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;
44 DisableTrackingPayload(final ClientIdentifier clientId, final byte[] serialized) {
45 super(clientId, serialized);
48 public static DisableTrackingPayload create(final ClientIdentifier clientId,
49 final int initialSerializedBufferCapacity) {
50 final ByteArrayDataOutput out = ByteStreams.newDataOutput(initialSerializedBufferCapacity);
52 clientId.writeTo(out);
53 } catch (IOException e) {
54 // This should never happen
55 LOG.error("Failed to serialize {}", clientId, e);
56 throw new RuntimeException("Failed to serialize " + clientId, e);
58 return new DisableTrackingPayload(clientId, out.toByteArray());
62 protected Proxy externalizableProxy(final byte[] serialized) {
63 return new Proxy(serialized);