Switch to ARGON raft version 14/103514/9
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 2 Dec 2022 08:10:07 +0000 (09:10 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 2 Dec 2022 11:44:39 +0000 (12:44 +0100)
We have new, more efficient serialization format. Switch to using it and
deprecate old proxies.

JIRA: CONTROLLER-2064
Change-Id: Ie549f08d62953ff6019ff915b12d0d4fedb1d3a0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
30 files changed:
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftVersions.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/EmptyExternalizableProxy.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/base/messages/TimeoutNow.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/FollowerIdentifier.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/client/messages/Shutdown.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/InstallSnapshotReply.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/RequestVote.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/messages/RequestVoteReply.java
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/LE.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
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/base/messages/TimeoutNowTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/FollowerIdentifierTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/client/messages/ShutdownTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/messages/AppendEntriesReplyTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/messages/AppendEntriesTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/messages/InstallSnapshotReplyTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/messages/InstallSnapshotTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/messages/RequestVoteReplyTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/messages/RequestVoteTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/persisted/ApplyJournalEntriesTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/persisted/DeleteEntriesTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/persisted/NoopPayloadTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/persisted/SimpleReplicatedLogEntryTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/persisted/SnapshotTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/persisted/UpdateElectionTermTest.java

index 646a57a3fe3792560f20440b1cfad780e86b6f38..1140e7449f92cf3a5193049e04879fd6bb7ebfc8 100644 (file)
@@ -21,7 +21,7 @@ public final class RaftVersions {
     public static final short BORON_VERSION = 3;
     public static final short FLUORINE_VERSION = 4;
     public static final short ARGON_VERSION = 5;
-    public static final short CURRENT_VERSION = FLUORINE_VERSION;
+    public static final short CURRENT_VERSION = ARGON_VERSION;
 
     private RaftVersions() {
 
index 67f3ed92aeeccdaaad5c407eb56304577d2fd4d0..96c25d56d37b34741123bc2195089f3d3f55c75e 100644 (file)
@@ -19,6 +19,7 @@ import java.io.ObjectOutput;
  *
  * @author Thomas Pantelis
  */
+@Deprecated(since = "7.0.0", forRemoval = true)
 public abstract class EmptyExternalizableProxy implements Externalizable {
     private static final long serialVersionUID = 1L;
 
index 780487b6ab714228d4d460cb3bd8f9f96f4ab58b..be3b0b5ffd135ba10747c36c1ce43427aeac4b65 100644 (file)
@@ -30,11 +30,7 @@ public final class TimeoutNow implements Serializable, ControlMessage {
         return INSTANCE;
     }
 
-    @java.io.Serial
-    private Object writeReplace() {
-        return new Proxy();
-    }
-
+    @Deprecated(since = "7.0.0", forRemoval = true)
     private static class Proxy extends EmptyExternalizableProxy {
         @java.io.Serial
         private static final long serialVersionUID = 1L;
index 32c6da4b527431d9e874000e6dd0acaff696a9d5..d961f84b0c73b1805427fd692798dd5f56afdeb1 100644 (file)
@@ -19,17 +19,21 @@ import org.opendaylight.yangtools.util.AbstractStringIdentifier;
  * @author Thomas Pantelis
  */
 class FollowerIdentifier extends AbstractStringIdentifier<FollowerIdentifier> {
+    @java.io.Serial
     private static final long serialVersionUID = 1L;
 
-    FollowerIdentifier(String followerId) {
+    FollowerIdentifier(final String followerId) {
         super(followerId);
     }
 
+    @java.io.Serial
     private Object writeReplace() {
-        return new Proxy(this);
+        return new FI(getValue());
     }
 
+    @Deprecated(since = "7.0.0", forRemoval = true)
     private static class Proxy implements Externalizable {
+        @java.io.Serial
         private static final long serialVersionUID = 1L;
 
         private FollowerIdentifier identifier;
@@ -40,20 +44,21 @@ class FollowerIdentifier extends AbstractStringIdentifier<FollowerIdentifier> {
         public Proxy() {
         }
 
-        Proxy(FollowerIdentifier identifier) {
+        Proxy(final FollowerIdentifier identifier) {
             this.identifier = identifier;
         }
 
         @Override
-        public void writeExternal(ObjectOutput out) throws IOException {
+        public void writeExternal(final ObjectOutput out) throws IOException {
             out.writeObject(identifier.getValue());
         }
 
         @Override
-        public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+        public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
             identifier = new FollowerIdentifier((String) in.readObject());
         }
 
+        @java.io.Serial
         private Object readResolve() {
             return identifier;
         }
index 29f291f5cf524b0eff88d67a0f7be50a67602abb..2f2ff47934ab0a4a85761c9f69fa90d98157fd7c 100644 (file)
@@ -33,11 +33,7 @@ public final class Shutdown implements Serializable, ControlMessage {
         return INSTANCE;
     }
 
-    @java.io.Serial
-    private Object writeReplace() {
-        return new Proxy();
-    }
-
+    @Deprecated(since = "7.0.0", forRemoval = true)
     private static class Proxy extends EmptyExternalizableProxy {
         @java.io.Serial
         private static final long serialVersionUID = 1L;
index 693fe7e7b8d5eb96d046eebb92e446ff9acf0b60..16cc900701b6c64fadbcfd9e057996eb4e134333 100644 (file)
@@ -50,10 +50,12 @@ public final class InstallSnapshotReply extends AbstractRaftRPC {
 
     @Override
     Object writeReplace() {
-        return new Proxy(this);
+        return new IR(this);
     }
 
+    @Deprecated(since = "7.0.0", forRemoval = true)
     private static class Proxy implements Externalizable {
+        @java.io.Serial
         private static final long serialVersionUID = 1L;
 
         private InstallSnapshotReply installSnapshotReply;
@@ -86,6 +88,7 @@ public final class InstallSnapshotReply extends AbstractRaftRPC {
             installSnapshotReply = new InstallSnapshotReply(term, followerId, chunkIndex, success);
         }
 
+        @java.io.Serial
         private Object readResolve() {
             return installSnapshotReply;
         }
index b23c76d06f9213d516f0f2a7345f85034c157333..72d1496951ef79aed8d7fba07fb963a8813793cd 100644 (file)
@@ -57,10 +57,12 @@ public final class RequestVote extends AbstractRaftRPC {
 
     @Override
     Object writeReplace() {
-        return new Proxy(this);
+        return new RV(this);
     }
 
+    @Deprecated(since = "7.0.0", forRemoval = true)
     private static class Proxy implements Externalizable {
+        @java.io.Serial
         private static final long serialVersionUID = 1L;
 
         private RequestVote requestVote;
@@ -93,6 +95,7 @@ public final class RequestVote extends AbstractRaftRPC {
             requestVote = new RequestVote(term, candidateId, lastLogIndex, lastLogTerm);
         }
 
+        @java.io.Serial
         private Object readResolve() {
             return requestVote;
         }
index 2554c17fd85fd1c7dcfc04c824079c1510ed98ee..7bfb7b68f0e07dda69f809666eb0f28ffc86875c 100644 (file)
@@ -34,10 +34,12 @@ public final class RequestVoteReply extends AbstractRaftRPC {
 
     @Override
     Object writeReplace() {
-        return new Proxy(this);
+        return new VR(this);
     }
 
+    @Deprecated(since = "7.0.0", forRemoval = true)
     private static class Proxy implements Externalizable {
+        @java.io.Serial
         private static final long serialVersionUID = 1L;
 
         private RequestVoteReply requestVoteReply;
@@ -66,6 +68,7 @@ public final class RequestVoteReply extends AbstractRaftRPC {
             requestVoteReply = new RequestVoteReply(term, voteGranted);
         }
 
+        @java.io.Serial
         private Object readResolve() {
             return requestVoteReply;
         }
index 3c0a8ac700c7de8e4e1fd156eb07ffbf0761d614..ad334f4c156ad0dc43aaf4eb69cf0e3184e4a039 100644 (file)
@@ -23,7 +23,9 @@ import java.io.Serializable;
  * @author Thomas Pantelis
  */
 public class ApplyJournalEntries implements Serializable, ControlMessage {
+    @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;
@@ -49,11 +51,13 @@ public class ApplyJournalEntries implements Serializable, ControlMessage {
             applyEntries = new ApplyJournalEntries(in.readLong());
         }
 
+        @java.io.Serial
         private Object readResolve() {
             return applyEntries;
         }
     }
 
+    @java.io.Serial
     private static final long serialVersionUID = 1L;
 
     private final long toIndex;
@@ -67,7 +71,7 @@ public class ApplyJournalEntries implements Serializable, ControlMessage {
     }
 
     private Object writeReplace() {
-        return new Proxy(this);
+        return new AJE(this);
     }
 
     @Override
index 57f5af3a034e90d31f716eea1da38626832f593f..b4b45465047420198b22ee0c1b0ab74fb9a18a7f 100644 (file)
@@ -19,7 +19,9 @@ import java.io.Serializable;
  * @author Thomas Pantelis
  */
 public class DeleteEntries implements Serializable {
+    @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;
@@ -45,11 +47,13 @@ public class DeleteEntries implements Serializable {
             deleteEntries = new DeleteEntries(in.readLong());
         }
 
+        @java.io.Serial
         private Object readResolve() {
             return deleteEntries;
         }
     }
 
+    @java.io.Serial
     private static final long serialVersionUID = 1L;
 
     private final long fromIndex;
@@ -63,7 +67,7 @@ public class DeleteEntries implements Serializable {
     }
 
     private Object writeReplace() {
-        return new Proxy(this);
+        return new DE(this);
     }
 
     @Override
index 950cdc589b9fd2ba04291ab796199fe9d1f71e93..7e609ab35c8310e71e125e5366d3c28d722e8c66 100644 (file)
@@ -30,6 +30,13 @@ final class LE implements Externalizable {
         // For Externalizable
     }
 
+    // For size estimation only, use full bit size
+    LE(final Void dummy) {
+        index = Long.MIN_VALUE;
+        term = Long.MIN_VALUE;
+        data = null;
+    }
+
     LE(final SimpleReplicatedLogEntry logEntry) {
         index = logEntry.getIndex();
         term = logEntry.getTerm();
index e190bf0919828714047ddbab275858acf5bb6ad3..1fa865948a3b3fcad6f0efa0d2bf9c30acf17a89 100644 (file)
@@ -22,16 +22,20 @@ public final class NoopPayload extends Payload implements ControlMessage {
     public static final NoopPayload INSTANCE = new NoopPayload();
 
     // 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;
 
+        @java.io.Serial
         private Object readResolve() {
             return INSTANCE;
         }
     }
 
+    @java.io.Serial
     private static final long serialVersionUID = 1L;
-    private static final Proxy PROXY = new Proxy();
+    private static final 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;
 
index 56a81f57f366bfc75874fc53e2d360019c994ecc..56c3f769ff18306f746496c48f387409697ecf10 100644 (file)
@@ -24,7 +24,9 @@ import org.opendaylight.controller.cluster.raft.messages.Payload;
  * @author Thomas Pantelis
  */
 public final class SimpleReplicatedLogEntry implements ReplicatedLogEntry, Serializable {
+    @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;
@@ -58,14 +60,16 @@ public final class SimpleReplicatedLogEntry implements ReplicatedLogEntry, Seria
             data = (Payload) in.readObject();
         }
 
+        @java.io.Serial
         private Object readResolve() {
             return new SimpleReplicatedLogEntry(index, term, data);
         }
     }
 
+    @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
-    private static final int PROXY_SIZE = SerializationUtils.serialize(new Proxy()).length;
+    // 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(new LE((Void) null)).length;
 
     private final long index;
     private final long term;
@@ -121,7 +125,7 @@ public final class SimpleReplicatedLogEntry implements ReplicatedLogEntry, Seria
     }
 
     private Object writeReplace() {
-        return new Proxy(this);
+        return new LE(this);
     }
 
     @Override
@@ -139,12 +143,11 @@ public final class SimpleReplicatedLogEntry implements ReplicatedLogEntry, Seria
         if (this == obj) {
             return true;
         }
-
         if (obj == null || getClass() != obj.getClass()) {
             return false;
         }
 
-        SimpleReplicatedLogEntry other = (SimpleReplicatedLogEntry) obj;
+        var other = (SimpleReplicatedLogEntry) obj;
         return index == other.index && term == other.term && payload.equals(other.payload);
     }
 
index 5f8a55f9efaf36f950722ce667e001d19ea50565..9812ac69d5c2be4194460c253f0316537cdb4c25 100644 (file)
@@ -42,7 +42,9 @@ public class Snapshot implements Serializable {
         }
     }
 
+    @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;
@@ -101,11 +103,13 @@ public class Snapshot implements Serializable {
                     electionTerm, electionVotedFor, serverConfig);
         }
 
+        @java.io.Serial
         private Object readResolve() {
             return snapshot;
         }
     }
 
+    @java.io.Serial
     private static final long serialVersionUID = 1L;
 
     private final State state;
@@ -160,7 +164,7 @@ public class Snapshot implements Serializable {
     }
 
     public long getLastIndex() {
-        return this.lastIndex;
+        return lastIndex;
     }
 
     public long getElectionTerm() {
@@ -175,8 +179,9 @@ public class Snapshot implements Serializable {
         return serverConfig;
     }
 
+    @java.io.Serial
     private Object writeReplace() {
-        return new Proxy(this);
+        return new SS(this);
     }
 
     @Override
index 939d893a2ec505538f918a1f30ad5c927c56666a..419aec0e321a678a04469f26cb38442bca2fe9c9 100644 (file)
@@ -17,7 +17,9 @@ import java.io.Serializable;
  * Message class to persist election term information.
  */
 public class UpdateElectionTerm implements Serializable {
+    @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;
@@ -44,11 +46,13 @@ public class UpdateElectionTerm implements Serializable {
             updateElectionTerm = new UpdateElectionTerm(in.readLong(), (String) in.readObject());
         }
 
+        @java.io.Serial
         private Object readResolve() {
             return updateElectionTerm;
         }
     }
 
+    @java.io.Serial
     private static final long serialVersionUID = 1L;
 
     private final long currentTerm;
@@ -67,8 +71,9 @@ public class UpdateElectionTerm implements Serializable {
         return votedFor;
     }
 
+    @java.io.Serial
     private Object writeReplace() {
-        return new Proxy(this);
+        return new UT(this);
     }
 
     @Override
index 375990e10609a3ee87c668463de55cf50085def1..eed7e94049cb2ff5831d6d9b63f1eee4f48d2fde 100644 (file)
@@ -22,7 +22,7 @@ public class TimeoutNowTest {
     @Test
     public void test() {
         final var bytes = SerializationUtils.serialize(TimeoutNow.INSTANCE);
-        assertEquals(187, bytes.length);
+        assertEquals(86, bytes.length);
         final var cloned = SerializationUtils.deserialize(bytes);
         assertSame("Cloned instance", TimeoutNow.INSTANCE, cloned);
     }
index e0b7d61f0e4ce3ecb79c19c239591c18aa7a1d6a..832e80fe88e960eaade2501d8b94c5bbfdc39682 100644 (file)
@@ -22,7 +22,7 @@ public class FollowerIdentifierTest {
     public void testSerialization() {
         final var expected = new FollowerIdentifier("follower1");
         final var bytes = SerializationUtils.serialize(expected);
-        assertEquals(109, bytes.length);
+        assertEquals(87, bytes.length);
         final var cloned = (FollowerIdentifier) SerializationUtils.deserialize(bytes);
         assertEquals("cloned", expected, cloned);
     }
index ea3bd7e4724c18038e551f180adeedee805d50c4..a4a8cf9d399741de7559af0e809fe8f37c0aba79 100644 (file)
@@ -22,7 +22,7 @@ public class ShutdownTest {
     @Test
     public void test() {
         final var bytes = SerializationUtils.serialize(Shutdown.INSTANCE);
-        assertEquals(187, bytes.length);
+        assertEquals(86, bytes.length);
         final var cloned = SerializationUtils.deserialize(bytes);
         assertSame("Cloned instance", Shutdown.INSTANCE, cloned);
     }
index 8c09729e101ee8ccbf4634b645ae89add3e0408b..4d90d789779ab997d7e6bf4dbd0faa061b8941c2 100644 (file)
@@ -25,7 +25,7 @@ public class AppendEntriesReplyTest {
             RaftVersions.CURRENT_VERSION);
 
         final var bytes = SerializationUtils.serialize(expected);
-        assertEquals(143, bytes.length);
+        assertEquals(98, bytes.length);
         final var cloned = (AppendEntriesReply) SerializationUtils.deserialize(bytes);
 
         assertEquals("getTerm", expected.getTerm(), cloned.getTerm());
index b061a2ca5431707dbeda9c9c46eb1a4ca287e83e..31f8b9a5d32cbcd425fd6fe08d86e6a55d5a8d8c 100644 (file)
@@ -39,7 +39,7 @@ public class AppendEntriesTest {
             RaftVersions.CURRENT_VERSION, null);
 
         var bytes = SerializationUtils.serialize(expected);
-        assertEquals(355, bytes.length);
+        assertEquals(285, bytes.length);
         var cloned = (AppendEntries) SerializationUtils.deserialize(bytes);
 
         verifyAppendEntries(expected, cloned, RaftVersions.CURRENT_VERSION);
@@ -50,7 +50,7 @@ public class AppendEntriesTest {
             RaftVersions.CURRENT_VERSION, "leader address");
 
         bytes = SerializationUtils.serialize(expected);
-        assertEquals(371, bytes.length);
+        assertEquals(301, bytes.length);
         cloned = (AppendEntries) SerializationUtils.deserialize(bytes);
 
         verifyAppendEntries(expected, cloned, RaftVersions.CURRENT_VERSION);
index 7ea8fb72000fe5c2d4536e11b8fd01a536d2d627..0d74f7df18205753777b5a25703822a34d1b7524 100644 (file)
@@ -22,7 +22,7 @@ public class InstallSnapshotReplyTest {
     public void testSerialization() {
         final var expected = new InstallSnapshotReply(5L, "follower", 1, true);
         final var bytes = SerializationUtils.serialize(expected);
-        assertEquals(126, bytes.length);
+        assertEquals(95, bytes.length);
         final var cloned = (InstallSnapshotReply) SerializationUtils.deserialize(bytes);
 
         assertEquals("getTerm", expected.getTerm(), cloned.getTerm());
index a3da9594169af01290664a255e18d8d9e5fbd385..c6f080eb229a5d0f20ac31d26f8df949abaf5457 100644 (file)
@@ -26,7 +26,16 @@ import org.opendaylight.controller.cluster.raft.persisted.ServerInfo;
  */
 public class InstallSnapshotTest {
     @Test
-    public void testSerialization() {
+    public void testCurrentSerialization() {
+        testSerialization(RaftVersions.CURRENT_VERSION, 1262, 1125);
+    }
+
+    @Test
+    public void testFluorineSerialization() {
+        testSerialization(RaftVersions.FLUORINE_VERSION, 1302, 1165);
+    }
+
+    private static void testSerialization(final short raftVersion, final int fullSize, final int emptySize) {
         byte[] data = new byte[1000];
         for (int i = 0, j = 0; i < data.length; i++) {
             data[i] = (byte)j;
@@ -35,13 +44,13 @@ public class InstallSnapshotTest {
             }
         }
 
-        ServerConfigurationPayload serverConfig = new ServerConfigurationPayload(List.of(
+        var serverConfig = new ServerConfigurationPayload(List.of(
                 new ServerInfo("leader", true), new ServerInfo("follower", false)));
-        assertInstallSnapshot(1302, new InstallSnapshot(3L, "leaderId", 11L, 2L, data, 5, 6, OptionalInt.of(54321),
-            Optional.of(serverConfig), RaftVersions.CURRENT_VERSION));
+        assertInstallSnapshot(fullSize, new InstallSnapshot(3L, "leaderId", 11L, 2L, data, 5, 6, OptionalInt.of(54321),
+            Optional.of(serverConfig), raftVersion));
 
-        assertInstallSnapshot(1165, new InstallSnapshot(3L, "leaderId", 11L, 2L, data, 5, 6, OptionalInt.empty(),
-            Optional.empty(), RaftVersions.CURRENT_VERSION));
+        assertInstallSnapshot(emptySize, new InstallSnapshot(3L, "leaderId", 11L, 2L, data, 5, 6, OptionalInt.empty(),
+            Optional.empty(), raftVersion));
     }
 
     private static void assertInstallSnapshot(final int expectedSize, final InstallSnapshot expected) {
index 440c35f100b59c797a491ca196727cc10fdeff22..d3d469ff515ef2009ee196918a0b8a7941bf0693 100644 (file)
@@ -22,7 +22,7 @@ public class RequestVoteReplyTest {
     public void testSerialization() {
         final var expected = new RequestVoteReply(5, true);
         final var bytes = SerializationUtils.serialize(expected);
-        assertEquals(105, bytes.length);
+        assertEquals(78, bytes.length);
         final var cloned = (RequestVoteReply) SerializationUtils.deserialize(bytes);
 
         assertEquals("getTerm", expected.getTerm(), cloned.getTerm());
index e710685056cc64a377f7873cd16bb14f43f6cd6c..6c684eef6b9dcebc5a7b71bb2d26a5ae5e2e9a73 100644 (file)
@@ -22,7 +22,7 @@ public class RequestVoteTest {
     public void testSerialization() {
         final var expected = new RequestVote(4, "candidateId", 3, 2);
         final var bytes = SerializationUtils.serialize(expected);
-        assertEquals(131, bytes.length);
+        assertEquals(97, bytes.length);
         final var cloned = (RequestVote) SerializationUtils.deserialize(bytes);
 
         assertEquals("getTerm", expected.getTerm(), cloned.getTerm());
index 2d9e7e3391a1098b8bfb38ae05cc57972ad52129..475de8d61847e286fdd0f4ca0874dd105f8b8841 100644 (file)
@@ -22,7 +22,7 @@ public class ApplyJournalEntriesTest {
     public void testSerialization() {
         final var expected = new ApplyJournalEntries(5);
         final var bytes = SerializationUtils.serialize(expected);
-        assertEquals(108, bytes.length);
+        assertEquals(80, bytes.length);
         final var cloned = (ApplyJournalEntries) SerializationUtils.deserialize(bytes);
 
         assertEquals("getFromIndex", expected.getToIndex(), cloned.getToIndex());
index 3254c899e61b8f7cacaa36c83ce4b0e6d42e6bd4..e7b4fcce4db5417c632d6e5d2fa66e25d4462afd 100644 (file)
@@ -22,7 +22,7 @@ public class DeleteEntriesTest {
     public void testSerialization() {
         final var expected = new DeleteEntries(5);
         final var bytes = SerializationUtils.serialize(expected);
-        assertEquals(102, bytes.length);
+        assertEquals(79, bytes.length);
         final var cloned = (DeleteEntries) SerializationUtils.deserialize(bytes);
 
         assertEquals("getFromIndex", expected.getFromIndex(), cloned.getFromIndex());
index cfeafbb1738a30c7784ce763cd2bab5e0f3da50d..bf2e8fa108f68ca86ab644c5cca0145a68191711 100644 (file)
@@ -17,7 +17,7 @@ public class NoopPayloadTest {
     @Test
     public void testSerialization() {
         final var bytes = SerializationUtils.serialize(NoopPayload.INSTANCE);
-        assertEquals(89, bytes.length);
+        assertEquals(74, bytes.length);
         assertSame(NoopPayload.INSTANCE, SerializationUtils.deserialize(bytes));
     }
 }
index 9c0e8907dcbb82e5523d0582ae9ed8453372e59c..6c01fcd848f262f57c96d22287fe6e5eb7da2af0 100644 (file)
@@ -23,7 +23,7 @@ public class SimpleReplicatedLogEntryTest {
     public void testSerialization() {
         final var expected = new SimpleReplicatedLogEntry(0, 1, new MockRaftActorContext.MockPayload("A"));
         final var bytes = SerializationUtils.serialize(expected);
-        assertEquals(260, bytes.length);
+        assertEquals(218, bytes.length);
         final var cloned = (SimpleReplicatedLogEntry) SerializationUtils.deserialize(bytes);
 
         assertEquals("getTerm", expected.getTerm(), cloned.getTerm());
index 55d9d47376ddf4ad9cf0fa6319713d50d640a0eb..99fa883afc6474e96373d8991a9265f6ee9c1113 100644 (file)
@@ -24,8 +24,8 @@ public class SnapshotTest {
     @Test
     public void testSerialization() {
         testSerialization(new byte[]{1, 2, 3, 4, 5, 6, 7}, List.of(
-                new SimpleReplicatedLogEntry(6, 2, new MockPayload("payload"))), 548);
-        testSerialization(new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9}, List.of(), 389);
+                new SimpleReplicatedLogEntry(6, 2, new MockPayload("payload"))), 491);
+        testSerialization(new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9}, List.of(), 345);
     }
 
     private static void testSerialization(final byte[] state, final List<ReplicatedLogEntry> unapplied,
index f783c64be79196cb83bdd687eee06b6696202ff4..cc6ba2d6c61dbb770d6dbeb51d1e3efc34763eec 100644 (file)
@@ -22,7 +22,7 @@ public class UpdateElectionTermTest {
     public void testSerialization() {
         final var expected = new UpdateElectionTerm(5, "leader");
         final var bytes = SerializationUtils.serialize(expected);
-        assertEquals(116, bytes.length);
+        assertEquals(88, bytes.length);
         final var cloned = (UpdateElectionTerm) SerializationUtils.deserialize(bytes);
 
         assertEquals("getCurrentTerm", expected.getCurrentTerm(), cloned.getCurrentTerm());