From 010adf819691f839812e9ca66e9147d801c9e54e Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sat, 26 Nov 2022 11:59:46 +0100 Subject: [PATCH] Remove old payload proxies We no longer need to carry compatibility serialization proxies, remove them. JIRA: CONTROLLER-2057 Change-Id: Ib040c0a082c94383b0224d593ad0ebec951b4d31 Signed-off-by: Robert Varga --- .../persisted/AbortTransactionPayload.java | 38 +----- .../AbstractIdentifiablePayload.java | 42 +------ .../persisted/CloseLocalHistoryPayload.java | 38 +----- .../persisted/CommitTransactionPayload.java | 68 +--------- .../persisted/CreateLocalHistoryPayload.java | 38 +----- .../cluster/datastore/persisted/DS.java | 37 ++++-- .../cluster/datastore/persisted/DSS.java | 19 +-- .../persisted/DatastoreSnapshot.java | 119 ------------------ .../persisted/DisableTrackingPayload.java | 36 +----- ...FrontendShardDataTreeSnapshotMetadata.java | 42 +------ .../MetadataShardDataTreeSnapshot.java | 65 ---------- .../persisted/PurgeLocalHistoryPayload.java | 38 +----- .../persisted/PurgeTransactionPayload.java | 38 +----- .../cluster/datastore/persisted/SM.java | 29 +++-- .../cluster/datastore/persisted/SS.java | 19 +-- .../persisted/ShardManagerSnapshot.java | 104 +-------------- .../persisted/ShardSnapshotState.java | 54 -------- .../persisted/SkipTransactionsPayload.java | 43 +------ 18 files changed, 91 insertions(+), 776 deletions(-) diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbortTransactionPayload.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbortTransactionPayload.java index 5f398853fe..3c765be615 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbortTransactionPayload.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbortTransactionPayload.java @@ -9,10 +9,8 @@ package org.opendaylight.controller.cluster.datastore.persisted; import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteStreams; -import java.io.DataInput; import java.io.IOException; import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; -import org.opendaylight.controller.cluster.raft.persisted.LegacySerializable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -21,41 +19,7 @@ import org.slf4j.LoggerFactory; * * @author Robert Varga */ -public sealed class AbortTransactionPayload extends AbstractIdentifiablePayload { - @Deprecated(since = "7.0.0", forRemoval = true) - private static final class Magnesium extends AbortTransactionPayload implements LegacySerializable { - @java.io.Serial - private static final long serialVersionUID = 1L; - - Magnesium(final TransactionIdentifier transactionId, final byte[] serialized) { - super(transactionId, serialized); - } - } - - @Deprecated(since = "7.0.0", forRemoval = true) - private static final class Proxy extends AbstractProxy { - @java.io.Serial - private static final long serialVersionUID = 1L; - - // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't - // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection. - @SuppressWarnings("checkstyle:RedundantModifier") - public Proxy() { - // For Externalizable - } - - @Override - protected TransactionIdentifier readIdentifier(final DataInput in) throws IOException { - return TransactionIdentifier.readFrom(in); - } - - @Override - protected AbortTransactionPayload createObject(final TransactionIdentifier identifier, - final byte[] serialized) { - return new Magnesium(identifier, serialized); - } - } - +public final class AbortTransactionPayload extends AbstractIdentifiablePayload { private static final Logger LOG = LoggerFactory.getLogger(AbortTransactionPayload.class); @java.io.Serial private static final long serialVersionUID = 1L; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractIdentifiablePayload.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractIdentifiablePayload.java index c835f7088a..885b6c5336 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractIdentifiablePayload.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/AbstractIdentifiablePayload.java @@ -11,8 +11,6 @@ import static com.google.common.base.Verify.verifyNotNull; import static java.util.Objects.requireNonNull; import com.google.common.base.MoreObjects; -import com.google.common.io.ByteStreams; -import java.io.DataInput; import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; @@ -21,7 +19,6 @@ import java.util.function.Function; import org.apache.commons.lang3.SerializationUtils; import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.raft.messages.IdentifiablePayload; -import org.opendaylight.yangtools.concepts.Identifiable; import org.opendaylight.yangtools.concepts.Identifier; /** @@ -84,44 +81,7 @@ public abstract class AbstractIdentifiablePayload extends } } - @Deprecated(since = "7.0.0", forRemoval = true) - protected abstract static class AbstractProxy implements SerialForm { - @java.io.Serial - private static final long serialVersionUID = 1L; - - private byte[] serialized; - private T identifier; - - public AbstractProxy() { - // For Externalizable - } - - protected AbstractProxy(final byte[] serialized) { - this.serialized = requireNonNull(serialized); - } - - @Override - public final byte[] bytes() { - return serialized; - } - - @Override - public final void readExternal(final byte[] bytes) throws IOException { - serialized = requireNonNull(bytes); - identifier = verifyNotNull(readIdentifier(ByteStreams.newDataInput(serialized))); - } - - @Override - public final Object readResolve() { - return verifyNotNull(createObject(identifier, serialized)); - } - - protected abstract @NonNull T readIdentifier(@NonNull DataInput in) throws IOException; - - @SuppressWarnings("checkstyle:hiddenField") - protected abstract @NonNull Identifiable createObject(@NonNull T identifier, byte @NonNull[] serialized); - } - + @java.io.Serial private static final long serialVersionUID = 1L; private final byte @NonNull [] serialized; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/CloseLocalHistoryPayload.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/CloseLocalHistoryPayload.java index ada468f314..9d6f526616 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/CloseLocalHistoryPayload.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/CloseLocalHistoryPayload.java @@ -9,10 +9,8 @@ package org.opendaylight.controller.cluster.datastore.persisted; import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteStreams; -import java.io.DataInput; import java.io.IOException; import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier; -import org.opendaylight.controller.cluster.raft.persisted.LegacySerializable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -21,41 +19,7 @@ import org.slf4j.LoggerFactory; * * @author Robert Varga */ -public sealed class CloseLocalHistoryPayload extends AbstractIdentifiablePayload { - @Deprecated(since = "7.0.0", forRemoval = true) - private static final class Magnesium extends CloseLocalHistoryPayload implements LegacySerializable { - @java.io.Serial - private static final long serialVersionUID = 1L; - - Magnesium(final LocalHistoryIdentifier historyId, final byte[] serialized) { - super(historyId, serialized); - } - } - - @Deprecated(since = "7.0.0", forRemoval = true) - private static final class Proxy extends AbstractProxy { - @java.io.Serial - private static final long serialVersionUID = 1L; - - // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't - // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection. - @SuppressWarnings("checkstyle:RedundantModifier") - public Proxy() { - // For Externalizable - } - - @Override - protected LocalHistoryIdentifier readIdentifier(final DataInput in) throws IOException { - return LocalHistoryIdentifier.readFrom(in); - } - - @Override - protected CloseLocalHistoryPayload createObject(final LocalHistoryIdentifier identifier, - final byte[] serialized) { - return new Magnesium(identifier, serialized); - } - } - +public final class CloseLocalHistoryPayload extends AbstractIdentifiablePayload { private static final Logger LOG = LoggerFactory.getLogger(CloseLocalHistoryPayload.class); @java.io.Serial private static final long serialVersionUID = 1L; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/CommitTransactionPayload.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/CommitTransactionPayload.java index a7643e6799..c8639bbebb 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/CommitTransactionPayload.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/CommitTransactionPayload.java @@ -7,7 +7,6 @@ */ package org.opendaylight.controller.cluster.datastore.persisted; -import static com.google.common.base.Verify.verifyNotNull; import static com.google.common.math.IntMath.ceilingPowerOfTwo; import static java.util.Objects.requireNonNull; @@ -19,12 +18,9 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.DataInput; import java.io.DataInputStream; import java.io.DataOutputStream; -import java.io.Externalizable; import java.io.IOException; -import java.io.ObjectInput; import java.io.ObjectOutput; import java.io.Serializable; -import java.io.StreamCorruptedException; import java.util.AbstractMap.SimpleImmutableEntry; import java.util.Map.Entry; import org.apache.commons.lang3.SerializationUtils; @@ -34,7 +30,6 @@ import org.opendaylight.controller.cluster.datastore.persisted.DataTreeCandidate import org.opendaylight.controller.cluster.io.ChunkedByteArray; import org.opendaylight.controller.cluster.io.ChunkedOutputStream; import org.opendaylight.controller.cluster.raft.messages.IdentifiablePayload; -import org.opendaylight.controller.cluster.raft.persisted.LegacySerializable; import org.opendaylight.yangtools.concepts.Either; import org.opendaylight.yangtools.yang.data.api.schema.stream.ReusableStreamReceiver; import org.opendaylight.yangtools.yang.data.impl.schema.ReusableImmutableNormalizedNodeStreamWriter; @@ -154,7 +149,7 @@ public abstract sealed class CommitTransactionPayload extends IdentifiablePayloa return new CT(this); } - static sealed class Simple extends CommitTransactionPayload { + static final class Simple extends CommitTransactionPayload { @java.io.Serial private static final long serialVersionUID = 1L; @@ -180,7 +175,7 @@ public abstract sealed class CommitTransactionPayload extends IdentifiablePayloa } } - static sealed class Chunked extends CommitTransactionPayload { + static final class Chunked extends CommitTransactionPayload { @java.io.Serial private static final long serialVersionUID = 1L; @@ -215,63 +210,4 @@ public abstract sealed class CommitTransactionPayload extends IdentifiablePayloa // Hidden on purpose } } - - @Deprecated(since = "7.0.0", forRemoval = true) - private static final class SimpleMagnesium extends Simple implements LegacySerializable { - @java.io.Serial - private static final long serialVersionUID = 1L; - - SimpleMagnesium(final byte[] serialized) { - super(serialized); - } - } - - @Deprecated(since = "7.0.0", forRemoval = true) - private static final class ChunkedMagnesium extends Chunked implements LegacySerializable { - @java.io.Serial - private static final long serialVersionUID = 1L; - - ChunkedMagnesium(final ChunkedByteArray source) { - super(source); - } - } - - @Deprecated(since = "7.0.0", forRemoval = true) - private static final class Proxy implements Externalizable { - @java.io.Serial - private static final long serialVersionUID = 1L; - - private CommitTransactionPayload payload; - - // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't - // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection. - @SuppressWarnings("checkstyle:RedundantModifier") - public Proxy() { - // For Externalizable - } - - @Override - public void writeExternal(final ObjectOutput out) { - throw new UnsupportedOperationException(); - } - - @Override - public void readExternal(final ObjectInput in) throws IOException { - final int length = in.readInt(); - if (length < 0) { - throw new StreamCorruptedException("Invalid payload length " + length); - } else if (length < MAX_ARRAY_SIZE) { - final byte[] serialized = new byte[length]; - in.readFully(serialized); - payload = new SimpleMagnesium(serialized); - } else { - payload = new ChunkedMagnesium(ChunkedByteArray.readFrom(in, length, MAX_ARRAY_SIZE)); - } - } - - @java.io.Serial - private Object readResolve() { - return verifyNotNull(payload); - } - } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/CreateLocalHistoryPayload.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/CreateLocalHistoryPayload.java index c0be946408..928503a9fc 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/CreateLocalHistoryPayload.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/CreateLocalHistoryPayload.java @@ -9,10 +9,8 @@ package org.opendaylight.controller.cluster.datastore.persisted; import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteStreams; -import java.io.DataInput; import java.io.IOException; import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier; -import org.opendaylight.controller.cluster.raft.persisted.LegacySerializable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -21,41 +19,7 @@ import org.slf4j.LoggerFactory; * * @author Robert Varga */ -public sealed class CreateLocalHistoryPayload extends AbstractIdentifiablePayload { - @Deprecated(since = "7.0.0", forRemoval = true) - private static final class Magnesium extends CreateLocalHistoryPayload implements LegacySerializable { - @java.io.Serial - private static final long serialVersionUID = 1L; - - Magnesium(final LocalHistoryIdentifier historyId, final byte[] serialized) { - super(historyId, serialized); - } - } - - @Deprecated(since = "7.0.0", forRemoval = true) - private static final class Proxy extends AbstractProxy { - @java.io.Serial - private static final long serialVersionUID = 1L; - - // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't - // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection. - @SuppressWarnings("checkstyle:RedundantModifier") - public Proxy() { - // For Externalizable - } - - @Override - protected LocalHistoryIdentifier readIdentifier(final DataInput in) throws IOException { - return LocalHistoryIdentifier.readFrom(in); - } - - @Override - protected CreateLocalHistoryPayload createObject(final LocalHistoryIdentifier identifier, - final byte[] serialized) { - return new Magnesium(identifier, serialized); - } - } - +public final class CreateLocalHistoryPayload extends AbstractIdentifiablePayload { private static final Logger LOG = LoggerFactory.getLogger(CreateLocalHistoryPayload.class); @java.io.Serial private static final long serialVersionUID = 1L; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/DS.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/DS.java index 894600adf1..091eeedbf6 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/DS.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/DS.java @@ -10,10 +10,17 @@ package org.opendaylight.controller.cluster.datastore.persisted; import static com.google.common.base.Verify.verifyNotNull; import static java.util.Objects.requireNonNull; +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.util.ArrayList; +import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot.ShardSnapshot; + /** * Serialization proxy for {@link DatastoreSnapshot}. */ -final class DS implements DatastoreSnapshot.SerialForm { +final class DS implements Externalizable { @java.io.Serial private static final long serialVersionUID = 1L; @@ -29,17 +36,33 @@ final class DS implements DatastoreSnapshot.SerialForm { } @Override - public DatastoreSnapshot datastoreSnapshot() { - return datastoreSnapshot; + public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { + final var type = (String) in.readObject(); + final var snapshot = (ShardManagerSnapshot) in.readObject(); + + final int size = in.readInt(); + var localShardSnapshots = new ArrayList(size); + for (int i = 0; i < size; i++) { + localShardSnapshots.add((ShardSnapshot) in.readObject()); + } + + datastoreSnapshot = new DatastoreSnapshot(type, snapshot, localShardSnapshots); } @Override - public void resolveTo(final DatastoreSnapshot newDatastoreSnapshot) { - datastoreSnapshot = requireNonNull(newDatastoreSnapshot); + public void writeExternal(final ObjectOutput out) throws IOException { + out.writeObject(datastoreSnapshot.getType()); + out.writeObject(datastoreSnapshot.getShardManagerSnapshot()); + + final var shardSnapshots = datastoreSnapshot.getShardSnapshots(); + out.writeInt(shardSnapshots.size()); + for (var shardSnapshot : shardSnapshots) { + out.writeObject(shardSnapshot); + } } - @Override - public Object readResolve() { + @java.io.Serial + private Object readResolve() { return verifyNotNull(datastoreSnapshot); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/DSS.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/DSS.java index 5d6ea922cc..9edb090f12 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/DSS.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/DSS.java @@ -10,13 +10,17 @@ package org.opendaylight.controller.cluster.datastore.persisted; import static com.google.common.base.Verify.verifyNotNull; import static java.util.Objects.requireNonNull; +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot.ShardSnapshot; import org.opendaylight.controller.cluster.raft.persisted.Snapshot; /** * Serialization proxy for {@link ShardDataTreeSnapshot}. */ -final class DSS implements ShardSnapshot.SerialForm { +final class DSS implements Externalizable { @java.io.Serial private static final long serialVersionUID = 1L; @@ -32,17 +36,18 @@ final class DSS implements ShardSnapshot.SerialForm { } @Override - public ShardSnapshot shardSnapshot() { - return shardSnapshot; + public void writeExternal(final ObjectOutput out) throws IOException { + out.writeObject(shardSnapshot.getName()); + out.writeObject(shardSnapshot.getSnapshot()); } @Override - public void resolveTo(final String name, final Snapshot snapshot) { - shardSnapshot = new ShardSnapshot(name, snapshot); + public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { + shardSnapshot = new ShardSnapshot((String) in.readObject(), (Snapshot) in.readObject()); } - @Override - public Object readResolve() { + @java.io.Serial + private Object readResolve() { return verifyNotNull(shardSnapshot); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/DatastoreSnapshot.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/DatastoreSnapshot.java index fe9501ffb6..9c0a3acc72 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/DatastoreSnapshot.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/DatastoreSnapshot.java @@ -7,16 +7,10 @@ */ package org.opendaylight.controller.cluster.datastore.persisted; -import static com.google.common.base.Verify.verifyNotNull; import static java.util.Objects.requireNonNull; import com.google.common.collect.ImmutableList; -import java.io.Externalizable; -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; import java.io.Serializable; -import java.util.ArrayList; import java.util.List; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; @@ -28,69 +22,6 @@ import org.opendaylight.controller.cluster.raft.persisted.Snapshot; * @author Thomas Pantelis */ public final class DatastoreSnapshot implements Serializable { - interface SerialForm extends Externalizable { - - DatastoreSnapshot datastoreSnapshot(); - - Object readResolve(); - - void resolveTo(@NonNull DatastoreSnapshot newDatastoreSnapshot); - - @Override - default void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { - final var type = (String)in.readObject(); - final var snapshot = (ShardManagerSnapshot) in.readObject(); - - final int size = in.readInt(); - var localShardSnapshots = new ArrayList(size); - for (int i = 0; i < size; i++) { - localShardSnapshots.add((ShardSnapshot) in.readObject()); - } - - resolveTo(new DatastoreSnapshot(type, snapshot, localShardSnapshots)); - } - - @Override - default void writeExternal(final ObjectOutput out) throws IOException { - final var datastoreSnapshot = datastoreSnapshot(); - out.writeObject(datastoreSnapshot.type); - out.writeObject(datastoreSnapshot.shardManagerSnapshot); - - out.writeInt(datastoreSnapshot.shardSnapshots.size()); - for (ShardSnapshot shardSnapshot: datastoreSnapshot.shardSnapshots) { - out.writeObject(shardSnapshot); - } - } - } - - private static final class Proxy implements SerialForm { - private static final long serialVersionUID = 1L; - - private DatastoreSnapshot datastoreSnapshot; - - // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't - // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection. - @SuppressWarnings("checkstyle:RedundantModifier") - public Proxy() { - // For Externalizable - } - - @Override - public DatastoreSnapshot datastoreSnapshot() { - return datastoreSnapshot; - } - - @Override - public void resolveTo(final DatastoreSnapshot newDatastoreSnapshot) { - datastoreSnapshot = requireNonNull(newDatastoreSnapshot); - } - - @Override - public Object readResolve() { - return verifyNotNull(datastoreSnapshot); - } - } - @java.io.Serial private static final long serialVersionUID = 1L; @@ -123,56 +54,6 @@ public final class DatastoreSnapshot implements Serializable { } public static final class ShardSnapshot implements Serializable { - interface SerialForm extends Externalizable { - - ShardSnapshot shardSnapshot(); - - Object readResolve(); - - void resolveTo(String name, Snapshot snapshot); - - @Override - default void writeExternal(final ObjectOutput out) throws IOException { - final var shardSnapshot = shardSnapshot(); - out.writeObject(shardSnapshot.name); - out.writeObject(shardSnapshot.snapshot); - } - - @Override - default void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { - resolveTo((String) in.readObject(), (Snapshot) in.readObject()); - } - } - - private static final class Proxy implements SerialForm { - @java.io.Serial - private static final long serialVersionUID = 1L; - - private ShardSnapshot shardSnapshot; - - // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't - // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection. - @SuppressWarnings("checkstyle:RedundantModifier") - public Proxy() { - // For Externalizable - } - - @Override - public ShardSnapshot shardSnapshot() { - return shardSnapshot; - } - - @Override - public void resolveTo(final String name, final Snapshot snapshot) { - shardSnapshot = new ShardSnapshot(name, snapshot); - } - - @Override - public Object readResolve() { - return verifyNotNull(shardSnapshot); - } - } - @java.io.Serial private static final long serialVersionUID = 1L; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/DisableTrackingPayload.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/DisableTrackingPayload.java index b531174576..293f396a94 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/DisableTrackingPayload.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/DisableTrackingPayload.java @@ -9,46 +9,12 @@ package org.opendaylight.controller.cluster.datastore.persisted; import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteStreams; -import java.io.DataInput; import java.io.IOException; import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier; -import org.opendaylight.controller.cluster.raft.persisted.LegacySerializable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public sealed class DisableTrackingPayload extends AbstractIdentifiablePayload { - @Deprecated(since = "7.0.0", forRemoval = true) - private static final class Magnesium extends DisableTrackingPayload implements LegacySerializable { - @java.io.Serial - private static final long serialVersionUID = 1L; - - Magnesium(final ClientIdentifier clientId, final byte[] serialized) { - super(clientId, serialized); - } - } - - @Deprecated(since = "7.0.0", forRemoval = true) - private static final class Proxy extends AbstractProxy { - @java.io.Serial - private static final long serialVersionUID = -5490519942445085251L; - - @SuppressWarnings("checkstyle:RedundantModifier") - public Proxy() { - // For Externalizable - } - - @Override - protected ClientIdentifier readIdentifier(final DataInput in) throws IOException { - return ClientIdentifier.readFrom(in); - } - - @Override - protected DisableTrackingPayload createObject(final ClientIdentifier identifier, - final byte[] serialized) { - return new Magnesium(identifier, serialized); - } - } - +public final class DisableTrackingPayload extends AbstractIdentifiablePayload { private static final Logger LOG = LoggerFactory.getLogger(DisableTrackingPayload.class); @java.io.Serial private static final long serialVersionUID = 1L; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/FrontendShardDataTreeSnapshotMetadata.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/FrontendShardDataTreeSnapshotMetadata.java index c5eb512c81..1d28ccac45 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/FrontendShardDataTreeSnapshotMetadata.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/FrontendShardDataTreeSnapshotMetadata.java @@ -11,49 +11,11 @@ import com.google.common.base.MoreObjects; import com.google.common.collect.ImmutableList; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.Externalizable; -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.util.ArrayList; import java.util.Collection; import java.util.List; -public final class FrontendShardDataTreeSnapshotMetadata extends - ShardDataTreeSnapshotMetadata { - private static final class Proxy implements Externalizable { - @java.io.Serial - private static final long serialVersionUID = 1L; - - private List clients; - - // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't - // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection. - @SuppressWarnings("checkstyle:RedundantModifier") - public Proxy() { - // For Externalizable - } - - @Override - public void writeExternal(final ObjectOutput out) { - throw new UnsupportedOperationException(); - } - - @Override - public void readExternal(final ObjectInput in) throws IOException { - final int size = in.readInt(); - final List readedClients = new ArrayList<>(size); - for (int i = 0; i < size ; ++i) { - readedClients.add(FrontendClientMetadata.readFrom(in)); - } - clients = ImmutableList.copyOf(readedClients); - } - - @java.io.Serial - private Object readResolve() { - return new FrontendShardDataTreeSnapshotMetadata(clients); - } - } - +public final class FrontendShardDataTreeSnapshotMetadata + extends ShardDataTreeSnapshotMetadata { @java.io.Serial private static final long serialVersionUID = 1L; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/MetadataShardDataTreeSnapshot.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/MetadataShardDataTreeSnapshot.java index a33a650052..1c9b5d19b6 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/MetadataShardDataTreeSnapshot.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/MetadataShardDataTreeSnapshot.java @@ -7,26 +7,15 @@ */ package org.opendaylight.controller.cluster.datastore.persisted; -import static com.google.common.base.Preconditions.checkArgument; import static java.util.Objects.requireNonNull; import com.google.common.annotations.Beta; import com.google.common.base.MoreObjects; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import java.io.Externalizable; -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; import java.io.Serializable; -import java.io.StreamCorruptedException; import java.util.Map; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; -import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeDataInput; -import org.opendaylight.yangtools.yang.data.codec.binfmt.NormalizedNodeStreamVersion; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * An {@link AbstractVersionedShardDataTreeSnapshot} which contains additional metadata. @@ -36,60 +25,6 @@ import org.slf4j.LoggerFactory; @Beta public final class MetadataShardDataTreeSnapshot extends AbstractVersionedShardDataTreeSnapshot implements Serializable { - private static final class Proxy implements Externalizable { - @java.io.Serial - private static final long serialVersionUID = 1L; - private static final Logger LOG = LoggerFactory.getLogger(MetadataShardDataTreeSnapshot.class); - - private Map>, ShardDataTreeSnapshotMetadata> metadata; - private NormalizedNodeStreamVersion version; - private NormalizedNode rootNode; - - // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't - // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection. - @SuppressWarnings("checkstyle:RedundantModifier") - public Proxy() { - // For Externalizable - } - - @Override - public void writeExternal(final ObjectOutput out) { - throw new UnsupportedOperationException(); - } - - @Override - public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { - final int metaSize = in.readInt(); - checkArgument(metaSize >= 0, "Invalid negative metadata map length %s", metaSize); - - // Default pre-allocate is 4, which should be fine - final Builder>, ShardDataTreeSnapshotMetadata> - metaBuilder = ImmutableMap.builder(); - for (int i = 0; i < metaSize; ++i) { - final ShardDataTreeSnapshotMetadata m = (ShardDataTreeSnapshotMetadata) in.readObject(); - if (m != null) { - metaBuilder.put(m.getType(), m); - } else { - LOG.warn("Skipping null metadata"); - } - } - - metadata = metaBuilder.build(); - final boolean present = in.readBoolean(); - if (!present) { - throw new StreamCorruptedException("Unexpected missing root node"); - } - - final NormalizedNodeDataInput stream = NormalizedNodeDataInput.newDataInput(in); - version = stream.getVersion(); - rootNode = stream.readNormalizedNode(); - } - - private Object readResolve() { - return new MetadataShardDataTreeSnapshot(rootNode, metadata); - } - } - @java.io.Serial private static final long serialVersionUID = 1L; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/PurgeLocalHistoryPayload.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/PurgeLocalHistoryPayload.java index a9e4557ece..3608e7589f 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/PurgeLocalHistoryPayload.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/PurgeLocalHistoryPayload.java @@ -9,10 +9,8 @@ package org.opendaylight.controller.cluster.datastore.persisted; import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteStreams; -import java.io.DataInput; import java.io.IOException; import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier; -import org.opendaylight.controller.cluster.raft.persisted.LegacySerializable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -22,41 +20,7 @@ import org.slf4j.LoggerFactory; * * @author Robert Varga */ -public sealed class PurgeLocalHistoryPayload extends AbstractIdentifiablePayload { - @Deprecated(since = "7.0.0", forRemoval = true) - private static final class Magnesium extends PurgeLocalHistoryPayload implements LegacySerializable { - @java.io.Serial - private static final long serialVersionUID = 1L; - - Magnesium(final LocalHistoryIdentifier historyId, final byte[] serialized) { - super(historyId, serialized); - } - } - - @Deprecated(since = "7.0.0", forRemoval = true) - private static final class Proxy extends AbstractProxy { - @java.io.Serial - private static final long serialVersionUID = 1L; - - // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't - // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection. - @SuppressWarnings("checkstyle:RedundantModifier") - public Proxy() { - // For Externalizable - } - - @Override - protected LocalHistoryIdentifier readIdentifier(final DataInput in) throws IOException { - return LocalHistoryIdentifier.readFrom(in); - } - - @Override - protected PurgeLocalHistoryPayload createObject(final LocalHistoryIdentifier identifier, - final byte[] serialized) { - return new Magnesium(identifier, serialized); - } - } - +public final class PurgeLocalHistoryPayload extends AbstractIdentifiablePayload { private static final Logger LOG = LoggerFactory.getLogger(PurgeLocalHistoryPayload.class); @java.io.Serial private static final long serialVersionUID = 1L; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/PurgeTransactionPayload.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/PurgeTransactionPayload.java index 4d5d2d742c..e63fa3b72d 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/PurgeTransactionPayload.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/PurgeTransactionPayload.java @@ -9,10 +9,8 @@ package org.opendaylight.controller.cluster.datastore.persisted; import com.google.common.io.ByteArrayDataOutput; import com.google.common.io.ByteStreams; -import java.io.DataInput; import java.io.IOException; import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; -import org.opendaylight.controller.cluster.raft.persisted.LegacySerializable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -21,41 +19,7 @@ import org.slf4j.LoggerFactory; * * @author Robert Varga */ -public sealed class PurgeTransactionPayload extends AbstractIdentifiablePayload { - @Deprecated(since = "7.0.0", forRemoval = true) - private static final class Magnesium extends PurgeTransactionPayload implements LegacySerializable { - @java.io.Serial - private static final long serialVersionUID = 1L; - - Magnesium(final TransactionIdentifier transactionId, final byte[] serialized) { - super(transactionId, serialized); - } - } - - @Deprecated(since = "7.0.0", forRemoval = true) - private static final class Proxy extends AbstractProxy { - @java.io.Serial - private static final long serialVersionUID = 1L; - - // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't - // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection. - @SuppressWarnings("checkstyle:RedundantModifier") - public Proxy() { - // For Externalizable - } - - @Override - protected TransactionIdentifier readIdentifier(final DataInput in) throws IOException { - return TransactionIdentifier.readFrom(in); - } - - @Override - protected PurgeTransactionPayload createObject(final TransactionIdentifier identifier, - final byte[] serialized) { - return new Magnesium(identifier, serialized); - } - } - +public final class PurgeTransactionPayload extends AbstractIdentifiablePayload { private static final Logger LOG = LoggerFactory.getLogger(PurgeTransactionPayload.class); @java.io.Serial private static final long serialVersionUID = 1L; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/SM.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/SM.java index 07c33086bf..dc39f5cf58 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/SM.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/SM.java @@ -10,12 +10,16 @@ package org.opendaylight.controller.cluster.datastore.persisted; import static com.google.common.base.Verify.verifyNotNull; import static java.util.Objects.requireNonNull; -import java.util.List; +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.util.ArrayList; /** * Serialization proxy for {@link ShardManagerSnapshot}. */ -final class SM implements ShardManagerSnapshot.SerializedForm { +final class SM implements Externalizable { @java.io.Serial private static final long serialVersionUID = 1L; @@ -31,17 +35,26 @@ final class SM implements ShardManagerSnapshot.SerializedForm { } @Override - public List shardNames() { - return snapshot.getShardList(); + public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { + final int size = in.readInt(); + final var shardList = new ArrayList(size); + for (int i = 0; i < size; i++) { + shardList.add((String) in.readObject()); + } + snapshot = new ShardManagerSnapshot(shardList); } @Override - public void resolveTo(final ShardManagerSnapshot newSnapshot) { - snapshot = requireNonNull(newSnapshot); + public void writeExternal(final ObjectOutput out) throws IOException { + final var shardList = snapshot.getShardList(); + out.writeInt(shardList.size()); + for (var shardName : shardList) { + out.writeObject(shardName); + } } - @Override - public Object readResolve() { + @java.io.Serial + private Object readResolve() { return verifyNotNull(snapshot); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/SS.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/SS.java index f816002c9a..f719e1b93e 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/SS.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/SS.java @@ -10,10 +10,15 @@ package org.opendaylight.controller.cluster.datastore.persisted; import static com.google.common.base.Verify.verifyNotNull; import static java.util.Objects.requireNonNull; +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; + /** * Serialization proxy for {@link ShardSnapshotState}. */ -final class SS implements ShardSnapshotState.SerialForm { +final class SS implements Externalizable { @java.io.Serial private static final long serialVersionUID = 1L; @@ -29,17 +34,17 @@ final class SS implements ShardSnapshotState.SerialForm { } @Override - public ShardSnapshotState snapshotState() { - return snapshotState; + public void readExternal(final ObjectInput in) throws IOException { + snapshotState = ShardDataTreeSnapshot.deserialize(in); } @Override - public void resolveTo(final ShardSnapshotState newSnapshotState) { - snapshotState = requireNonNull(newSnapshotState); + public void writeExternal(final ObjectOutput out) throws IOException { + snapshotState.getSnapshot().serialize(out); } - @Override - public Object readResolve() { + @java.io.Serial + private Object readResolve() { return verifyNotNull(snapshotState); } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ShardManagerSnapshot.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ShardManagerSnapshot.java index b211d1a54f..86d293528a 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ShardManagerSnapshot.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ShardManagerSnapshot.java @@ -7,113 +7,17 @@ */ package org.opendaylight.controller.cluster.datastore.persisted; -import static java.util.Objects.requireNonNull; - import com.google.common.collect.ImmutableList; -import java.io.Externalizable; -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; import java.io.Serializable; -import java.util.ArrayList; import java.util.List; import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.controller.cluster.raft.persisted.MigratedSerializable; /** * Represents the persisted snapshot state for the ShardManager. * * @author Thomas Pantelis */ -public sealed class ShardManagerSnapshot implements Serializable { - interface SerializedForm extends Externalizable { - /** - * Return the serial form of this object contents, corresponding to {@link ShardManagerSnapshot#shardList}. - * - * @return List of shards names. - */ - List shardNames(); - - /** - * Resolve this proxy to an actual {@link ShardManagerSnapshot}. Implementations can rely on the object to be - * set via {@link #resolveTo(ShardManagerSnapshot)}. - * - * @return A snapshot - */ - Object readResolve(); - - /** - * Set this proxy to return {@code snapshot} on next {@link #readResolve()}. - * - * @param newSnapshot Snapshot to set - */ - void resolveTo(@NonNull ShardManagerSnapshot newSnapshot); - - @Override - default void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { - final int size = in.readInt(); - final var shardList = new ArrayList(size); - for (int i = 0; i < size; i++) { - shardList.add((String) in.readObject()); - } - resolveTo(new ShardManagerSnapshot(shardList)); - } - - @Override - default void writeExternal(final ObjectOutput out) throws IOException { - final var shardList = shardNames(); - out.writeInt(shardList.size()); - for (var shardName : shardList) { - out.writeObject(shardName); - } - } - } - - @Deprecated(since = "7.0.0", forRemoval = true) - private static final class Magnesium extends ShardManagerSnapshot implements MigratedSerializable { - @java.io.Serial - private static final long serialVersionUID = 1L; - - Magnesium(final List shardList) { - super(shardList); - } - - @Override - public boolean isMigrated() { - return true; - } - } - - @Deprecated(since = "7.0.0", forRemoval = true) - private static final class Proxy implements SerializedForm { - @java.io.Serial - private static final long serialVersionUID = 1L; - - private ShardManagerSnapshot snapshot = null; - - // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't - // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection. - @SuppressWarnings("checkstyle:RedundantModifier") - public Proxy() { - // For Externalizable - } - - @Override - public List shardNames() { - return snapshot.getShardList(); - } - - @Override - public void resolveTo(final ShardManagerSnapshot newSnapshot) { - snapshot = requireNonNull(newSnapshot); - } - - @Override - public Object readResolve() { - return new Magnesium(snapshot.getShardList()); - } - } - +public final class ShardManagerSnapshot implements Serializable { @java.io.Serial private static final long serialVersionUID = 1L; @@ -123,17 +27,17 @@ public sealed class ShardManagerSnapshot implements Serializable { this.shardList = ImmutableList.copyOf(shardList); } - public final List getShardList() { + public List getShardList() { return shardList; } @java.io.Serial - public final Object writeReplace() { + private Object writeReplace() { return new SM(this); } @Override - public final String toString() { + public String toString() { return "ShardManagerSnapshot [ShardList = " + shardList + " ]"; } } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ShardSnapshotState.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ShardSnapshotState.java index 90275c19a6..c06c5cf318 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ShardSnapshotState.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/ShardSnapshotState.java @@ -7,15 +7,10 @@ */ package org.opendaylight.controller.cluster.datastore.persisted; -import static com.google.common.base.Verify.verifyNotNull; import static java.util.Objects.requireNonNull; import com.google.common.annotations.VisibleForTesting; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import java.io.Externalizable; -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.raft.persisted.Snapshot; @@ -25,55 +20,6 @@ import org.opendaylight.controller.cluster.raft.persisted.Snapshot; * @author Thomas Pantelis */ public final class ShardSnapshotState implements Snapshot.State { - interface SerialForm extends Externalizable { - - ShardSnapshotState snapshotState(); - - void resolveTo(@NonNull ShardSnapshotState newSnapshotState); - - Object readResolve(); - - @Override - default void readExternal(final ObjectInput in) throws IOException { - resolveTo(ShardDataTreeSnapshot.deserialize(in)); - } - - @Override - default void writeExternal(final ObjectOutput out) throws IOException { - snapshotState().getSnapshot().serialize(out); - } - } - - @Deprecated(since = "7.0.0", forRemoval = true) - private static final class Proxy implements SerialForm { - @java.io.Serial - private static final long serialVersionUID = 1L; - - private ShardSnapshotState snapshotState; - - // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't - // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection. - @SuppressWarnings("checkstyle:RedundantModifier") - public Proxy() { - // For Externalizable - } - - @Override - public ShardSnapshotState snapshotState() { - return snapshotState; - } - - @Override - public void resolveTo(final ShardSnapshotState newSnapshotState) { - snapshotState = requireNonNull(newSnapshotState); - } - - @Override - public Object readResolve() { - return verifyNotNull(snapshotState); - } - } - @java.io.Serial private static final long serialVersionUID = 1L; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/SkipTransactionsPayload.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/SkipTransactionsPayload.java index 085774592b..a8fb52c4b9 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/SkipTransactionsPayload.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/SkipTransactionsPayload.java @@ -7,17 +7,14 @@ */ package org.opendaylight.controller.cluster.datastore.persisted; -import static com.google.common.base.Verify.verifyNotNull; import static java.util.Objects.requireNonNull; import com.google.common.io.ByteStreams; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import java.io.DataInput; import java.io.IOException; import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier; import org.opendaylight.controller.cluster.datastore.utils.ImmutableUnsignedLongSet; -import org.opendaylight.controller.cluster.raft.persisted.LegacySerializable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -26,45 +23,7 @@ import org.slf4j.LoggerFactory; * for other purposes. It contains a {@link LocalHistoryIdentifier} and a list of transaction identifiers within that * local history. */ -public sealed class SkipTransactionsPayload extends AbstractIdentifiablePayload { - private static final class Magnesium extends SkipTransactionsPayload implements LegacySerializable { - @java.io.Serial - private static final long serialVersionUID = 1L; - - Magnesium(final LocalHistoryIdentifier historyId, final byte[] serialized, - final ImmutableUnsignedLongSet transactionIds) { - super(historyId, serialized, transactionIds); - } - } - - @Deprecated(since = "7.0.0", forRemoval = true) - private static final class Proxy extends AbstractProxy { - @java.io.Serial - private static final long serialVersionUID = 1L; - - private ImmutableUnsignedLongSet transactionIds; - - // checkstyle flags the public modifier as redundant which really doesn't make sense since it clearly isn't - // redundant. It is explicitly needed for Java serialization to be able to create instances via reflection. - @SuppressWarnings("checkstyle:RedundantModifier") - public Proxy() { - // For Externalizable - } - - @Override - protected LocalHistoryIdentifier readIdentifier(final DataInput in) throws IOException { - final var id = LocalHistoryIdentifier.readFrom(in); - transactionIds = ImmutableUnsignedLongSet.readFrom(in); - return id; - } - - @Override - protected SkipTransactionsPayload createObject(final LocalHistoryIdentifier identifier, - final byte[] serialized) { - return new Magnesium(identifier, serialized, verifyNotNull(transactionIds)); - } - } - +public final class SkipTransactionsPayload extends AbstractIdentifiablePayload { private static final Logger LOG = LoggerFactory.getLogger(SkipTransactionsPayload.class); @java.io.Serial private static final long serialVersionUID = 1L; -- 2.36.6