2 * Copyright (c) 2019 PANTHEON.tech, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.cluster.datastore.persisted;
10 import com.google.common.io.ByteArrayDataOutput;
11 import com.google.common.io.ByteStreams;
12 import java.io.IOException;
13 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
17 public final class DisableTrackingPayload extends AbstractIdentifiablePayload<ClientIdentifier> {
18 private static final Logger LOG = LoggerFactory.getLogger(DisableTrackingPayload.class);
20 private static final long serialVersionUID = 1L;
21 private static final int PROXY_SIZE = externalizableProxySize(DT::new);
23 DisableTrackingPayload(final ClientIdentifier clientId, final byte[] serialized) {
24 super(clientId, serialized);
27 public static DisableTrackingPayload create(final ClientIdentifier clientId,
28 final int initialSerializedBufferCapacity) {
29 final ByteArrayDataOutput out = ByteStreams.newDataOutput(initialSerializedBufferCapacity);
31 clientId.writeTo(out);
32 } catch (IOException e) {
33 // This should never happen
34 LOG.error("Failed to serialize {}", clientId, e);
35 throw new IllegalStateException("Failed to serialize " + clientId, e);
37 return new DisableTrackingPayload(clientId, out.toByteArray());
41 protected DT externalizableProxy(final byte[] serialized) {
42 return new DT(serialized);
46 protected int externalizableProxySize() {