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> {
20 @SuppressWarnings("checkstyle:RedundantModifier")
25 Proxy(final byte[] serialized) {
30 protected ClientIdentifier readIdentifier(final DataInput in) throws IOException {
31 return ClientIdentifier.readFrom(in);
35 protected DisableTrackingPayload createObject(final ClientIdentifier identifier,
36 final byte[] serialized) {
37 return new DisableTrackingPayload(identifier, serialized);
41 private static final Logger LOG = LoggerFactory.getLogger(DisableTrackingPayload.class);
42 private static final long serialVersionUID = 1L;
43 private static final int PROXY_SIZE = externalizableProxySize(Proxy::new);
45 DisableTrackingPayload(final ClientIdentifier clientId, final byte[] serialized) {
46 super(clientId, serialized);
49 public static DisableTrackingPayload create(final ClientIdentifier clientId,
50 final int initialSerializedBufferCapacity) {
51 final ByteArrayDataOutput out = ByteStreams.newDataOutput(initialSerializedBufferCapacity);
53 clientId.writeTo(out);
54 } catch (IOException e) {
55 // This should never happen
56 LOG.error("Failed to serialize {}", clientId, e);
57 throw new IllegalStateException("Failed to serialize " + clientId, e);
59 return new DisableTrackingPayload(clientId, out.toByteArray());
63 protected Proxy externalizableProxy(final byte[] serialized) {
64 return new Proxy(serialized);
68 protected int externalizableProxySize() {