Remove legacy raft.persisted proxies 66/105166/14
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 3 Apr 2023 13:51:53 +0000 (15:51 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 12 May 2023 17:42:40 +0000 (19:42 +0200)
These proxies have not been emitted since controller-7.0.0, remove them
now.

JIRA: CONTROLLER-2078
Change-Id: I31a86bf464857fccbc1d68a1f0d520971cb153b5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/ApplyJournalEntries.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/DeleteEntries.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/NoopPayload.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/SimpleReplicatedLogEntry.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/Snapshot.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/UpdateElectionTerm.java

index 4439e2cfa1721063c7555325386195cfb9497dfc..30da667c2695c666f04eaae0d3f2a216772fe125 100644 (file)
@@ -8,10 +8,6 @@
 package org.opendaylight.controller.cluster.raft.persisted;
 
 import akka.dispatch.ControlMessage;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
 import java.io.Serializable;
 
 /**
@@ -22,47 +18,7 @@ import java.io.Serializable;
  *
  * @author Thomas Pantelis
  */
-public sealed class ApplyJournalEntries implements Serializable, ControlMessage {
-    @Deprecated(since = "7.0.0", forRemoval = true)
-    private static final class Legacy extends ApplyJournalEntries implements LegacySerializable {
-        @java.io.Serial
-        private static final long serialVersionUID = 1L;
-
-        Legacy(final long toIndex) {
-            super(toIndex);
-        }
-    }
-
-    @Deprecated(since = "7.0.0", forRemoval = true)
-    private static final class Proxy implements Externalizable {
-        @java.io.Serial
-        private static final long serialVersionUID = 1L;
-
-        private ApplyJournalEntries applyEntries = 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 void writeExternal(final ObjectOutput out) throws IOException {
-            out.writeLong(applyEntries.toIndex);
-        }
-
-        @Override
-        public void readExternal(final ObjectInput in) throws IOException {
-            applyEntries = new Legacy(in.readLong());
-        }
-
-        @java.io.Serial
-        private Object readResolve() {
-            return applyEntries;
-        }
-    }
-
+public final class ApplyJournalEntries implements Serializable, ControlMessage {
     @java.io.Serial
     private static final long serialVersionUID = 1L;
 
@@ -72,17 +28,17 @@ public sealed class ApplyJournalEntries implements Serializable, ControlMessage
         this.toIndex = toIndex;
     }
 
-    public final long getToIndex() {
+    public long getToIndex() {
         return toIndex;
     }
 
-    @java.io.Serial
-    public final Object writeReplace() {
-        return new AJE(this);
-    }
-
     @Override
-    public final String toString() {
+    public String toString() {
         return "ApplyJournalEntries [toIndex=" + toIndex + "]";
     }
+
+    @java.io.Serial
+    private Object writeReplace() {
+        return new AJE(this);
+    }
 }
index 189ca9c5c83351c5dfe47eb95d73293cdd237ea3..8b4eb8388af80799ffd77dc439aca9c10a29cac6 100644 (file)
@@ -7,10 +7,6 @@
  */
 package org.opendaylight.controller.cluster.raft.persisted;
 
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
 import java.io.Serializable;
 
 /**
@@ -18,47 +14,7 @@ import java.io.Serializable;
  *
  * @author Thomas Pantelis
  */
-public sealed class DeleteEntries implements Serializable {
-    @Deprecated(since = "7.0.0", forRemoval = true)
-    private static final class Legacy extends DeleteEntries implements LegacySerializable {
-        @java.io.Serial
-        private static final long serialVersionUID = 1L;
-
-        Legacy(final long fromIndex) {
-            super(fromIndex);
-        }
-    }
-
-    @Deprecated(since = "7.0.0", forRemoval = true)
-    private static final class Proxy implements Externalizable {
-        @java.io.Serial
-        private static final long serialVersionUID = 1L;
-
-        private DeleteEntries deleteEntries = 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 void writeExternal(final ObjectOutput out) throws IOException {
-            out.writeLong(deleteEntries.fromIndex);
-        }
-
-        @Override
-        public void readExternal(final ObjectInput in) throws IOException {
-            deleteEntries = new Legacy(in.readLong());
-        }
-
-        @java.io.Serial
-        private Object readResolve() {
-            return deleteEntries;
-        }
-    }
-
+public final class DeleteEntries implements Serializable {
     @java.io.Serial
     private static final long serialVersionUID = 1L;
 
@@ -68,17 +24,17 @@ public sealed class DeleteEntries implements Serializable {
         this.fromIndex = fromIndex;
     }
 
-    public final long getFromIndex() {
+    public long getFromIndex() {
         return fromIndex;
     }
 
-    @java.io.Serial
-    public final Object writeReplace() {
-        return new DE(this);
-    }
-
     @Override
-    public final String toString() {
+    public String toString() {
         return "DeleteEntries [fromIndex=" + fromIndex + "]";
     }
+
+    @java.io.Serial
+    private Object writeReplace() {
+        return new DE(this);
+    }
 }
index f1a3a3b923cab4bd370511316663ce74e20d402e..0f076c55d755a3286433d388aad2e33faeef1fdb 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.controller.cluster.raft.persisted;
 
 import akka.dispatch.ControlMessage;
-import java.io.Serializable;
 import org.apache.commons.lang3.SerializationUtils;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.controller.cluster.raft.messages.Payload;
@@ -19,33 +18,17 @@ import org.opendaylight.controller.cluster.raft.messages.Payload;
  *
  * @author Thomas Pantelis
  */
-// FIXME: do not implement MigratedSerializable once Proxy is gone
-public final class NoopPayload extends Payload implements ControlMessage, MigratedSerializable {
-    // There is no need for Externalizable
-    @Deprecated(since = "7.0.0", forRemoval = true)
-    private static final class Proxy implements Serializable {
-        @java.io.Serial
-        private static final long serialVersionUID = 1L;
-        private static final @NonNull NoopPayload INSTANCE = new NoopPayload(true);
-
-        @java.io.Serial
-        private Object readResolve() {
-            return INSTANCE;
-        }
-    }
-
+public final class NoopPayload extends Payload implements ControlMessage {
     @java.io.Serial
     private static final long serialVersionUID = 1L;
     private static final @NonNull NP PROXY = new NP();
     // Estimate to how big the proxy is. Note this includes object stream overhead, so it is a bit conservative
     private static final int PROXY_SIZE = SerializationUtils.serialize(PROXY).length;
 
-    public static final @NonNull NoopPayload INSTANCE = new NoopPayload(false);
-
-    private final boolean migrated;
+    public static final @NonNull NoopPayload INSTANCE = new NoopPayload();
 
-    private NoopPayload(final boolean migrated) {
-        this.migrated = migrated;
+    private NoopPayload() {
+        // Hidden on purpose
     }
 
     @Override
@@ -59,13 +42,7 @@ public final class NoopPayload extends Payload implements ControlMessage, Migrat
     }
 
     @Override
-    public boolean isMigrated() {
-        return migrated;
-    }
-
-    // FIXME: protected once not MigratedSerializable
-    @Override
-    public Object writeReplace() {
+    protected Object writeReplace() {
         return PROXY;
     }
 }
index c5bb3e2d4a98378898e058c369037647462ab20e..610d53a9e72efcb7bded805e79d7d6a4a5e1b63f 100644 (file)
@@ -9,10 +9,6 @@ package org.opendaylight.controller.cluster.raft.persisted;
 
 import static java.util.Objects.requireNonNull;
 
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
 import java.io.Serializable;
 import org.apache.commons.lang3.SerializationUtils;
 import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry;
@@ -23,53 +19,7 @@ import org.opendaylight.controller.cluster.raft.messages.Payload;
  *
  * @author Thomas Pantelis
  */
-public sealed class SimpleReplicatedLogEntry implements ReplicatedLogEntry, Serializable {
-    @Deprecated(since = "7.0.0", forRemoval = true)
-    private static final class Legacy extends SimpleReplicatedLogEntry implements LegacySerializable {
-        @java.io.Serial
-        private static final long serialVersionUID = 1L;
-
-        Legacy(final long index, final long term, final Payload payload) {
-            super(index, term, payload);
-        }
-    }
-
-    @Deprecated(since = "7.0.0", forRemoval = true)
-    private static final class Proxy implements Externalizable {
-        @java.io.Serial
-        private static final long serialVersionUID = 1L;
-
-        private long index;
-        private long term;
-        private Payload data;
-
-        // 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) throws IOException {
-            out.writeLong(index);
-            out.writeLong(term);
-            out.writeObject(data);
-        }
-
-        @Override
-        public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
-            index = in.readLong();
-            term = in.readLong();
-            data = (Payload) in.readObject();
-        }
-
-        @java.io.Serial
-        private Object readResolve() {
-            return new Legacy(index, term, data);
-        }
-    }
-
+public final class SimpleReplicatedLogEntry implements ReplicatedLogEntry, Serializable {
     @java.io.Serial
     private static final long serialVersionUID = 1L;
     // Estimate to how big the proxy is. Note this includes object stream overhead, so it is a bit conservative.
@@ -94,47 +44,42 @@ public sealed class SimpleReplicatedLogEntry implements ReplicatedLogEntry, Seri
     }
 
     @Override
-    public final Payload getData() {
+    public Payload getData() {
         return payload;
     }
 
     @Override
-    public final long getTerm() {
+    public long getTerm() {
         return term;
     }
 
     @Override
-    public final long getIndex() {
+    public long getIndex() {
         return index;
     }
 
     @Override
-    public final int size() {
+    public int size() {
         return payload.size();
     }
 
     @Override
-    public final int serializedSize() {
+    public int serializedSize() {
         return PROXY_SIZE + payload.serializedSize();
     }
 
     @Override
-    public final boolean isPersistencePending() {
+    public boolean isPersistencePending() {
         return persistencePending;
     }
 
     @Override
-    public final void setPersistencePending(final boolean pending) {
+    public void setPersistencePending(final boolean pending) {
         persistencePending = pending;
     }
 
-    @java.io.Serial
-    public final Object writeReplace() {
-        return new LE(this);
-    }
-
     @Override
-    public final int hashCode() {
+    public int hashCode() {
         final int prime = 31;
         int result = 1;
         result = prime * result + payload.hashCode();
@@ -144,13 +89,18 @@ public sealed class SimpleReplicatedLogEntry implements ReplicatedLogEntry, Seri
     }
 
     @Override
-    public final boolean equals(final Object obj) {
+    public boolean equals(final Object obj) {
         return this == obj || obj instanceof SimpleReplicatedLogEntry other && index == other.index
             && term == other.term && payload.equals(other.payload);
     }
 
     @Override
-    public final String toString() {
+    public String toString() {
         return "SimpleReplicatedLogEntry [index=" + index + ", term=" + term + ", payload=" + payload + "]";
     }
+
+    @java.io.Serial
+    private Object writeReplace() {
+        return new LE(this);
+    }
 }
index c3634e3fdf0b2102144f954669afce2a72054f98..81d2331bb4b6c9af4b700c9be2b1a2a37f8328da 100644 (file)
@@ -7,22 +7,16 @@
  */
 package org.opendaylight.controller.cluster.raft.persisted;
 
-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.List;
 import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry;
-import org.opendaylight.controller.cluster.raft.messages.Payload;
 
 /**
  * Represents a snapshot of the raft data.
  *
  * @author Thomas Pantelis
  */
-public sealed class Snapshot implements Serializable {
+public final class Snapshot implements Serializable {
     /**
      * Implementations of this interface are used as the state payload for a snapshot.
      *
@@ -40,82 +34,6 @@ public sealed class Snapshot implements Serializable {
         }
     }
 
-    @Deprecated(since = "7.0.0", forRemoval = true)
-    private static final class Legacy extends Snapshot implements LegacySerializable {
-        @java.io.Serial
-        private static final long serialVersionUID = 1L;
-
-        Legacy(final State state, final List<ReplicatedLogEntry> unAppliedEntries, final long lastIndex,
-                final long lastTerm, final long lastAppliedIndex, final long lastAppliedTerm, final long electionTerm,
-                final String electionVotedFor, final ServerConfigurationPayload serverConfig) {
-            super(state, unAppliedEntries, lastIndex, lastTerm, lastAppliedIndex, lastAppliedTerm, electionTerm,
-                electionVotedFor, serverConfig);
-        }
-    }
-
-    @Deprecated(since = "7.0.0", forRemoval = true)
-    private static final class Proxy implements Externalizable {
-        @java.io.Serial
-        private static final long serialVersionUID = 1L;
-
-        private Snapshot 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 void writeExternal(final ObjectOutput out) throws IOException {
-            out.writeLong(snapshot.lastIndex);
-            out.writeLong(snapshot.lastTerm);
-            out.writeLong(snapshot.lastAppliedIndex);
-            out.writeLong(snapshot.lastAppliedTerm);
-            out.writeLong(snapshot.electionTerm);
-            out.writeObject(snapshot.electionVotedFor);
-            out.writeObject(snapshot.serverConfig);
-
-            out.writeInt(snapshot.unAppliedEntries.size());
-            for (ReplicatedLogEntry e: snapshot.unAppliedEntries) {
-                out.writeLong(e.getIndex());
-                out.writeLong(e.getTerm());
-                out.writeObject(e.getData());
-            }
-
-            out.writeObject(snapshot.state);
-        }
-
-        @Override
-        public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
-            long lastIndex = in.readLong();
-            long lastTerm = in.readLong();
-            long lastAppliedIndex = in.readLong();
-            long lastAppliedTerm = in.readLong();
-            long electionTerm = in.readLong();
-            String electionVotedFor = (String) in.readObject();
-            ServerConfigurationPayload serverConfig = (ServerConfigurationPayload) in.readObject();
-
-            int size = in.readInt();
-            var unAppliedEntries = ImmutableList.<ReplicatedLogEntry>builderWithExpectedSize(size);
-            for (int i = 0; i < size; i++) {
-                unAppliedEntries.add(new SimpleReplicatedLogEntry(in.readLong(), in.readLong(),
-                        (Payload) in.readObject()));
-            }
-
-            State state = (State) in.readObject();
-
-            snapshot = new Legacy(state, unAppliedEntries.build(), lastIndex, lastTerm, lastAppliedIndex,
-                lastAppliedTerm, electionTerm, electionVotedFor, serverConfig);
-        }
-
-        @java.io.Serial
-        private Object readResolve() {
-            return snapshot;
-        }
-    }
-
     @java.io.Serial
     private static final long serialVersionUID = 1L;
 
@@ -129,7 +47,7 @@ public sealed class Snapshot implements Serializable {
     private final String electionVotedFor;
     private final ServerConfigurationPayload serverConfig;
 
-    Snapshot(final State state, final List<ReplicatedLogEntry> unAppliedEntries, final long lastIndex,
+    private Snapshot(final State state, final List<ReplicatedLogEntry> unAppliedEntries, final long lastIndex,
             final long lastTerm, final long lastAppliedIndex, final long lastAppliedTerm, final long electionTerm,
             final String electionVotedFor, final ServerConfigurationPayload serverConfig) {
         this.state = state;
@@ -186,16 +104,16 @@ public sealed class Snapshot implements Serializable {
         return serverConfig;
     }
 
-    @java.io.Serial
-    public final Object writeReplace() {
-        return new SS(this);
-    }
-
     @Override
-    public final String toString() {
+    public String toString() {
         return "Snapshot [lastIndex=" + lastIndex + ", lastTerm=" + lastTerm + ", lastAppliedIndex=" + lastAppliedIndex
                 + ", lastAppliedTerm=" + lastAppliedTerm + ", unAppliedEntries size=" + unAppliedEntries.size()
                 + ", state=" + state + ", electionTerm=" + electionTerm + ", electionVotedFor="
                 + electionVotedFor + ", ServerConfigPayload="  + serverConfig + "]";
     }
+
+    @java.io.Serial
+    private Object writeReplace() {
+        return new SS(this);
+    }
 }
index 99b3b61bad920221959079f2cb101093d071e3d9..3ef7acbea369c35f4fa365ac5736aa0b3f34df7f 100644 (file)
@@ -7,57 +7,12 @@
  */
 package org.opendaylight.controller.cluster.raft.persisted;
 
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
 import java.io.Serializable;
 
 /**
  * Message class to persist election term information.
  */
-public sealed class UpdateElectionTerm implements Serializable {
-    @Deprecated(since = "7.0.0", forRemoval = true)
-    private static final class Legacy extends UpdateElectionTerm implements LegacySerializable {
-        @java.io.Serial
-        private static final long serialVersionUID = 1L;
-
-        Legacy(final long currentTerm, final String votedFor) {
-            super(currentTerm, votedFor);
-        }
-    }
-
-    @Deprecated(since = "7.0.0", forRemoval = true)
-    private static final class Proxy implements Externalizable {
-        @java.io.Serial
-        private static final long serialVersionUID = 1L;
-
-        private UpdateElectionTerm updateElectionTerm = 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 void writeExternal(final ObjectOutput out) throws IOException {
-            out.writeLong(updateElectionTerm.currentTerm);
-            out.writeObject(updateElectionTerm.votedFor);
-        }
-
-        @Override
-        public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
-            updateElectionTerm = new Legacy(in.readLong(), (String) in.readObject());
-        }
-
-        @java.io.Serial
-        private Object readResolve() {
-            return updateElectionTerm;
-        }
-    }
-
+public final class UpdateElectionTerm implements Serializable {
     @java.io.Serial
     private static final long serialVersionUID = 1L;
 
@@ -69,22 +24,22 @@ public sealed class UpdateElectionTerm implements Serializable {
         this.votedFor = votedFor;
     }
 
-    public final long getCurrentTerm() {
+    public long getCurrentTerm() {
         return currentTerm;
     }
 
-    public final String getVotedFor() {
+    public String getVotedFor() {
         return votedFor;
     }
 
-    @java.io.Serial
-    public final Object writeReplace() {
-        return new UT(this);
-    }
-
     @Override
-    public final String toString() {
+    public String toString() {
         return "UpdateElectionTerm [currentTerm=" + currentTerm + ", votedFor=" + votedFor + "]";
     }
+
+    @java.io.Serial
+    private Object writeReplace() {
+        return new UT(this);
+    }
 }