Remove MockReplicatedLogEntry 08/48808/3
authorTom Pantelis <tpanteli@brocade.com>
Tue, 29 Nov 2016 20:21:03 +0000 (15:21 -0500)
committerTom Pantelis <tpanteli@brocade.com>
Thu, 1 Dec 2016 13:06:34 +0000 (13:06 +0000)
This class now just inherits from SimpleReplicatedLogEntry so in no
longer needed. Changed all users to SimpleReplicatedLogEntry. The only
difference is that the term and index params are flipped in the ctors.

Change-Id: I0b32078eeb9ea45001dcd8e8aa30bfe548256e96
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
13 files changed:
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/persisted/SimpleReplicatedLogEntry.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractReplicatedLogImplTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/MockRaftActorContext.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorRecoverySupportTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorServerConfigurationSupportTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/ReplicatedLogImplTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/SnapshotManagerTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractRaftActorBehaviorTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/CandidateTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/FollowerTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/LeaderTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/PartitionedCandidateOnStartupElectionScenarioTest.java

index 3dc5a28..5edd2ed 100644 (file)
@@ -21,7 +21,7 @@ import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payloa
  *
  * @author Thomas Pantelis
  */
-public class SimpleReplicatedLogEntry implements ReplicatedLogEntry, MigratedSerializable {
+public final class SimpleReplicatedLogEntry implements ReplicatedLogEntry, MigratedSerializable {
     private static final class Proxy implements Externalizable {
         private static final long serialVersionUID = 1L;
 
index bf0eda6..a37a131 100644 (file)
@@ -21,7 +21,7 @@ import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.raft.MockRaftActorContext.MockPayload;
-import org.opendaylight.controller.cluster.raft.MockRaftActorContext.MockReplicatedLogEntry;
+import org.opendaylight.controller.cluster.raft.persisted.SimpleReplicatedLogEntry;
 
 /**
 * Unit tests for AbstractReplicatedLogImplTest.
@@ -34,10 +34,10 @@ public class AbstractReplicatedLogImplTest {
     public void setUp() {
         replicatedLogImpl = new MockAbstractReplicatedLogImpl();
         // create a set of initial entries in the in-memory log
-        replicatedLogImpl.append(new MockReplicatedLogEntry(1, 0, new MockPayload("A")));
-        replicatedLogImpl.append(new MockReplicatedLogEntry(1, 1, new MockPayload("B")));
-        replicatedLogImpl.append(new MockReplicatedLogEntry(1, 2, new MockPayload("C")));
-        replicatedLogImpl.append(new MockReplicatedLogEntry(2, 3, new MockPayload("D")));
+        replicatedLogImpl.append(new SimpleReplicatedLogEntry(0, 1, new MockPayload("A")));
+        replicatedLogImpl.append(new SimpleReplicatedLogEntry(1, 1, new MockPayload("B")));
+        replicatedLogImpl.append(new SimpleReplicatedLogEntry(2, 1, new MockPayload("C")));
+        replicatedLogImpl.append(new SimpleReplicatedLogEntry(3, 2, new MockPayload("D")));
 
     }
 
@@ -105,10 +105,10 @@ public class AbstractReplicatedLogImplTest {
         assertTrue(replicatedLogImpl.isInSnapshot(2));
 
         // append few more entries
-        replicatedLogImpl.append(new MockReplicatedLogEntry(2, 4, new MockPayload("E")));
-        replicatedLogImpl.append(new MockReplicatedLogEntry(2, 5, new MockPayload("F")));
-        replicatedLogImpl.append(new MockReplicatedLogEntry(3, 6, new MockPayload("G")));
-        replicatedLogImpl.append(new MockReplicatedLogEntry(3, 7, new MockPayload("H")));
+        replicatedLogImpl.append(new SimpleReplicatedLogEntry(4, 2, new MockPayload("E")));
+        replicatedLogImpl.append(new SimpleReplicatedLogEntry(5, 2, new MockPayload("F")));
+        replicatedLogImpl.append(new SimpleReplicatedLogEntry(6, 3, new MockPayload("G")));
+        replicatedLogImpl.append(new SimpleReplicatedLogEntry(7, 3, new MockPayload("H")));
 
         // check their values as well
         assertEquals(5, replicatedLogImpl.size());
@@ -168,7 +168,7 @@ public class AbstractReplicatedLogImplTest {
         Assert.assertEquals("B", from.get(0).getData().toString());
         Assert.assertEquals("C", from.get(1).getData().toString());
 
-        replicatedLogImpl.append(new MockReplicatedLogEntry(2, 4, new MockPayload("12345")));
+        replicatedLogImpl.append(new SimpleReplicatedLogEntry(4, 2, new MockPayload("12345")));
         from = replicatedLogImpl.getFrom(4, 2, 2);
         Assert.assertEquals(1, from.size());
         Assert.assertEquals("12345", from.get(0).getData().toString());
@@ -177,10 +177,10 @@ public class AbstractReplicatedLogImplTest {
     @Test
     public void testSnapshotPreCommit() {
         //add 4 more entries
-        replicatedLogImpl.append(new MockReplicatedLogEntry(2, 4, new MockPayload("E")));
-        replicatedLogImpl.append(new MockReplicatedLogEntry(2, 5, new MockPayload("F")));
-        replicatedLogImpl.append(new MockReplicatedLogEntry(3, 6, new MockPayload("G")));
-        replicatedLogImpl.append(new MockReplicatedLogEntry(3, 7, new MockPayload("H")));
+        replicatedLogImpl.append(new SimpleReplicatedLogEntry(4, 2, new MockPayload("E")));
+        replicatedLogImpl.append(new SimpleReplicatedLogEntry(5, 2, new MockPayload("F")));
+        replicatedLogImpl.append(new SimpleReplicatedLogEntry(6, 3, new MockPayload("G")));
+        replicatedLogImpl.append(new SimpleReplicatedLogEntry(7, 3, new MockPayload("H")));
 
         //sending negative values should not cause any changes
         replicatedLogImpl.snapshotPreCommit(-1, -1);
@@ -256,7 +256,7 @@ public class AbstractReplicatedLogImplTest {
         assertTrue(replicatedLogImpl.isPresent(2));
         assertTrue(replicatedLogImpl.isPresent(3));
 
-        replicatedLogImpl.append(new MockReplicatedLogEntry(2, 4, new MockPayload("D")));
+        replicatedLogImpl.append(new SimpleReplicatedLogEntry(4, 2, new MockPayload("D")));
         replicatedLogImpl.snapshotPreCommit(3, 2); //snapshot on 3
         replicatedLogImpl.snapshotCommit();
 
@@ -270,15 +270,15 @@ public class AbstractReplicatedLogImplTest {
         replicatedLogImpl.snapshotCommit();
         assertFalse(replicatedLogImpl.isPresent(4));
 
-        replicatedLogImpl.append(new MockReplicatedLogEntry(2, 5, new MockPayload("D")));
+        replicatedLogImpl.append(new SimpleReplicatedLogEntry(5, 2, new MockPayload("D")));
         assertTrue(replicatedLogImpl.isPresent(5));
     }
 
     @Test
     public void testRemoveFrom() {
 
-        replicatedLogImpl.append(new MockReplicatedLogEntry(2, 4, new MockPayload("E", 2)));
-        replicatedLogImpl.append(new MockReplicatedLogEntry(2, 5, new MockPayload("F", 3)));
+        replicatedLogImpl.append(new SimpleReplicatedLogEntry(4, 2, new MockPayload("E", 2)));
+        replicatedLogImpl.append(new SimpleReplicatedLogEntry(5, 2, new MockPayload("F", 3)));
 
         assertEquals("dataSize", 9, replicatedLogImpl.dataSize());
 
index 0bb2e8a..65f0a62 100644 (file)
@@ -79,8 +79,8 @@ public class MockRaftActorContext extends RaftActorContextImpl {
     public void initReplicatedLog() {
         SimpleReplicatedLog replicatedLog = new SimpleReplicatedLog();
         long term = getTermInformation().getCurrentTerm();
-        replicatedLog.append(new MockReplicatedLogEntry(term, 0, new MockPayload("1")));
-        replicatedLog.append(new MockReplicatedLogEntry(term, 1, new MockPayload("2")));
+        replicatedLog.append(new SimpleReplicatedLogEntry(0, term, new MockPayload("1")));
+        replicatedLog.append(new SimpleReplicatedLogEntry(1, term, new MockPayload("2")));
         setReplicatedLog(replicatedLog);
         setCommitIndex(replicatedLog.lastIndex());
         setLastApplied(replicatedLog.lastIndex());
@@ -224,15 +224,6 @@ public class MockRaftActorContext extends RaftActorContextImpl {
         }
     }
 
-    // TODO - this class can be removed and use ReplicatedLogImplEntry directly.
-    public static class MockReplicatedLogEntry extends SimpleReplicatedLogEntry {
-        private static final long serialVersionUID = 1L;
-
-        public MockReplicatedLogEntry(long term, long index, Payload data) {
-            super(index, term, data);
-        }
-    }
-
     public static class MockReplicatedLogBuilder {
         private final ReplicatedLog mockLog = new SimpleReplicatedLog();
 
index 6d5e7e7..9c42101 100644 (file)
@@ -40,6 +40,7 @@ import org.opendaylight.controller.cluster.raft.persisted.ApplyJournalEntries;
 import org.opendaylight.controller.cluster.raft.persisted.DeleteEntries;
 import org.opendaylight.controller.cluster.raft.persisted.ServerConfigurationPayload;
 import org.opendaylight.controller.cluster.raft.persisted.ServerInfo;
+import org.opendaylight.controller.cluster.raft.persisted.SimpleReplicatedLogEntry;
 import org.opendaylight.controller.cluster.raft.persisted.UpdateElectionTerm;
 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
 import org.slf4j.Logger;
@@ -96,8 +97,7 @@ public class RaftActorRecoverySupportTest {
 
     @Test
     public void testOnReplicatedLogEntry() {
-        MockRaftActorContext.MockReplicatedLogEntry logEntry = new MockRaftActorContext.MockReplicatedLogEntry(1,
-                1, new MockRaftActorContext.MockPayload("1", 5));
+        ReplicatedLogEntry logEntry = new SimpleReplicatedLogEntry(1, 1, new MockRaftActorContext.MockPayload("1", 5));
 
         sendMessageToSupport(logEntry);
 
@@ -115,18 +115,12 @@ public class RaftActorRecoverySupportTest {
         configParams.setJournalRecoveryLogBatchSize(5);
 
         ReplicatedLog replicatedLog = context.getReplicatedLog();
-        replicatedLog.append(new MockRaftActorContext.MockReplicatedLogEntry(1,
-                0, new MockRaftActorContext.MockPayload("0")));
-        replicatedLog.append(new MockRaftActorContext.MockReplicatedLogEntry(1,
-                1, new MockRaftActorContext.MockPayload("1")));
-        replicatedLog.append(new MockRaftActorContext.MockReplicatedLogEntry(1,
-                2, new MockRaftActorContext.MockPayload("2")));
-        replicatedLog.append(new MockRaftActorContext.MockReplicatedLogEntry(1,
-                3, new MockRaftActorContext.MockPayload("3")));
-        replicatedLog.append(new MockRaftActorContext.MockReplicatedLogEntry(1,
-                4, new MockRaftActorContext.MockPayload("4")));
-        replicatedLog.append(new MockRaftActorContext.MockReplicatedLogEntry(1,
-                5, new MockRaftActorContext.MockPayload("5")));
+        replicatedLog.append(new SimpleReplicatedLogEntry(0, 1, new MockRaftActorContext.MockPayload("0")));
+        replicatedLog.append(new SimpleReplicatedLogEntry(1, 1, new MockRaftActorContext.MockPayload("1")));
+        replicatedLog.append(new SimpleReplicatedLogEntry(2, 1, new MockRaftActorContext.MockPayload("2")));
+        replicatedLog.append(new SimpleReplicatedLogEntry(3, 1, new MockRaftActorContext.MockPayload("3")));
+        replicatedLog.append(new SimpleReplicatedLogEntry(4, 1, new MockRaftActorContext.MockPayload("4")));
+        replicatedLog.append(new SimpleReplicatedLogEntry(5, 1, new MockRaftActorContext.MockPayload("5")));
 
         sendMessageToSupport(new ApplyJournalEntries(2));
 
@@ -164,20 +158,17 @@ public class RaftActorRecoverySupportTest {
     public void testOnSnapshotOffer() {
 
         ReplicatedLog replicatedLog = context.getReplicatedLog();
-        replicatedLog.append(new MockRaftActorContext.MockReplicatedLogEntry(1,
-                1, new MockRaftActorContext.MockPayload("1")));
-        replicatedLog.append(new MockRaftActorContext.MockReplicatedLogEntry(1,
-                2, new MockRaftActorContext.MockPayload("2")));
-        replicatedLog.append(new MockRaftActorContext.MockReplicatedLogEntry(1,
-                3, new MockRaftActorContext.MockPayload("3")));
+        replicatedLog.append(new SimpleReplicatedLogEntry(1, 1, new MockRaftActorContext.MockPayload("1")));
+        replicatedLog.append(new SimpleReplicatedLogEntry(2, 1, new MockRaftActorContext.MockPayload("2")));
+        replicatedLog.append(new SimpleReplicatedLogEntry(3, 1, new MockRaftActorContext.MockPayload("3")));
 
         byte[] snapshotBytes = {1,2,3,4,5};
 
-        ReplicatedLogEntry unAppliedEntry1 = new MockRaftActorContext.MockReplicatedLogEntry(1,
-                4, new MockRaftActorContext.MockPayload("4", 4));
+        ReplicatedLogEntry unAppliedEntry1 = new SimpleReplicatedLogEntry(4, 1,
+                new MockRaftActorContext.MockPayload("4", 4));
 
-        ReplicatedLogEntry unAppliedEntry2 = new MockRaftActorContext.MockReplicatedLogEntry(1,
-                5, new MockRaftActorContext.MockPayload("5", 5));
+        ReplicatedLogEntry unAppliedEntry2 = new SimpleReplicatedLogEntry(5, 1,
+                new MockRaftActorContext.MockPayload("5", 5));
 
         long lastAppliedDuringSnapshotCapture = 3;
         long lastIndexDuringSnapshotCapture = 5;
@@ -209,10 +200,8 @@ public class RaftActorRecoverySupportTest {
     @Test
     public void testOnRecoveryCompletedWithRemainingBatch() {
         ReplicatedLog replicatedLog = context.getReplicatedLog();
-        replicatedLog.append(new MockRaftActorContext.MockReplicatedLogEntry(1,
-                0, new MockRaftActorContext.MockPayload("0")));
-        replicatedLog.append(new MockRaftActorContext.MockReplicatedLogEntry(1,
-                1, new MockRaftActorContext.MockPayload("1")));
+        replicatedLog.append(new SimpleReplicatedLogEntry(0, 1, new MockRaftActorContext.MockPayload("0")));
+        replicatedLog.append(new SimpleReplicatedLogEntry(1, 1, new MockRaftActorContext.MockPayload("1")));
 
         sendMessageToSupport(new ApplyJournalEntries(1));
 
@@ -244,12 +233,9 @@ public class RaftActorRecoverySupportTest {
     @Test
     public void testOnDeleteEntries() {
         ReplicatedLog replicatedLog = context.getReplicatedLog();
-        replicatedLog.append(new MockRaftActorContext.MockReplicatedLogEntry(1,
-                0, new MockRaftActorContext.MockPayload("0")));
-        replicatedLog.append(new MockRaftActorContext.MockReplicatedLogEntry(1,
-                1, new MockRaftActorContext.MockPayload("1")));
-        replicatedLog.append(new MockRaftActorContext.MockReplicatedLogEntry(1,
-                2, new MockRaftActorContext.MockPayload("2")));
+        replicatedLog.append(new SimpleReplicatedLogEntry(0, 1, new MockRaftActorContext.MockPayload("0")));
+        replicatedLog.append(new SimpleReplicatedLogEntry(1, 1, new MockRaftActorContext.MockPayload("1")));
+        replicatedLog.append(new SimpleReplicatedLogEntry(2, 1, new MockRaftActorContext.MockPayload("2")));
 
         sendMessageToSupport(new DeleteEntries(1));
 
@@ -279,10 +265,8 @@ public class RaftActorRecoverySupportTest {
 
         sendMessageToSupport(new UpdateElectionTerm(5, "member2"));
 
-        sendMessageToSupport(new MockRaftActorContext.MockReplicatedLogEntry(1,
-                4, new MockRaftActorContext.MockPayload("4")));
-        sendMessageToSupport(new MockRaftActorContext.MockReplicatedLogEntry(1,
-                5, new MockRaftActorContext.MockPayload("5")));
+        sendMessageToSupport(new SimpleReplicatedLogEntry(4, 1, new MockRaftActorContext.MockPayload("4")));
+        sendMessageToSupport(new SimpleReplicatedLogEntry(5, 1, new MockRaftActorContext.MockPayload("5")));
 
         sendMessageToSupport(new ApplyJournalEntries(4));
 
@@ -353,7 +337,7 @@ public class RaftActorRecoverySupportTest {
                 new ServerInfo(follower2, false),
                 new ServerInfo(follower3, true)));
 
-        sendMessageToSupport(new MockRaftActorContext.MockReplicatedLogEntry(1, 0, obj));
+        sendMessageToSupport(new SimpleReplicatedLogEntry(0, 1, obj));
 
         //verify new peers
         assertTrue("Dynamic server configuration", context.isDynamicServerConfigurationInUse());
@@ -374,7 +358,7 @@ public class RaftActorRecoverySupportTest {
                 new ServerInfo("follower2", true),
                 new ServerInfo("follower3", true)));
 
-        sendMessageToSupport(new MockRaftActorContext.MockReplicatedLogEntry(1, 1, obj));
+        sendMessageToSupport(new SimpleReplicatedLogEntry(1, 1, obj));
 
         //verify new peers
         assertTrue("Dynamic server configuration", context.isDynamicServerConfigurationInUse());
@@ -389,7 +373,7 @@ public class RaftActorRecoverySupportTest {
         ServerConfigurationPayload obj = new ServerConfigurationPayload(Arrays.asList(
                 new ServerInfo(localId, true), new ServerInfo(follower, true)));
 
-        sendMessageToSupport(new MockRaftActorContext.MockReplicatedLogEntry(1, 0, obj));
+        sendMessageToSupport(new SimpleReplicatedLogEntry(0, 1, obj));
 
         //verify new peers
         assertEquals("New peer Ids", Sets.newHashSet(follower), Sets.newHashSet(context.getPeerIds()));
index 43ad1c1..af408e6 100644 (file)
@@ -768,12 +768,12 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         RaftActorServerConfigurationSupport support = new RaftActorServerConfigurationSupport(
                 noLeaderActor.underlyingActor());
 
-        ReplicatedLogEntry serverConfigEntry = new MockRaftActorContext.MockReplicatedLogEntry(1, 1,
+        ReplicatedLogEntry serverConfigEntry = new SimpleReplicatedLogEntry(1, 1,
                 new ServerConfigurationPayload(Collections.<ServerInfo>emptyList()));
         boolean handled = support.handleMessage(new ApplyState(null, null, serverConfigEntry), ActorRef.noSender());
         assertEquals("Message handled", true, handled);
 
-        ReplicatedLogEntry nonServerConfigEntry = new MockRaftActorContext.MockReplicatedLogEntry(1, 1,
+        ReplicatedLogEntry nonServerConfigEntry = new SimpleReplicatedLogEntry(1, 1,
                 new MockRaftActorContext.MockPayload("1"));
         handled = support.handleMessage(new ApplyState(null, null, nonServerConfigEntry), ActorRef.noSender());
         assertEquals("Message handled", false, handled);
index d57c354..cdb3e05 100644 (file)
@@ -146,8 +146,7 @@ public class RaftActorTest extends AbstractActorTest {
         kit.watch(followerActor);
 
         List<ReplicatedLogEntry> snapshotUnappliedEntries = new ArrayList<>();
-        ReplicatedLogEntry entry1 = new MockRaftActorContext.MockReplicatedLogEntry(1, 4,
-                new MockRaftActorContext.MockPayload("E"));
+        ReplicatedLogEntry entry1 = new SimpleReplicatedLogEntry(4, 1, new MockRaftActorContext.MockPayload("E"));
         snapshotUnappliedEntries.add(entry1);
 
         int lastAppliedDuringSnapshotCapture = 3;
@@ -167,12 +166,9 @@ public class RaftActorTest extends AbstractActorTest {
 
         // add more entries after snapshot is taken
         List<ReplicatedLogEntry> entries = new ArrayList<>();
-        ReplicatedLogEntry entry2 = new MockRaftActorContext.MockReplicatedLogEntry(1, 5,
-                new MockRaftActorContext.MockPayload("F", 2));
-        ReplicatedLogEntry entry3 = new MockRaftActorContext.MockReplicatedLogEntry(1, 6,
-                new MockRaftActorContext.MockPayload("G", 3));
-        ReplicatedLogEntry entry4 = new MockRaftActorContext.MockReplicatedLogEntry(1, 7,
-                new MockRaftActorContext.MockPayload("H", 4));
+        ReplicatedLogEntry entry2 = new SimpleReplicatedLogEntry(5, 1, new MockRaftActorContext.MockPayload("F", 2));
+        ReplicatedLogEntry entry3 = new SimpleReplicatedLogEntry(6, 1, new MockRaftActorContext.MockPayload("G", 3));
+        ReplicatedLogEntry entry4 = new SimpleReplicatedLogEntry(7, 1, new MockRaftActorContext.MockPayload("H", 4));
         entries.add(entry2);
         entries.add(entry3);
         entries.add(entry4);
@@ -300,8 +296,7 @@ public class RaftActorTest extends AbstractActorTest {
         SnapshotOffer snapshotOffer = new SnapshotOffer(new SnapshotMetadata("test", 6, 12345), snapshot);
         mockRaftActor.handleRecover(snapshotOffer);
 
-        MockRaftActorContext.MockReplicatedLogEntry logEntry = new MockRaftActorContext.MockReplicatedLogEntry(1,
-                1, new MockRaftActorContext.MockPayload("1", 5));
+        ReplicatedLogEntry logEntry = new SimpleReplicatedLogEntry(1, 1, new MockRaftActorContext.MockPayload("1", 5));
         mockRaftActor.handleRecover(logEntry);
 
         ApplyJournalEntries applyJournalEntries = new ApplyJournalEntries(2);
@@ -418,8 +413,7 @@ public class RaftActorTest extends AbstractActorTest {
 
         mockRaftActor.waitForInitializeBehaviorComplete();
 
-        ReplicatedLogEntry entry = new MockRaftActorContext.MockReplicatedLogEntry(1, 5,
-                new MockRaftActorContext.MockPayload("F"));
+        ReplicatedLogEntry entry = new SimpleReplicatedLogEntry(5, 1, new MockRaftActorContext.MockPayload("F"));
 
         final Identifier id = new MockIdentifier("apply-state");
         mockRaftActor.onReceiveCommand(new ApplyState(mockActorRef, id, entry));
@@ -596,7 +590,7 @@ public class RaftActorTest extends AbstractActorTest {
         assertEquals(8, leaderActor.getReplicatedLog().size());
 
         leaderActor.getRaftActorContext().getSnapshotManager().capture(
-                new MockRaftActorContext.MockReplicatedLogEntry(1, 6, new MockRaftActorContext.MockPayload("x")), 4);
+                new SimpleReplicatedLogEntry(6, 1, new MockRaftActorContext.MockPayload("x")), 4);
 
         verify(leaderActor.snapshotCohortDelegate).createSnapshot(any(ActorRef.class));
 
@@ -688,30 +682,23 @@ public class RaftActorTest extends AbstractActorTest {
 
         //snapshot on 4
         followerActor.getRaftActorContext().getSnapshotManager().capture(
-                new MockRaftActorContext.MockReplicatedLogEntry(1, 5,
-                        new MockRaftActorContext.MockPayload("D")), 4);
+                new SimpleReplicatedLogEntry(5, 1, new MockRaftActorContext.MockPayload("D")), 4);
 
         verify(followerActor.snapshotCohortDelegate).createSnapshot(any(ActorRef.class));
 
         assertEquals(6, followerActor.getReplicatedLog().size());
 
         //fake snapshot on index 6
-        List<ReplicatedLogEntry> entries =
-                Arrays.asList(
-                        (ReplicatedLogEntry) new MockRaftActorContext.MockReplicatedLogEntry(1, 6,
-                                new MockRaftActorContext.MockPayload("foo-6"))
-                        );
+        List<ReplicatedLogEntry> entries = Arrays.asList(
+                (ReplicatedLogEntry) new SimpleReplicatedLogEntry(6, 1, new MockRaftActorContext.MockPayload("foo-6")));
         followerActor.onReceiveCommand(new AppendEntries(1, leaderId, 5, 1, entries, 5, 5, (short)0));
         assertEquals(7, followerActor.getReplicatedLog().size());
 
         //fake snapshot on index 7
         assertEquals(RaftState.Follower, followerActor.getCurrentBehavior().state());
 
-        entries =
-                Arrays.asList(
-                        (ReplicatedLogEntry) new MockRaftActorContext.MockReplicatedLogEntry(1, 7,
-                                new MockRaftActorContext.MockPayload("foo-7"))
-                        );
+        entries = Arrays.asList((ReplicatedLogEntry) new SimpleReplicatedLogEntry(7, 1,
+                new MockRaftActorContext.MockPayload("foo-7")));
         followerActor.onReceiveCommand(new AppendEntries(1, leaderId, 6, 1, entries, 6, 6, (short) 0));
         assertEquals(8, followerActor.getReplicatedLog().size());
 
@@ -734,11 +721,8 @@ public class RaftActorTest extends AbstractActorTest {
         assertEquals(3, followerActor.getReplicatedLog().size()); //indexes 5,6,7 left in the log
         assertEquals(7, followerActor.getReplicatedLog().lastIndex());
 
-        entries =
-                Arrays.asList(
-                        (ReplicatedLogEntry) new MockRaftActorContext.MockReplicatedLogEntry(1, 8,
-                                new MockRaftActorContext.MockPayload("foo-7"))
-                        );
+        entries = Arrays.asList((ReplicatedLogEntry) new SimpleReplicatedLogEntry(8, 1,
+                new MockRaftActorContext.MockPayload("foo-7")));
         // send an additional entry 8 with leaderCommit = 7
         followerActor.onReceiveCommand(new AppendEntries(1, leaderId, 7, 1, entries, 7, 7, (short) 0));
 
@@ -851,7 +835,7 @@ public class RaftActorTest extends AbstractActorTest {
 
         leaderActor.waitForInitializeBehaviorComplete();
         for (int i = 0; i < 4; i++) {
-            leaderActor.getReplicatedLog().append(new MockRaftActorContext.MockReplicatedLogEntry(1, i,
+            leaderActor.getReplicatedLog().append(new SimpleReplicatedLogEntry(i, 1,
                     new MockRaftActorContext.MockPayload("A")));
         }
 
@@ -1034,12 +1018,12 @@ public class RaftActorTest extends AbstractActorTest {
         long term = 3;
         long seqN = 1;
         InMemoryJournal.addEntry(persistenceId, seqN++, new UpdateElectionTerm(term, "member-1"));
-        InMemoryJournal.addEntry(persistenceId, seqN++, new MockRaftActorContext.MockReplicatedLogEntry(term, 0,
+        InMemoryJournal.addEntry(persistenceId, seqN++, new SimpleReplicatedLogEntry(0, term,
                 new MockRaftActorContext.MockPayload("A")));
-        InMemoryJournal.addEntry(persistenceId, seqN++, new MockRaftActorContext.MockReplicatedLogEntry(term, 1,
+        InMemoryJournal.addEntry(persistenceId, seqN++, new SimpleReplicatedLogEntry(1, term,
                 new MockRaftActorContext.MockPayload("B")));
         InMemoryJournal.addEntry(persistenceId, seqN++, new ApplyJournalEntries(1));
-        InMemoryJournal.addEntry(persistenceId, seqN++, new MockRaftActorContext.MockReplicatedLogEntry(term, 2,
+        InMemoryJournal.addEntry(persistenceId, seqN++, new SimpleReplicatedLogEntry(2, term,
                 new MockRaftActorContext.MockPayload("C")));
 
         TestActorRef<MockRaftActor> raftActorRef = factory.createTestActor(MockRaftActor.props(persistenceId,
@@ -1198,7 +1182,7 @@ public class RaftActorTest extends AbstractActorTest {
         Snapshot snapshot = Snapshot.create(fromObject(state).toByteArray(), Arrays.<ReplicatedLogEntry>asList(),
                 5, 2, 5, 2, 2, "member-1");
 
-        InMemoryJournal.addEntry(persistenceId, 1, new MockRaftActorContext.MockReplicatedLogEntry(1, 0,
+        InMemoryJournal.addEntry(persistenceId, 1, new SimpleReplicatedLogEntry(0, 1,
                 new MockRaftActorContext.MockPayload("B")));
 
         TestActorRef<MockRaftActor> raftActorRef = factory.createTestActor(MockRaftActor.builder().id(persistenceId)
@@ -1231,7 +1215,7 @@ public class RaftActorTest extends AbstractActorTest {
         config.setHeartBeatInterval(FiniteDuration.create(1, TimeUnit.MILLISECONDS));
 
         String persistenceId = factory.generateActorId("test-actor-");
-        InMemoryJournal.addEntry(persistenceId, 1,  new MockRaftActorContext.MockReplicatedLogEntry(1, 0,
+        InMemoryJournal.addEntry(persistenceId, 1,  new SimpleReplicatedLogEntry(0, 1,
                 new ServerConfigurationPayload(Arrays.asList(new ServerInfo(persistenceId, false)))));
 
         TestActorRef<MockRaftActor> raftActorRef = factory.createTestActor(MockRaftActor.builder().id(persistenceId)
index 6449f0a..c2321ca 100644 (file)
@@ -29,9 +29,9 @@ import org.mockito.MockitoAnnotations;
 import org.mockito.internal.matchers.Same;
 import org.opendaylight.controller.cluster.DataPersistenceProvider;
 import org.opendaylight.controller.cluster.raft.MockRaftActorContext.MockPayload;
-import org.opendaylight.controller.cluster.raft.MockRaftActorContext.MockReplicatedLogEntry;
 import org.opendaylight.controller.cluster.raft.behaviors.RaftActorBehavior;
 import org.opendaylight.controller.cluster.raft.persisted.DeleteEntries;
+import org.opendaylight.controller.cluster.raft.persisted.SimpleReplicatedLogEntry;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -82,7 +82,7 @@ public class ReplicatedLogImplTest {
     public void testAppendAndPersistExpectingNoCapture() throws Exception {
         ReplicatedLog log = ReplicatedLogImpl.newInstance(context);
 
-        MockReplicatedLogEntry logEntry1 = new MockReplicatedLogEntry(1, 1, new MockPayload("1"));
+        ReplicatedLogEntry logEntry1 = new SimpleReplicatedLogEntry(1, 1, new MockPayload("1"));
 
         log.appendAndPersist(logEntry1, null, true);
 
@@ -92,7 +92,7 @@ public class ReplicatedLogImplTest {
 
         reset(mockPersistence);
 
-        MockReplicatedLogEntry logEntry2 = new MockReplicatedLogEntry(1, 2, new MockPayload("2"));
+        ReplicatedLogEntry logEntry2 = new SimpleReplicatedLogEntry(2, 1, new MockPayload("2"));
         Procedure<ReplicatedLogEntry> mockCallback = Mockito.mock(Procedure.class);
         log.appendAndPersist(logEntry2, mockCallback, true);
 
@@ -109,7 +109,7 @@ public class ReplicatedLogImplTest {
         ReplicatedLog log = ReplicatedLogImpl.newInstance(context);
 
         Procedure<ReplicatedLogEntry> mockCallback = Mockito.mock(Procedure.class);
-        MockReplicatedLogEntry logEntry = new MockReplicatedLogEntry(1, 1, new MockPayload("1"));
+        ReplicatedLogEntry logEntry = new SimpleReplicatedLogEntry(1, 1, new MockPayload("1"));
 
         log.appendAndPersist(logEntry, mockCallback, true);
 
@@ -134,8 +134,8 @@ public class ReplicatedLogImplTest {
 
         ReplicatedLog log = ReplicatedLogImpl.newInstance(context);
 
-        final MockReplicatedLogEntry logEntry1 = new MockReplicatedLogEntry(1, 2, new MockPayload("2"));
-        final MockReplicatedLogEntry logEntry2 = new MockReplicatedLogEntry(1, 3, new MockPayload("3"));
+        final ReplicatedLogEntry logEntry1 = new SimpleReplicatedLogEntry(2, 1, new MockPayload("2"));
+        final ReplicatedLogEntry logEntry2 = new SimpleReplicatedLogEntry(3, 1, new MockPayload("3"));
 
         log.appendAndPersist(logEntry1, null, true);
         verifyPersist(logEntry1);
@@ -158,14 +158,14 @@ public class ReplicatedLogImplTest {
         ReplicatedLog log = ReplicatedLogImpl.newInstance(context);
 
         int dataSize = 600;
-        MockReplicatedLogEntry logEntry = new MockReplicatedLogEntry(1, 2, new MockPayload("2", dataSize));
+        ReplicatedLogEntry logEntry = new SimpleReplicatedLogEntry(2, 1, new MockPayload("2", dataSize));
 
         log.appendAndPersist(logEntry, null, true);
         verifyPersist(logEntry);
 
         reset(mockPersistence);
 
-        logEntry = new MockReplicatedLogEntry(1, 3, new MockPayload("3", 5));
+        logEntry = new SimpleReplicatedLogEntry(3, 1, new MockPayload("3", 5));
 
         log.appendAndPersist(logEntry, null, true);
         verifyPersist(logEntry);
@@ -178,9 +178,9 @@ public class ReplicatedLogImplTest {
 
         ReplicatedLog log = ReplicatedLogImpl.newInstance(context);
 
-        log.append(new MockReplicatedLogEntry(1, 0, new MockPayload("0")));
-        log.append(new MockReplicatedLogEntry(1, 1, new MockPayload("1")));
-        log.append(new MockReplicatedLogEntry(1, 2, new MockPayload("2")));
+        log.append(new SimpleReplicatedLogEntry(0, 1, new MockPayload("0")));
+        log.append(new SimpleReplicatedLogEntry(1, 1, new MockPayload("1")));
+        log.append(new SimpleReplicatedLogEntry(2, 1, new MockPayload("2")));
 
         log.removeFromAndPersist(1);
 
index efaae7b..fab250b 100644 (file)
@@ -38,6 +38,7 @@ import org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshot;
 import org.opendaylight.controller.cluster.raft.base.messages.SendInstallSnapshot;
 import org.opendaylight.controller.cluster.raft.base.messages.SnapshotComplete;
 import org.opendaylight.controller.cluster.raft.behaviors.RaftActorBehavior;
+import org.opendaylight.controller.cluster.raft.persisted.SimpleReplicatedLogEntry;
 import org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor;
 import org.slf4j.LoggerFactory;
 
@@ -111,7 +112,7 @@ public class SnapshotManagerTest extends AbstractActorTest {
     public void testCaptureToInstall() throws Exception {
 
         // Force capturing toInstall = true
-        snapshotManager.captureToInstall(new MockRaftActorContext.MockReplicatedLogEntry(1, 0,
+        snapshotManager.captureToInstall(new SimpleReplicatedLogEntry(0, 1,
                 new MockRaftActorContext.MockPayload()), 0, "follower-1");
 
         assertEquals(true, snapshotManager.isCapturing());
@@ -136,7 +137,7 @@ public class SnapshotManagerTest extends AbstractActorTest {
 
     @Test
     public void testCapture() throws Exception {
-        boolean capture = snapshotManager.capture(new MockRaftActorContext.MockReplicatedLogEntry(1,9,
+        boolean capture = snapshotManager.capture(new SimpleReplicatedLogEntry(9, 1,
                 new MockRaftActorContext.MockPayload()), 9);
 
         assertTrue(capture);
@@ -194,7 +195,7 @@ public class SnapshotManagerTest extends AbstractActorTest {
     public void testCaptureWithCreateProcedureError() throws Exception {
         doThrow(new RuntimeException("mock")).when(mockProcedure).run();
 
-        boolean capture = snapshotManager.capture(new MockRaftActorContext.MockReplicatedLogEntry(1,9,
+        boolean capture = snapshotManager.capture(new SimpleReplicatedLogEntry(9, 1,
                 new MockRaftActorContext.MockPayload()), 9);
 
         assertFalse(capture);
@@ -206,7 +207,7 @@ public class SnapshotManagerTest extends AbstractActorTest {
 
     @Test
     public void testIllegalCapture() throws Exception {
-        boolean capture = snapshotManager.capture(new MockRaftActorContext.MockReplicatedLogEntry(1,9,
+        boolean capture = snapshotManager.capture(new SimpleReplicatedLogEntry(9, 1,
                 new MockRaftActorContext.MockPayload()), 9);
 
         assertTrue(capture);
@@ -216,7 +217,7 @@ public class SnapshotManagerTest extends AbstractActorTest {
         reset(mockProcedure);
 
         // This will not cause snapshot capture to start again
-        capture = snapshotManager.capture(new MockRaftActorContext.MockReplicatedLogEntry(1,9,
+        capture = snapshotManager.capture(new SimpleReplicatedLogEntry(9, 1,
                 new MockRaftActorContext.MockPayload()), 9);
 
         assertFalse(capture);
@@ -233,11 +234,10 @@ public class SnapshotManagerTest extends AbstractActorTest {
 
         doReturn(8L).when(mockRaftActorContext).getLastApplied();
 
-        MockRaftActorContext.MockReplicatedLogEntry lastLogEntry = new MockRaftActorContext.MockReplicatedLogEntry(
-                3L, 9L, new MockRaftActorContext.MockPayload());
+        ReplicatedLogEntry lastLogEntry = new SimpleReplicatedLogEntry(9L, 3L, new MockRaftActorContext.MockPayload());
 
-        MockRaftActorContext.MockReplicatedLogEntry lastAppliedEntry = new MockRaftActorContext.MockReplicatedLogEntry(
-                2L, 8L, new MockRaftActorContext.MockPayload());
+        ReplicatedLogEntry lastAppliedEntry = new SimpleReplicatedLogEntry(
+                8L, 2L, new MockRaftActorContext.MockPayload());
 
         doReturn(lastAppliedEntry).when(mockReplicatedLog).get(8L);
         doReturn(Arrays.asList(lastLogEntry)).when(mockReplicatedLog).getFrom(9L);
@@ -275,8 +275,7 @@ public class SnapshotManagerTest extends AbstractActorTest {
         doReturn(9L).when(replicatedLogEntry).getIndex();
 
         // when replicatedToAllIndex != -1
-        snapshotManager.capture(new MockRaftActorContext.MockReplicatedLogEntry(6,9,
-                new MockRaftActorContext.MockPayload()), 9);
+        snapshotManager.capture(new SimpleReplicatedLogEntry(9, 6, new MockRaftActorContext.MockPayload()), 9);
 
         byte[] bytes = new byte[] {1,2,3,4,5,6,7,8,9,10};
         snapshotManager.persist(bytes, Runtime.getRuntime().totalMemory());
@@ -303,8 +302,7 @@ public class SnapshotManagerTest extends AbstractActorTest {
         doReturn(Integer.MAX_VALUE).when(mockReplicatedLog).dataSize();
 
         // when replicatedToAllIndex = -1
-        snapshotManager.capture(new MockRaftActorContext.MockReplicatedLogEntry(6,9,
-                new MockRaftActorContext.MockPayload()), -1);
+        snapshotManager.capture(new SimpleReplicatedLogEntry(9, 6, new MockRaftActorContext.MockPayload()), -1);
 
         snapshotManager.persist(new byte[]{}, Runtime.getRuntime().totalMemory());
 
@@ -329,7 +327,7 @@ public class SnapshotManagerTest extends AbstractActorTest {
         doReturn(6L).when(replicatedLogEntry).getTerm();
         doReturn(replicatedToAllIndex).when(replicatedLogEntry).getIndex();
 
-        snapshotManager.capture(new MockRaftActorContext.MockReplicatedLogEntry(6, 9,
+        snapshotManager.capture(new SimpleReplicatedLogEntry(9, 6,
                 new MockRaftActorContext.MockPayload()), replicatedToAllIndex);
 
         snapshotManager.persist(new byte[]{}, 2000000L);
@@ -346,7 +344,7 @@ public class SnapshotManagerTest extends AbstractActorTest {
         doReturn(Integer.MAX_VALUE).when(mockReplicatedLog).dataSize();
 
         // when replicatedToAllIndex = -1
-        boolean capture = snapshotManager.captureToInstall(new MockRaftActorContext.MockReplicatedLogEntry(6, 9,
+        boolean capture = snapshotManager.captureToInstall(new SimpleReplicatedLogEntry(9, 6,
                 new MockRaftActorContext.MockPayload()), -1, "follower-1");
 
         assertTrue(capture);
@@ -387,7 +385,7 @@ public class SnapshotManagerTest extends AbstractActorTest {
         doReturn(Integer.MAX_VALUE).when(mockReplicatedLog).dataSize();
 
         // when replicatedToAllIndex = -1
-        snapshotManager.captureToInstall(new MockRaftActorContext.MockReplicatedLogEntry(6, 9,
+        snapshotManager.captureToInstall(new SimpleReplicatedLogEntry(9, 6,
                 new MockRaftActorContext.MockPayload()), -1, "follower-1");
 
         snapshotManager.persist(new byte[]{}, Runtime.getRuntime().totalMemory());
@@ -406,7 +404,7 @@ public class SnapshotManagerTest extends AbstractActorTest {
         doReturn(50L).when(mockDataPersistenceProvider).getLastSequenceNumber();
 
         // when replicatedToAllIndex = -1
-        snapshotManager.captureToInstall(new MockRaftActorContext.MockReplicatedLogEntry(6, 9,
+        snapshotManager.captureToInstall(new SimpleReplicatedLogEntry(9, 6,
                 new MockRaftActorContext.MockPayload()), -1, "follower-1");
 
         snapshotManager.persist(new byte[]{}, Runtime.getRuntime().totalMemory());
@@ -435,7 +433,7 @@ public class SnapshotManagerTest extends AbstractActorTest {
     @Test
     public void testCommitBeforePersist() {
         // when replicatedToAllIndex = -1
-        snapshotManager.captureToInstall(new MockRaftActorContext.MockReplicatedLogEntry(6, 9,
+        snapshotManager.captureToInstall(new SimpleReplicatedLogEntry(9, 6,
                 new MockRaftActorContext.MockPayload()), -1, "follower-1");
 
         snapshotManager.commit(100L, 0);
@@ -465,7 +463,7 @@ public class SnapshotManagerTest extends AbstractActorTest {
         doReturn(50L).when(mockDataPersistenceProvider).getLastSequenceNumber();
 
         // when replicatedToAllIndex = -1
-        snapshotManager.captureToInstall(new MockRaftActorContext.MockReplicatedLogEntry(6, 9,
+        snapshotManager.captureToInstall(new SimpleReplicatedLogEntry(9, 6,
                 new MockRaftActorContext.MockPayload()), -1, "follower-1");
 
         snapshotManager.persist(new byte[]{}, Runtime.getRuntime().totalMemory());
@@ -484,7 +482,7 @@ public class SnapshotManagerTest extends AbstractActorTest {
     @Test
     public void testRollback() {
         // when replicatedToAllIndex = -1
-        snapshotManager.captureToInstall(new MockRaftActorContext.MockReplicatedLogEntry(6, 9,
+        snapshotManager.captureToInstall(new SimpleReplicatedLogEntry(9, 6,
                 new MockRaftActorContext.MockPayload()), -1, "follower-1");
 
         snapshotManager.persist(new byte[]{}, Runtime.getRuntime().totalMemory());
@@ -500,7 +498,7 @@ public class SnapshotManagerTest extends AbstractActorTest {
     @Test
     public void testRollbackBeforePersist() {
         // when replicatedToAllIndex = -1
-        snapshotManager.captureToInstall(new MockRaftActorContext.MockReplicatedLogEntry(6, 9,
+        snapshotManager.captureToInstall(new SimpleReplicatedLogEntry(9, 6,
                 new MockRaftActorContext.MockPayload()), -1, "follower-1");
 
         snapshotManager.rollback();
@@ -518,7 +516,7 @@ public class SnapshotManagerTest extends AbstractActorTest {
     @Test
     public void testCallingRollbackMultipleTimesCausesNoHarm() {
         // when replicatedToAllIndex = -1
-        snapshotManager.captureToInstall(new MockRaftActorContext.MockReplicatedLogEntry(6, 9,
+        snapshotManager.captureToInstall(new SimpleReplicatedLogEntry(9, 6,
                 new MockRaftActorContext.MockPayload()), -1, "follower-1");
 
         snapshotManager.persist(new byte[]{}, Runtime.getRuntime().totalMemory());
@@ -602,7 +600,7 @@ public class SnapshotManagerTest extends AbstractActorTest {
 
     @Test
     public void testTrimLogAfterCapture() {
-        boolean capture = snapshotManager.capture(new MockRaftActorContext.MockReplicatedLogEntry(1,9,
+        boolean capture = snapshotManager.capture(new SimpleReplicatedLogEntry(9, 1,
                 new MockRaftActorContext.MockPayload()), 9);
 
         assertTrue(capture);
@@ -624,7 +622,7 @@ public class SnapshotManagerTest extends AbstractActorTest {
 
     @Test
     public void testTrimLogAfterCaptureToInstall() {
-        boolean capture = snapshotManager.captureToInstall(new MockRaftActorContext.MockReplicatedLogEntry(1,9,
+        boolean capture = snapshotManager.captureToInstall(new SimpleReplicatedLogEntry(9, 1,
                 new MockRaftActorContext.MockPayload()), 9, "follower-1");
 
         assertTrue(capture);
@@ -652,7 +650,7 @@ public class SnapshotManagerTest extends AbstractActorTest {
         doReturn(4L).when(mockReplicatedLog).getSnapshotTerm();
         doReturn(7L).when(mockReplicatedLog).getSnapshotIndex();
 
-        ReplicatedLogEntry lastLogEntry = new MockRaftActorContext.MockReplicatedLogEntry(6L, 9L,
+        ReplicatedLogEntry lastLogEntry = new SimpleReplicatedLogEntry(9L, 6L,
                 new MockRaftActorContext.MockPayload());
 
         // No followers and valid lastLogEntry
@@ -668,7 +666,7 @@ public class SnapshotManagerTest extends AbstractActorTest {
         assertEquals("getIndex", -1L, reader.getIndex());
 
         // Followers and valid originalIndex entry
-        doReturn(new MockRaftActorContext.MockReplicatedLogEntry(5L, 8L,
+        doReturn(new SimpleReplicatedLogEntry(8L, 5L,
                 new MockRaftActorContext.MockPayload())).when(mockReplicatedLog).get(8L);
         reader.init(mockReplicatedLog, 8L, lastLogEntry, true);
 
index ead6bb7..df21943 100644 (file)
@@ -36,6 +36,7 @@ import org.opendaylight.controller.cluster.raft.messages.AppendEntriesReply;
 import org.opendaylight.controller.cluster.raft.messages.RaftRPC;
 import org.opendaylight.controller.cluster.raft.messages.RequestVote;
 import org.opendaylight.controller.cluster.raft.messages.RequestVoteReply;
+import org.opendaylight.controller.cluster.raft.persisted.SimpleReplicatedLogEntry;
 import org.opendaylight.controller.cluster.raft.policy.RaftPolicy;
 import org.opendaylight.controller.cluster.raft.protobuff.client.messages.Payload;
 import org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor;
@@ -126,7 +127,7 @@ public abstract class AbstractRaftActorBehaviorTest<T extends RaftActorBehavior>
         setLastLogEntry(context, 2, 0, payload);
 
         List<ReplicatedLogEntry> entries = new ArrayList<>();
-        entries.add(new MockRaftActorContext.MockReplicatedLogEntry(2, 0, payload));
+        entries.add(new SimpleReplicatedLogEntry(0, 2, payload));
 
         final AppendEntries appendEntries = new AppendEntries(2, "leader-1", -1, -1, entries, 2, -1, (short)0);
 
@@ -290,8 +291,7 @@ public abstract class AbstractRaftActorBehaviorTest<T extends RaftActorBehavior>
 
     protected MockRaftActorContext.SimpleReplicatedLog setLastLogEntry(
         MockRaftActorContext actorContext, long term, long index, Payload data) {
-        return setLastLogEntry(actorContext,
-            new MockRaftActorContext.MockReplicatedLogEntry(term, index, data));
+        return setLastLogEntry(actorContext, new SimpleReplicatedLogEntry(index, term, data));
     }
 
     protected MockRaftActorContext.SimpleReplicatedLog setLastLogEntry(MockRaftActorContext actorContext,
index cb188c6..88a2613 100644 (file)
@@ -40,6 +40,7 @@ import org.opendaylight.controller.cluster.raft.messages.AppendEntriesReply;
 import org.opendaylight.controller.cluster.raft.messages.RaftRPC;
 import org.opendaylight.controller.cluster.raft.messages.RequestVote;
 import org.opendaylight.controller.cluster.raft.messages.RequestVoteReply;
+import org.opendaylight.controller.cluster.raft.persisted.SimpleReplicatedLogEntry;
 import org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -316,7 +317,7 @@ public class CandidateTest extends AbstractRaftActorBehaviorTest<Candidate> {
         setLastLogEntry(context, 2, 0, payload);
 
         List<ReplicatedLogEntry> entries = new ArrayList<>();
-        entries.add(new MockRaftActorContext.MockReplicatedLogEntry(2, 0, payload));
+        entries.add(new SimpleReplicatedLogEntry(0, 2, payload));
 
         final AppendEntries appendEntries = new AppendEntries(2, "leader-1", -1, -1, entries, 2, -1, (short)0);
 
index 9ca2ba0..9d64b14 100644 (file)
@@ -52,6 +52,7 @@ import org.opendaylight.controller.cluster.raft.messages.RequestVote;
 import org.opendaylight.controller.cluster.raft.messages.RequestVoteReply;
 import org.opendaylight.controller.cluster.raft.persisted.ServerConfigurationPayload;
 import org.opendaylight.controller.cluster.raft.persisted.ServerInfo;
+import org.opendaylight.controller.cluster.raft.persisted.SimpleReplicatedLogEntry;
 import org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor;
 import scala.concurrent.duration.FiniteDuration;
 
@@ -1126,7 +1127,7 @@ public class FollowerTest extends AbstractRaftActorBehaviorTest<Follower> {
 
 
     private static ReplicatedLogEntry newReplicatedLogEntry(long term, long index, String data) {
-        return new MockRaftActorContext.MockReplicatedLogEntry(term, index,
+        return new SimpleReplicatedLogEntry(index, term,
                 new MockRaftActorContext.MockPayload(data));
     }
 
index 380a0c2..a842069 100644 (file)
@@ -153,8 +153,7 @@ public class LeaderTest extends AbstractLeaderTest<Leader> {
 
     private RaftActorBehavior sendReplicate(MockRaftActorContext actorContext, long term, long index) {
         MockRaftActorContext.MockPayload payload = new MockRaftActorContext.MockPayload("foo");
-        MockRaftActorContext.MockReplicatedLogEntry newEntry = new MockRaftActorContext.MockReplicatedLogEntry(
-                term, index, payload);
+        SimpleReplicatedLogEntry newEntry = new SimpleReplicatedLogEntry(index, term, payload);
         actorContext.getReplicatedLog().append(newEntry);
         return leader.handleMessage(leaderActor, new Replicate(null, null, newEntry));
     }
@@ -513,8 +512,8 @@ public class LeaderTest extends AbstractLeaderTest<Leader> {
 
         long newLogIndex = actorContext.getReplicatedLog().lastIndex() + 1;
         long term = actorContext.getTermInformation().getCurrentTerm();
-        MockRaftActorContext.MockReplicatedLogEntry newEntry = new MockRaftActorContext.MockReplicatedLogEntry(
-                term, newLogIndex, new MockRaftActorContext.MockPayload("foo"));
+        ReplicatedLogEntry newEntry = new SimpleReplicatedLogEntry(
+                newLogIndex, term, new MockRaftActorContext.MockPayload("foo"));
 
         actorContext.getReplicatedLog().append(newEntry);
 
index 9d58d03..f8eab9a 100644 (file)
@@ -14,13 +14,13 @@ import com.google.common.collect.ImmutableMap;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.raft.DefaultConfigParamsImpl;
 import org.opendaylight.controller.cluster.raft.MockRaftActorContext.MockPayload;
-import org.opendaylight.controller.cluster.raft.MockRaftActorContext.MockReplicatedLogEntry;
 import org.opendaylight.controller.cluster.raft.MockRaftActorContext.SimpleReplicatedLog;
 import org.opendaylight.controller.cluster.raft.RaftState;
 import org.opendaylight.controller.cluster.raft.base.messages.ElectionTimeout;
 import org.opendaylight.controller.cluster.raft.base.messages.TimeoutNow;
 import org.opendaylight.controller.cluster.raft.messages.RequestVote;
 import org.opendaylight.controller.cluster.raft.messages.RequestVoteReply;
+import org.opendaylight.controller.cluster.raft.persisted.SimpleReplicatedLogEntry;
 
 /**
  * A leader election scenario test that partitions a candidate when trying to join a cluster on startup.
@@ -166,7 +166,7 @@ public class PartitionedCandidateOnStartupElectionScenarioTest extends AbstractL
         // will be 2 and the last term will be 1 so it is behind the leader's log.
 
         SimpleReplicatedLog candidateReplicatedLog = new SimpleReplicatedLog();
-        candidateReplicatedLog.append(new MockReplicatedLogEntry(2, 0, new MockPayload("")));
+        candidateReplicatedLog.append(new SimpleReplicatedLogEntry(0, 2, new MockPayload("")));
 
         member3Context.setReplicatedLog(candidateReplicatedLog);
         member3Context.setCommitIndex(candidateReplicatedLog.lastIndex());
@@ -216,8 +216,8 @@ public class PartitionedCandidateOnStartupElectionScenarioTest extends AbstractL
         // will be 3 and the last term will be 2.
 
         SimpleReplicatedLog replicatedLog = new SimpleReplicatedLog();
-        replicatedLog.append(new MockReplicatedLogEntry(2, 0, new MockPayload("")));
-        replicatedLog.append(new MockReplicatedLogEntry(3, 1, new MockPayload("")));
+        replicatedLog.append(new SimpleReplicatedLogEntry(0, 2, new MockPayload("")));
+        replicatedLog.append(new SimpleReplicatedLogEntry(1, 3, new MockPayload("")));
 
         // Create member 2's behavior as Follower.
 

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.