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.opendaylight.controller.cluster.raft.persisted.LegacySerializable;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
19 public sealed class DisableTrackingPayload extends AbstractIdentifiablePayload<ClientIdentifier> {
20 @Deprecated(since = "7.0.0", forRemoval = true)
21 private static final class Magnesium extends DisableTrackingPayload implements LegacySerializable {
23 private static final long serialVersionUID = 1L;
25 Magnesium(final ClientIdentifier clientId, final byte[] serialized) {
26 super(clientId, serialized);
30 @Deprecated(since = "7.0.0", forRemoval = true)
31 private static final class Proxy extends AbstractProxy<ClientIdentifier> {
33 private static final long serialVersionUID = -5490519942445085251L;
35 @SuppressWarnings("checkstyle:RedundantModifier")
41 protected ClientIdentifier readIdentifier(final DataInput in) throws IOException {
42 return ClientIdentifier.readFrom(in);
46 protected DisableTrackingPayload createObject(final ClientIdentifier identifier,
47 final byte[] serialized) {
48 return new Magnesium(identifier, serialized);
52 private static final Logger LOG = LoggerFactory.getLogger(DisableTrackingPayload.class);
54 private static final long serialVersionUID = 1L;
55 private static final int PROXY_SIZE = externalizableProxySize(DT::new);
57 DisableTrackingPayload(final ClientIdentifier clientId, final byte[] serialized) {
58 super(clientId, serialized);
61 public static DisableTrackingPayload create(final ClientIdentifier clientId,
62 final int initialSerializedBufferCapacity) {
63 final ByteArrayDataOutput out = ByteStreams.newDataOutput(initialSerializedBufferCapacity);
65 clientId.writeTo(out);
66 } catch (IOException e) {
67 // This should never happen
68 LOG.error("Failed to serialize {}", clientId, e);
69 throw new IllegalStateException("Failed to serialize " + clientId, e);
71 return new DisableTrackingPayload(clientId, out.toByteArray());
75 protected DT externalizableProxy(final byte[] serialized) {
76 return new DT(serialized);
80 protected int externalizableProxySize() {