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.DataInput;
13 import java.io.IOException;
14 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
18 public final class DisableTrackingPayload extends AbstractIdentifiablePayload<ClientIdentifier> {
19 private static final class Proxy extends AbstractProxy<ClientIdentifier> {
21 private static final long serialVersionUID = -5490519942445085251L;
23 @SuppressWarnings("checkstyle:RedundantModifier")
28 Proxy(final byte[] serialized) {
33 protected ClientIdentifier readIdentifier(final DataInput in) throws IOException {
34 return ClientIdentifier.readFrom(in);
38 protected DisableTrackingPayload createObject(final ClientIdentifier identifier,
39 final byte[] serialized) {
40 return new DisableTrackingPayload(identifier, serialized);
44 private static final Logger LOG = LoggerFactory.getLogger(DisableTrackingPayload.class);
45 private static final long serialVersionUID = 1L;
46 private static final int PROXY_SIZE = externalizableProxySize(Proxy::new);
48 DisableTrackingPayload(final ClientIdentifier clientId, final byte[] serialized) {
49 super(clientId, serialized);
52 public static DisableTrackingPayload create(final ClientIdentifier clientId,
53 final int initialSerializedBufferCapacity) {
54 final ByteArrayDataOutput out = ByteStreams.newDataOutput(initialSerializedBufferCapacity);
56 clientId.writeTo(out);
57 } catch (IOException e) {
58 // This should never happen
59 LOG.error("Failed to serialize {}", clientId, e);
60 throw new IllegalStateException("Failed to serialize " + clientId, e);
62 return new DisableTrackingPayload(clientId, out.toByteArray());
66 protected Proxy externalizableProxy(final byte[] serialized) {
67 return new Proxy(serialized);
71 protected int externalizableProxySize() {