Fix warnings in sal-akka-raft test classes 98/46798/4
authorTom Pantelis <tpanteli@brocade.com>
Tue, 11 Oct 2016 16:06:26 +0000 (12:06 -0400)
committerTom Pantelis <tpanteli@brocade.com>
Wed, 12 Oct 2016 16:19:57 +0000 (16:19 +0000)
Fixed checkstyle warnings in the test classes. Most of the
warnings/changes were for:
 - white space before if/for/while/catch
 - white space before beginning brace
 - line too long
 - illegal catching of Exception (suppressed)
 - variable name too short
 - indentation
 - removed use of JavaTestKit with embedded code (avoids
   having to indent code another 4 spaces). In most cases, JavaTestKit
   wasn't even used.
 - local vars/params hiding a field
 - putting overloaded methods close to one another
 - remove unused vars
 - convert functional interfaces to lambdas (eclipse save action)
 - empty catch block - added comment or Throwables.propagate as appropriate
 - missing period after first sentence in javadoc
 - missing first sentence in javadoc
 - adding final for locals declared too far from first usage

Change-Id: I5c522e5b0383b2c5e9b0b036dc444c51f788b650
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
59 files changed:
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractActorTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractRaftActorIntegrationTest.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/DefaultConfigParamsImplTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/ElectionTermImplTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/FollowerLogInformationImplTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/IsolationScenarioTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/LeadershipTransferIntegrationTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/MigratedMessagesTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/MockRaftActor.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/NonVotingFollowerIntegrationTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/PreLeaderScenarioTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorContextImplTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorDelegatingPersistentDataProviderTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorLeadershipTransferCohortTest.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/RaftActorSnapshotMessageSupportTest.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/RaftActorTestKit.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RecoveryIntegrationSingleNodeTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RecoveryIntegrationTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/ReplicatedLogImplEntryTest.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/ReplicationAndSnapshotsIntegrationTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/ReplicationAndSnapshotsWithLaggingFollowerIntegrationTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/ServerConfigurationPayloadTest.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/SnapshotTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/TestActorFactory.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/base/messages/DeleteEntriesTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/base/messages/UpdateElectionTermTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeaderElectionScenarioTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeaderTest.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/DelayedMessagesElectionScenarioTest.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/IsolatedLeaderTest.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
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/PartitionedLeadersElectionScenarioTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/SnapshotTrackerTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/SyncStatusTrackerTest.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/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/ServerConfigurationPayloadTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/persisted/UpdateElectionTermTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/utils/DoNothingActor.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/utils/EchoActor.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/utils/ForwardMessageToBehaviorActor.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/utils/InMemoryJournal.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/utils/InMemorySnapshotStore.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/utils/MessageCollectorActor.java

index 62e2ebd..d16e5ef 100644 (file)
@@ -10,12 +10,12 @@ package org.opendaylight.controller.cluster.raft;
 
 import akka.actor.ActorSystem;
 import akka.testkit.JavaTestKit;
 
 import akka.actor.ActorSystem;
 import akka.testkit.JavaTestKit;
+import java.io.File;
+import java.io.IOException;
 import org.apache.commons.io.FileUtils;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.opendaylight.yangtools.util.AbstractStringIdentifier;
 import org.apache.commons.io.FileUtils;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.opendaylight.yangtools.util.AbstractStringIdentifier;
-import java.io.File;
-import java.io.IOException;
 
 public abstract class AbstractActorTest {
     protected static final class MockIdentifier extends AbstractStringIdentifier<MockIdentifier> {
 
 public abstract class AbstractActorTest {
     protected static final class MockIdentifier extends AbstractStringIdentifier<MockIdentifier> {
@@ -29,14 +29,14 @@ public abstract class AbstractActorTest {
     private static ActorSystem system;
 
     @BeforeClass
     private static ActorSystem system;
 
     @BeforeClass
-    public static void setUpClass() throws Exception{
+    public static void setUpClass() throws Exception {
         deleteJournal();
         System.setProperty("shard.persistent", "false");
         system = ActorSystem.create("test");
     }
 
     @AfterClass
         deleteJournal();
         System.setProperty("shard.persistent", "false");
         system = ActorSystem.create("test");
     }
 
     @AfterClass
-    public static void tearDownClass() throws Exception{
+    public static void tearDownClass() throws Exception {
         deleteJournal();
         JavaTestKit.shutdownActorSystem(system);
         system = null;
         deleteJournal();
         JavaTestKit.shutdownActorSystem(system);
         system = null;
@@ -49,7 +49,7 @@ public abstract class AbstractActorTest {
     protected static void deleteJournal() throws IOException {
         File journal = new File("journal");
 
     protected static void deleteJournal() throws IOException {
         File journal = new File("journal");
 
-        if(journal.exists()) {
+        if (journal.exists()) {
             FileUtils.deleteDirectory(journal);
         }
     }
             FileUtils.deleteDirectory(journal);
         }
     }
index 6e2f25b..9bc8a53 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.controller.cluster.raft;
 import static akka.pattern.Patterns.ask;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static akka.pattern.Patterns.ask;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+
 import akka.actor.ActorRef;
 import akka.actor.InvalidActorNameException;
 import akka.actor.PoisonPill;
 import akka.actor.ActorRef;
 import akka.actor.InvalidActorNameException;
 import akka.actor.PoisonPill;
@@ -19,6 +20,7 @@ import akka.testkit.JavaTestKit;
 import akka.testkit.TestActorRef;
 import akka.util.Timeout;
 import com.google.common.base.Stopwatch;
 import akka.testkit.TestActorRef;
 import akka.util.Timeout;
 import com.google.common.base.Stopwatch;
+import com.google.common.base.Throwables;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.util.concurrent.Uninterruptibles;
 import java.util.ArrayList;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.util.concurrent.Uninterruptibles;
 import java.util.ArrayList;
@@ -109,21 +111,21 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest
             getRaftActorContext().setTotalMemoryRetriever(mockTotalMemory > 0 ? () -> mockTotalMemory : null);
         }
 
             getRaftActorContext().setTotalMemoryRetriever(mockTotalMemory > 0 ? () -> mockTotalMemory : null);
         }
 
-        @SuppressWarnings({ "rawtypes", "unchecked" })
+        @SuppressWarnings({ "rawtypes", "unchecked", "checkstyle:IllegalCatch" })
         @Override
         public void handleCommand(Object message) {
         @Override
         public void handleCommand(Object message) {
-            if(message instanceof MockPayload) {
-                MockPayload payload = (MockPayload)message;
+            if (message instanceof MockPayload) {
+                MockPayload payload = (MockPayload) message;
                 super.persistData(collectorActor, new MockIdentifier(payload.toString()), payload);
                 return;
             }
 
                 super.persistData(collectorActor, new MockIdentifier(payload.toString()), payload);
                 return;
             }
 
-            if(message instanceof ServerConfigurationPayload) {
-                super.persistData(collectorActor, new MockIdentifier("serverConfig"), (Payload)message);
+            if (message instanceof ServerConfigurationPayload) {
+                super.persistData(collectorActor, new MockIdentifier("serverConfig"), (Payload) message);
                 return;
             }
 
                 return;
             }
 
-            if(message instanceof SetPeerAddress) {
+            if (message instanceof SetPeerAddress) {
                 setPeerAddress(((SetPeerAddress) message).getPeerId().toString(),
                         ((SetPeerAddress) message).getPeerAddress());
                 return;
                 setPeerAddress(((SetPeerAddress) message).getPeerId().toString(),
                         ((SetPeerAddress) message).getPeerAddress());
                 return;
@@ -131,11 +133,11 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest
 
             try {
                 Predicate drop = dropMessages.get(message.getClass());
 
             try {
                 Predicate drop = dropMessages.get(message.getClass());
-                if(drop == null || !drop.test(message)) {
+                if (drop == null || !drop.test(message)) {
                     super.handleCommand(message);
                 }
             } finally {
                     super.handleCommand(message);
                 }
             } finally {
-                if(!(message instanceof SendHeartBeat)) {
+                if (!(message instanceof SendHeartBeat)) {
                     try {
                         collectorActor.tell(message, ActorRef.noSender());
                     } catch (Exception e) {
                     try {
                         collectorActor.tell(message, ActorRef.noSender());
                     } catch (Exception e) {
@@ -146,11 +148,12 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest
         }
 
         @Override
         }
 
         @Override
+        @SuppressWarnings("checkstyle:IllegalCatch")
         public void createSnapshot(ActorRef actorRef) {
             try {
                 actorRef.tell(new CaptureSnapshotReply(RaftActorTest.fromObject(getState()).toByteArray()), actorRef);
             } catch (Exception e) {
         public void createSnapshot(ActorRef actorRef) {
             try {
                 actorRef.tell(new CaptureSnapshotReply(RaftActorTest.fromObject(getState()).toByteArray()), actorRef);
             } catch (Exception e) {
-                e.printStackTrace();
+                Throwables.propagate(e);
             }
         }
 
             }
         }
 
@@ -165,8 +168,8 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest
         public static class Builder extends AbstractBuilder<Builder, TestRaftActor> {
             private TestActorRef<MessageCollectorActor> collectorActor;
 
         public static class Builder extends AbstractBuilder<Builder, TestRaftActor> {
             private TestActorRef<MessageCollectorActor> collectorActor;
 
-            public Builder collectorActor(TestActorRef<MessageCollectorActor> collectorActor) {
-                this.collectorActor = collectorActor;
+            public Builder collectorActor(TestActorRef<MessageCollectorActor> newCollectorActor) {
+                this.collectorActor = newCollectorActor;
                 return this;
             }
 
                 return this;
             }
 
@@ -239,10 +242,10 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest
         RaftActorTestKit.waitUntilLeader(actorRef);
     }
 
         RaftActorTestKit.waitUntilLeader(actorRef);
     }
 
-    protected TestActorRef<TestRaftActor> newTestRaftActor(String id, Map<String, String> peerAddresses,
+    protected TestActorRef<TestRaftActor> newTestRaftActor(String id, Map<String, String> newPeerAddresses,
             ConfigParams configParams) {
             ConfigParams configParams) {
-        return newTestRaftActor(id, TestRaftActor.newBuilder().peerAddresses(peerAddresses != null ? peerAddresses :
-            Collections.<String, String>emptyMap()).config(configParams));
+        return newTestRaftActor(id, TestRaftActor.newBuilder().peerAddresses(newPeerAddresses != null
+                ? newPeerAddresses : Collections.<String, String>emptyMap()).config(configParams));
     }
 
     protected TestActorRef<TestRaftActor> newTestRaftActor(String id, TestRaftActor.Builder builder) {
     }
 
     protected TestActorRef<TestRaftActor> newTestRaftActor(String id, TestRaftActor.Builder builder) {
@@ -251,7 +254,7 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest
                         factory.generateActorId(id + "-collector"))).id(id);
 
         InvalidActorNameException lastEx = null;
                         factory.generateActorId(id + "-collector"))).id(id);
 
         InvalidActorNameException lastEx = null;
-        for(int i = 0; i < 10; i++) {
+        for (int i = 0; i < 10; i++) {
             try {
                 return factory.createTestActor(builder.props().withDispatcher(Dispatchers.DefaultDispatcherId()), id);
             } catch (InvalidActorNameException e) {
             try {
                 return factory.createTestActor(builder.props().withDispatcher(Dispatchers.DefaultDispatcherId()), id);
             } catch (InvalidActorNameException e) {
@@ -264,18 +267,19 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest
         throw lastEx;
     }
 
         throw lastEx;
     }
 
-    protected void killActor(TestActorRef<TestRaftActor> leaderActor) {
+    protected void killActor(TestActorRef<TestRaftActor> actor) {
         JavaTestKit testkit = new JavaTestKit(getSystem());
         JavaTestKit testkit = new JavaTestKit(getSystem());
-        testkit.watch(leaderActor);
+        testkit.watch(actor);
 
 
-        leaderActor.tell(PoisonPill.getInstance(), null);
+        actor.tell(PoisonPill.getInstance(), null);
         testkit.expectMsgClass(JavaTestKit.duration("5 seconds"), Terminated.class);
 
         testkit.expectMsgClass(JavaTestKit.duration("5 seconds"), Terminated.class);
 
-        testkit.unwatch(leaderActor);
+        testkit.unwatch(actor);
     }
 
     protected void verifyApplyJournalEntries(ActorRef actor, final long expIndex) {
     }
 
     protected void verifyApplyJournalEntries(ActorRef actor, final long expIndex) {
-        MessageCollectorActor.expectFirstMatching(actor, ApplyJournalEntries.class, msg -> msg.getToIndex() == expIndex);
+        MessageCollectorActor.expectFirstMatching(actor, ApplyJournalEntries.class,
+            msg -> msg.getToIndex() == expIndex);
     }
 
     @SuppressWarnings("unchecked")
     }
 
     @SuppressWarnings("unchecked")
@@ -290,7 +294,7 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest
         List<Object> actualState = (List<Object>)MockRaftActor.toObject(snapshot.getState());
         assertEquals(String.format("%s Snapshot getState size. Expected %s: . Actual: %s", prefix, expSnapshotState,
                 actualState), expSnapshotState.size(), actualState.size());
         List<Object> actualState = (List<Object>)MockRaftActor.toObject(snapshot.getState());
         assertEquals(String.format("%s Snapshot getState size. Expected %s: . Actual: %s", prefix, expSnapshotState,
                 actualState), expSnapshotState.size(), actualState.size());
-        for(int i = 0; i < expSnapshotState.size(); i++) {
+        for (int i = 0; i < expSnapshotState.size(); i++) {
             assertEquals(prefix + " Snapshot state " + i, expSnapshotState.get(i), actualState.get(i));
         }
     }
             assertEquals(prefix + " Snapshot state " + i, expSnapshotState.get(i), actualState.get(i));
         }
     }
@@ -298,26 +302,26 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest
     protected void verifyPersistedJournal(String persistenceId, List<? extends ReplicatedLogEntry> expJournal) {
         List<ReplicatedLogEntry> journal = InMemoryJournal.get(persistenceId, ReplicatedLogEntry.class);
         assertEquals("Journal ReplicatedLogEntry count", expJournal.size(), journal.size());
     protected void verifyPersistedJournal(String persistenceId, List<? extends ReplicatedLogEntry> expJournal) {
         List<ReplicatedLogEntry> journal = InMemoryJournal.get(persistenceId, ReplicatedLogEntry.class);
         assertEquals("Journal ReplicatedLogEntry count", expJournal.size(), journal.size());
-        for(int i = 0; i < expJournal.size(); i++) {
+        for (int i = 0; i < expJournal.size(); i++) {
             ReplicatedLogEntry expected = expJournal.get(i);
             ReplicatedLogEntry actual = journal.get(i);
             verifyReplicatedLogEntry(expected, actual.getTerm(), actual.getIndex(), actual.getData());
         }
     }
 
             ReplicatedLogEntry expected = expJournal.get(i);
             ReplicatedLogEntry actual = journal.get(i);
             verifyReplicatedLogEntry(expected, actual.getTerm(), actual.getIndex(), actual.getData());
         }
     }
 
-    protected MockPayload sendPayloadData(ActorRef leaderActor, String data) {
-        return sendPayloadData(leaderActor, data, 0);
+    protected MockPayload sendPayloadData(ActorRef actor, String data) {
+        return sendPayloadData(actor, data, 0);
     }
 
     }
 
-    protected MockPayload sendPayloadData(ActorRef leaderActor, String data, int size) {
+    protected MockPayload sendPayloadData(ActorRef actor, String data, int size) {
         MockPayload payload;
         MockPayload payload;
-        if(size > 0) {
+        if (size > 0) {
             payload = new MockPayload(data, size);
         } else {
             payload = new MockPayload(data);
         }
 
             payload = new MockPayload(data, size);
         } else {
             payload = new MockPayload(data);
         }
 
-        leaderActor.tell(payload, ActorRef.noSender());
+        actor.tell(payload, ActorRef.noSender());
         return payload;
     }
 
         return payload;
     }
 
@@ -338,7 +342,7 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest
         assertEquals("ReplicatedLogEntry getData", payload, replicatedLogEntry.getData());
     }
 
         assertEquals("ReplicatedLogEntry getData", payload, replicatedLogEntry.getData());
     }
 
-    protected String testActorPath(String id){
+    protected String testActorPath(String id) {
         return factory.createTestActorPath(id);
     }
 
         return factory.createTestActorPath(id);
     }
 
@@ -370,11 +374,12 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest
                 actor.getCurrentBehavior().getReplicatedToAllIndex());
     }
 
                 actor.getCurrentBehavior().getReplicatedToAllIndex());
     }
 
+    @SuppressWarnings("checkstyle:IllegalCatch")
     static void verifyRaftState(ActorRef raftActor, Consumer<OnDemandRaftState> verifier) {
         Timeout timeout = new Timeout(500, TimeUnit.MILLISECONDS);
         AssertionError lastError = null;
         Stopwatch sw = Stopwatch.createStarted();
     static void verifyRaftState(ActorRef raftActor, Consumer<OnDemandRaftState> verifier) {
         Timeout timeout = new Timeout(500, TimeUnit.MILLISECONDS);
         AssertionError lastError = null;
         Stopwatch sw = Stopwatch.createStarted();
-        while(sw.elapsed(TimeUnit.SECONDS) <= 5) {
+        while (sw.elapsed(TimeUnit.SECONDS) <= 5) {
             try {
                 OnDemandRaftState raftState = (OnDemandRaftState)Await.result(ask(raftActor,
                         GetOnDemandRaftState.INSTANCE, timeout), timeout.duration());
             try {
                 OnDemandRaftState raftState = (OnDemandRaftState)Await.result(ask(raftActor,
                         GetOnDemandRaftState.INSTANCE, timeout), timeout.duration());
index 4e2fe80..6c6133f 100644 (file)
@@ -12,6 +12,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
+
 import akka.japi.Procedure;
 import java.util.HashMap;
 import java.util.List;
 import akka.japi.Procedure;
 import java.util.HashMap;
 import java.util.List;
@@ -23,7 +24,7 @@ import org.opendaylight.controller.cluster.raft.MockRaftActorContext.MockPayload
 import org.opendaylight.controller.cluster.raft.MockRaftActorContext.MockReplicatedLogEntry;
 
 /**
 import org.opendaylight.controller.cluster.raft.MockRaftActorContext.MockReplicatedLogEntry;
 
 /**
-*
+* Unit tests for AbstractReplicatedLogImplTest.
 */
 public class AbstractReplicatedLogImplTest {
 
 */
 public class AbstractReplicatedLogImplTest {
 
@@ -303,7 +304,7 @@ public class AbstractReplicatedLogImplTest {
 
         long lastIndex = 0;
         long lastTerm = 0;
 
         long lastIndex = 0;
         long lastTerm = 0;
-        for(int i = 0; i < numEntries; i++) {
+        for (int i = 0; i < numEntries; i++) {
             ReplicatedLogEntry entry = replicatedLogImpl.getAtPhysicalIndex(i);
             map.put(entry.getIndex(), entry.getData().toString());
             lastIndex = entry.getIndex();
             ReplicatedLogEntry entry = replicatedLogImpl.getAtPhysicalIndex(i);
             map.put(entry.getIndex(), entry.getData().toString());
             lastIndex = entry.getIndex();
@@ -316,11 +317,8 @@ public class AbstractReplicatedLogImplTest {
         return map;
 
     }
         return map;
 
     }
-    class MockAbstractReplicatedLogImpl extends AbstractReplicatedLogImpl {
-        @Override
-        public void appendAndPersist(final ReplicatedLogEntry replicatedLogEntry) {
-        }
 
 
+    class MockAbstractReplicatedLogImpl extends AbstractReplicatedLogImpl {
         @Override
         public boolean removeFromAndPersist(final long index) {
             return true;
         @Override
         public boolean removeFromAndPersist(final long index) {
             return true;
@@ -330,6 +328,10 @@ public class AbstractReplicatedLogImplTest {
         public void appendAndPersist(ReplicatedLogEntry replicatedLogEntry, Procedure<ReplicatedLogEntry> callback) {
         }
 
         public void appendAndPersist(ReplicatedLogEntry replicatedLogEntry, Procedure<ReplicatedLogEntry> callback) {
         }
 
+        @Override
+        public void appendAndPersist(final ReplicatedLogEntry replicatedLogEntry) {
+        }
+
         @Override
         public void captureSnapshotIfReady(ReplicatedLogEntry replicatedLogEntry) {
         }
         @Override
         public void captureSnapshotIfReady(ReplicatedLogEntry replicatedLogEntry) {
         }
index e86b377..9062684 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.controller.cluster.raft;
 
 import static org.junit.Assert.assertEquals;
 package org.opendaylight.controller.cluster.raft;
 
 import static org.junit.Assert.assertEquals;
+
 import org.junit.Test;
 import org.opendaylight.controller.cluster.raft.policy.DefaultRaftPolicy;
 import org.opendaylight.controller.cluster.raft.policy.RaftPolicy;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.raft.policy.DefaultRaftPolicy;
 import org.opendaylight.controller.cluster.raft.policy.RaftPolicy;
@@ -16,14 +17,14 @@ import org.opendaylight.controller.cluster.raft.policy.TestRaftPolicy;
 public class DefaultConfigParamsImplTest {
 
     @Test
 public class DefaultConfigParamsImplTest {
 
     @Test
-    public void testGetRaftPolicyWithDefault(){
+    public void testGetRaftPolicyWithDefault() {
         DefaultConfigParamsImpl params = new DefaultConfigParamsImpl();
 
         assertEquals("Default instance", DefaultRaftPolicy.INSTANCE, params.getRaftPolicy());
     }
 
     @Test
         DefaultConfigParamsImpl params = new DefaultConfigParamsImpl();
 
         assertEquals("Default instance", DefaultRaftPolicy.INSTANCE, params.getRaftPolicy());
     }
 
     @Test
-    public void testGetRaftPolicyInvalidClassName(){
+    public void testGetRaftPolicyInvalidClassName() {
         DefaultConfigParamsImpl params = new DefaultConfigParamsImpl();
         params.setCustomRaftPolicyImplementationClass("foobar");
 
         DefaultConfigParamsImpl params = new DefaultConfigParamsImpl();
         params.setCustomRaftPolicyImplementationClass("foobar");
 
@@ -31,7 +32,7 @@ public class DefaultConfigParamsImplTest {
     }
 
     @Test
     }
 
     @Test
-    public void testGetRaftPolicyValidClassNameButInvalidType(){
+    public void testGetRaftPolicyValidClassNameButInvalidType() {
         DefaultConfigParamsImpl params = new DefaultConfigParamsImpl();
         params.setCustomRaftPolicyImplementationClass("java.lang.String");
 
         DefaultConfigParamsImpl params = new DefaultConfigParamsImpl();
         params.setCustomRaftPolicyImplementationClass("java.lang.String");
 
@@ -39,9 +40,10 @@ public class DefaultConfigParamsImplTest {
     }
 
     @Test
     }
 
     @Test
-    public void testGetRaftPolicyValidClass(){
+    public void testGetRaftPolicyValidClass() {
         DefaultConfigParamsImpl params1 = new DefaultConfigParamsImpl();
         DefaultConfigParamsImpl params1 = new DefaultConfigParamsImpl();
-        params1.setCustomRaftPolicyImplementationClass("org.opendaylight.controller.cluster.raft.policy.TestRaftPolicy");
+        params1.setCustomRaftPolicyImplementationClass(
+                "org.opendaylight.controller.cluster.raft.policy.TestRaftPolicy");
         RaftPolicy behavior1 = params1.getRaftPolicy();
 
         assertEquals("TestCustomBehavior", TestRaftPolicy.class, behavior1.getClass());
         RaftPolicy behavior1 = params1.getRaftPolicy();
 
         assertEquals("TestCustomBehavior", TestRaftPolicy.class, behavior1.getClass());
@@ -49,7 +51,8 @@ public class DefaultConfigParamsImplTest {
 
         DefaultConfigParamsImpl params2 = new DefaultConfigParamsImpl();
         RaftPolicy behavior2 = params2.getRaftPolicy();
 
         DefaultConfigParamsImpl params2 = new DefaultConfigParamsImpl();
         RaftPolicy behavior2 = params2.getRaftPolicy();
-        params1.setCustomRaftPolicyImplementationClass("org.opendaylight.controller.cluster.raft.policy.TestRaftPolicy");
+        params1.setCustomRaftPolicyImplementationClass(
+                "org.opendaylight.controller.cluster.raft.policy.TestRaftPolicy");
 
         assertEquals("Default instance", DefaultRaftPolicy.INSTANCE, behavior2);
         assertEquals("Default instance", DefaultRaftPolicy.INSTANCE, params2.getRaftPolicy());
 
         assertEquals("Default instance", DefaultRaftPolicy.INSTANCE, behavior2);
         assertEquals("Default instance", DefaultRaftPolicy.INSTANCE, params2.getRaftPolicy());
@@ -57,4 +60,4 @@ public class DefaultConfigParamsImplTest {
     }
 
 
     }
 
 
-}
\ No newline at end of file
+}
index 972cafd..275dadf 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.controller.cluster.raft;
 
 import static org.junit.Assert.assertEquals;
 import static org.mockito.Mockito.verify;
 
 import static org.junit.Assert.assertEquals;
 import static org.mockito.Mockito.verify;
+
 import akka.japi.Procedure;
 import org.junit.Before;
 import org.junit.Test;
 import akka.japi.Procedure;
 import org.junit.Before;
 import org.junit.Test;
index 843b9be..3818b30 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.controller.cluster.raft;
 
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
 
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
+
 import com.google.common.base.Stopwatch;
 import com.google.common.util.concurrent.Uninterruptibles;
 import java.util.concurrent.TimeUnit;
 import com.google.common.base.Stopwatch;
 import com.google.common.util.concurrent.Uninterruptibles;
 import java.util.concurrent.TimeUnit;
@@ -62,7 +63,7 @@ public class FollowerLogInformationImplTest {
     }
 
     @Test
     }
 
     @Test
-    public void testOkToReplicate(){
+    public void testOkToReplicate() {
         MockRaftActorContext context = new MockRaftActorContext();
         context.setCommitIndex(0);
         FollowerLogInformation followerLogInformation =
         MockRaftActorContext context = new MockRaftActorContext();
         context.setCommitIndex(0);
         FollowerLogInformation followerLogInformation =
index 22dff6a..1d7e317 100644 (file)
@@ -9,11 +9,11 @@ package org.opendaylight.controller.cluster.raft;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
+import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.assertNoneMatching;
 import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.clearMessages;
 import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.clearMessages;
-import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.expectMatching;
 import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.expectFirstMatching;
 import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.expectFirstMatching;
+import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.expectMatching;
 import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.getAllMatching;
 import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.getAllMatching;
-import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.assertNoneMatching;
 
 import akka.actor.Actor;
 import akka.actor.ActorRef;
 
 import akka.actor.Actor;
 import akka.actor.ActorRef;
@@ -58,8 +58,8 @@ public class IsolationScenarioTest extends AbstractRaftActorIntegrationTest {
 
         // Send an initial payloads and verify replication.
 
 
         // Send an initial payloads and verify replication.
 
-        MockPayload payload0 = sendPayloadData(leaderActor, "zero");
-        MockPayload payload1 = sendPayloadData(leaderActor, "one");
+        final MockPayload payload0 = sendPayloadData(leaderActor, "zero");
+        final  MockPayload payload1 = sendPayloadData(leaderActor, "one");
         verifyApplyJournalEntries(leaderCollectorActor, 1);
         verifyApplyJournalEntries(follower1CollectorActor, 1);
         verifyApplyJournalEntries(follower2CollectorActor, 1);
         verifyApplyJournalEntries(leaderCollectorActor, 1);
         verifyApplyJournalEntries(follower1CollectorActor, 1);
         verifyApplyJournalEntries(follower2CollectorActor, 1);
@@ -70,7 +70,7 @@ public class IsolationScenarioTest extends AbstractRaftActorIntegrationTest {
 
         testLog.info("Sending payload to isolated leader");
 
 
         testLog.info("Sending payload to isolated leader");
 
-        MockPayload isolatedLeaderPayload2 = sendPayloadData(leaderActor, "two");
+        final MockPayload isolatedLeaderPayload2 = sendPayloadData(leaderActor, "two");
 
         // Wait for the isolated leader to send AppendEntries to follower1 with the entry at index 2. Note the message
         // is collected but not forwarded to the follower RaftActor.
 
         // Wait for the isolated leader to send AppendEntries to follower1 with the entry at index 2. Note the message
         // is collected but not forwarded to the follower RaftActor.
@@ -84,15 +84,16 @@ public class IsolationScenarioTest extends AbstractRaftActorIntegrationTest {
         // The leader should transition to IsolatedLeader.
 
         expectFirstMatching(leaderNotifierActor, RoleChanged.class,
         // The leader should transition to IsolatedLeader.
 
         expectFirstMatching(leaderNotifierActor, RoleChanged.class,
-                rc -> rc.getNewRole().equals(RaftState.IsolatedLeader.name()));
+            rc -> rc.getNewRole().equals(RaftState.IsolatedLeader.name()));
 
         forceElectionOnFollower1();
 
 
         forceElectionOnFollower1();
 
-        // Send a payload to the new leader follower1 with index 2 and verify it's replicated to follower2 and committed.
+        // Send a payload to the new leader follower1 with index 2 and verify it's replicated to follower2
+        // and committed.
 
         testLog.info("Sending payload to new leader");
 
 
         testLog.info("Sending payload to new leader");
 
-        MockPayload newLeaderPayload2 = sendPayloadData(follower1Actor, "two-new");
+        final MockPayload newLeaderPayload2 = sendPayloadData(follower1Actor, "two-new");
         verifyApplyJournalEntries(follower1CollectorActor, 2);
         verifyApplyJournalEntries(follower2CollectorActor, 2);
 
         verifyApplyJournalEntries(follower1CollectorActor, 2);
         verifyApplyJournalEntries(follower2CollectorActor, 2);
 
@@ -109,7 +110,8 @@ public class IsolationScenarioTest extends AbstractRaftActorIntegrationTest {
         // Previous leader should switch to follower b/c it will receive either an AppendEntries or AppendEntriesReply
         // with a higher term.
 
         // Previous leader should switch to follower b/c it will receive either an AppendEntries or AppendEntriesReply
         // with a higher term.
 
-        expectFirstMatching(leaderNotifierActor, RoleChanged.class, rc -> rc.getNewRole().equals(RaftState.Follower.name()));
+        expectFirstMatching(leaderNotifierActor, RoleChanged.class,
+            rc -> rc.getNewRole().equals(RaftState.Follower.name()));
 
         // The previous leader has a conflicting log entry at index 2 with a different term which should get
         // replaced by the new leader's index 1 entry.
 
         // The previous leader has a conflicting log entry at index 2 with a different term which should get
         // replaced by the new leader's index 1 entry.
@@ -141,7 +143,7 @@ public class IsolationScenarioTest extends AbstractRaftActorIntegrationTest {
 
         // Submit an initial payload that is committed/applied on all nodes.
 
 
         // Submit an initial payload that is committed/applied on all nodes.
 
-        MockPayload payload0 = sendPayloadData(leaderActor, "zero");
+        final MockPayload payload0 = sendPayloadData(leaderActor, "zero");
         verifyApplyJournalEntries(leaderCollectorActor, 0);
         verifyApplyJournalEntries(follower1CollectorActor, 0);
         verifyApplyJournalEntries(follower2CollectorActor, 0);
         verifyApplyJournalEntries(leaderCollectorActor, 0);
         verifyApplyJournalEntries(follower1CollectorActor, 0);
         verifyApplyJournalEntries(follower2CollectorActor, 0);
@@ -159,13 +161,13 @@ public class IsolationScenarioTest extends AbstractRaftActorIntegrationTest {
         // message is forwarded to the followers.
 
         expectFirstMatching(follower1CollectorActor, AppendEntries.class, ae -> {
         // message is forwarded to the followers.
 
         expectFirstMatching(follower1CollectorActor, AppendEntries.class, ae -> {
-            return ae.getEntries().size() == 1 && ae.getEntries().get(0).getIndex() == 1 &&
-                    ae.getEntries().get(0).getData().equals(payload1);
+            return ae.getEntries().size() == 1 && ae.getEntries().get(0).getIndex() == 1
+                    && ae.getEntries().get(0).getData().equals(payload1);
         });
 
         expectFirstMatching(follower2CollectorActor, AppendEntries.class, ae -> {
         });
 
         expectFirstMatching(follower2CollectorActor, AppendEntries.class, ae -> {
-            return ae.getEntries().size() == 1 && ae.getEntries().get(0).getIndex() == 1 &&
-                    ae.getEntries().get(0).getData().equals(payload1);
+            return ae.getEntries().size() == 1 && ae.getEntries().get(0).getIndex() == 1
+                    && ae.getEntries().get(0).getData().equals(payload1);
         });
 
         verifyApplyJournalEntries(leaderCollectorActor, 1);
         });
 
         verifyApplyJournalEntries(leaderCollectorActor, 1);
@@ -176,7 +178,7 @@ public class IsolationScenarioTest extends AbstractRaftActorIntegrationTest {
 
         testLog.info("Sending payload to isolated leader");
 
 
         testLog.info("Sending payload to isolated leader");
 
-        MockPayload isolatedLeaderPayload2 = sendPayloadData(leaderActor, "two");
+        final MockPayload isolatedLeaderPayload2 = sendPayloadData(leaderActor, "two");
 
         // Wait for the isolated leader to send AppendEntries to follower1 with the entry at index 2. Note the message
         // is collected but not forwarded to the follower RaftActor.
 
         // Wait for the isolated leader to send AppendEntries to follower1 with the entry at index 2. Note the message
         // is collected but not forwarded to the follower RaftActor.
@@ -190,7 +192,7 @@ public class IsolationScenarioTest extends AbstractRaftActorIntegrationTest {
         // The leader should transition to IsolatedLeader.
 
         expectFirstMatching(leaderNotifierActor, RoleChanged.class,
         // The leader should transition to IsolatedLeader.
 
         expectFirstMatching(leaderNotifierActor, RoleChanged.class,
-                rc -> rc.getNewRole().equals(RaftState.IsolatedLeader.name()));
+            rc -> rc.getNewRole().equals(RaftState.IsolatedLeader.name()));
 
         forceElectionOnFollower1();
 
 
         forceElectionOnFollower1();
 
@@ -200,7 +202,7 @@ public class IsolationScenarioTest extends AbstractRaftActorIntegrationTest {
 
         testLog.info("Sending payload to new leader");
 
 
         testLog.info("Sending payload to new leader");
 
-        MockPayload newLeaderPayload2 = sendPayloadData(follower1Actor, "two-new");
+        final MockPayload newLeaderPayload2 = sendPayloadData(follower1Actor, "two-new");
         verifyApplyJournalEntries(follower1CollectorActor, 3);
         verifyApplyJournalEntries(follower2CollectorActor, 3);
 
         verifyApplyJournalEntries(follower1CollectorActor, 3);
         verifyApplyJournalEntries(follower2CollectorActor, 3);
 
@@ -217,7 +219,8 @@ public class IsolationScenarioTest extends AbstractRaftActorIntegrationTest {
         // Previous leader should switch to follower b/c it will receive either an AppendEntries or AppendEntriesReply
         // with a higher term.
 
         // Previous leader should switch to follower b/c it will receive either an AppendEntries or AppendEntriesReply
         // with a higher term.
 
-        expectFirstMatching(leaderNotifierActor, RoleChanged.class, rc -> rc.getNewRole().equals(RaftState.Follower.name()));
+        expectFirstMatching(leaderNotifierActor, RoleChanged.class,
+            rc -> rc.getNewRole().equals(RaftState.Follower.name()));
 
         // The previous leader has a conflicting log entry at index 2 with a different term which should get
         // replaced by the new leader's entry.
 
         // The previous leader has a conflicting log entry at index 2 with a different term which should get
         // replaced by the new leader's entry.
@@ -236,8 +239,8 @@ public class IsolationScenarioTest extends AbstractRaftActorIntegrationTest {
         // Ensure the prior leader didn't apply its conflicting entry with index 2, term 1.
 
         List<ApplyState> applyState = getAllMatching(leaderCollectorActor, ApplyState.class);
         // Ensure the prior leader didn't apply its conflicting entry with index 2, term 1.
 
         List<ApplyState> applyState = getAllMatching(leaderCollectorActor, ApplyState.class);
-        for(ApplyState as: applyState) {
-            if(as.getReplicatedLogEntry().getIndex() == 2 && as.getReplicatedLogEntry().getTerm() == 1) {
+        for (ApplyState as: applyState) {
+            if (as.getReplicatedLogEntry().getIndex() == 2 && as.getReplicatedLogEntry().getTerm() == 1) {
                 fail("Got unexpected ApplyState: " + as);
             }
         }
                 fail("Got unexpected ApplyState: " + as);
             }
         }
@@ -263,7 +266,7 @@ public class IsolationScenarioTest extends AbstractRaftActorIntegrationTest {
 
         // Submit an initial payload that is committed/applied on all nodes.
 
 
         // Submit an initial payload that is committed/applied on all nodes.
 
-        MockPayload payload0 = sendPayloadData(leaderActor, "zero");
+        final MockPayload payload0 = sendPayloadData(leaderActor, "zero");
         verifyApplyJournalEntries(leaderCollectorActor, 0);
         verifyApplyJournalEntries(follower1CollectorActor, 0);
         verifyApplyJournalEntries(follower2CollectorActor, 0);
         verifyApplyJournalEntries(leaderCollectorActor, 0);
         verifyApplyJournalEntries(follower1CollectorActor, 0);
         verifyApplyJournalEntries(follower2CollectorActor, 0);
@@ -281,13 +284,13 @@ public class IsolationScenarioTest extends AbstractRaftActorIntegrationTest {
         // message is forwarded to the followers.
 
         expectFirstMatching(follower1CollectorActor, AppendEntries.class, ae -> {
         // message is forwarded to the followers.
 
         expectFirstMatching(follower1CollectorActor, AppendEntries.class, ae -> {
-            return ae.getEntries().size() == 1 && ae.getEntries().get(0).getIndex() == 1 &&
-                    ae.getEntries().get(0).getData().equals(payload1);
+            return ae.getEntries().size() == 1 && ae.getEntries().get(0).getIndex() == 1
+                    && ae.getEntries().get(0).getData().equals(payload1);
         });
 
         expectFirstMatching(follower2CollectorActor, AppendEntries.class, ae -> {
         });
 
         expectFirstMatching(follower2CollectorActor, AppendEntries.class, ae -> {
-            return ae.getEntries().size() == 1 && ae.getEntries().get(0).getIndex() == 1 &&
-                    ae.getEntries().get(0).getData().equals(payload1);
+            return ae.getEntries().size() == 1 && ae.getEntries().get(0).getIndex() == 1
+                    && ae.getEntries().get(0).getData().equals(payload1);
         });
 
         verifyApplyJournalEntries(leaderCollectorActor, 1);
         });
 
         verifyApplyJournalEntries(leaderCollectorActor, 1);
@@ -306,8 +309,8 @@ public class IsolationScenarioTest extends AbstractRaftActorIntegrationTest {
         // are collected but not forwarded to the follower RaftActor.
 
         expectFirstMatching(follower1CollectorActor, AppendEntries.class, ae -> {
         // are collected but not forwarded to the follower RaftActor.
 
         expectFirstMatching(follower1CollectorActor, AppendEntries.class, ae -> {
-            for(ReplicatedLogEntry e: ae.getEntries()) {
-                if(e.getIndex() == 4) {
+            for (ReplicatedLogEntry e: ae.getEntries()) {
+                if (e.getIndex() == 4) {
                     return true;
                 }
             }
                     return true;
                 }
             }
@@ -317,7 +320,7 @@ public class IsolationScenarioTest extends AbstractRaftActorIntegrationTest {
         // The leader should transition to IsolatedLeader.
 
         expectFirstMatching(leaderNotifierActor, RoleChanged.class,
         // The leader should transition to IsolatedLeader.
 
         expectFirstMatching(leaderNotifierActor, RoleChanged.class,
-                rc -> rc.getNewRole().equals(RaftState.IsolatedLeader.name()));
+            rc -> rc.getNewRole().equals(RaftState.IsolatedLeader.name()));
 
         forceElectionOnFollower1();
 
 
         forceElectionOnFollower1();
 
@@ -327,9 +330,9 @@ public class IsolationScenarioTest extends AbstractRaftActorIntegrationTest {
 
         testLog.info("Sending 3 payloads to new leader");
 
 
         testLog.info("Sending 3 payloads to new leader");
 
-        MockPayload newLeaderPayload2 = sendPayloadData(follower1Actor, "two-new");
-        MockPayload newLeaderPayload3 = sendPayloadData(follower1Actor, "three-new");
-        MockPayload newLeaderPayload4 = sendPayloadData(follower1Actor, "four-new");
+        final MockPayload newLeaderPayload2 = sendPayloadData(follower1Actor, "two-new");
+        final MockPayload newLeaderPayload3 = sendPayloadData(follower1Actor, "three-new");
+        final MockPayload newLeaderPayload4 = sendPayloadData(follower1Actor, "four-new");
         verifyApplyJournalEntries(follower1CollectorActor, 5);
         verifyApplyJournalEntries(follower2CollectorActor, 5);
 
         verifyApplyJournalEntries(follower1CollectorActor, 5);
         verifyApplyJournalEntries(follower2CollectorActor, 5);
 
@@ -346,7 +349,8 @@ public class IsolationScenarioTest extends AbstractRaftActorIntegrationTest {
         // Previous leader should switch to follower b/c it will receive either an AppendEntries or AppendEntriesReply
         // with a higher term.
 
         // Previous leader should switch to follower b/c it will receive either an AppendEntries or AppendEntriesReply
         // with a higher term.
 
-        expectFirstMatching(leaderNotifierActor, RoleChanged.class, rc -> rc.getNewRole().equals(RaftState.Follower.name()));
+        expectFirstMatching(leaderNotifierActor, RoleChanged.class,
+            rc -> rc.getNewRole().equals(RaftState.Follower.name()));
 
         // The previous leader has conflicting log entries starting at index 2 with different terms which should get
         // replaced by the new leader's entries.
 
         // The previous leader has conflicting log entries starting at index 2 with different terms which should get
         // replaced by the new leader's entries.
@@ -365,8 +369,8 @@ public class IsolationScenarioTest extends AbstractRaftActorIntegrationTest {
         // Ensure the prior leader didn't apply any of its conflicting entries with term 1.
 
         List<ApplyState> applyState = getAllMatching(leaderCollectorActor, ApplyState.class);
         // Ensure the prior leader didn't apply any of its conflicting entries with term 1.
 
         List<ApplyState> applyState = getAllMatching(leaderCollectorActor, ApplyState.class);
-        for(ApplyState as: applyState) {
-            if(as.getReplicatedLogEntry().getTerm() == 1) {
+        for (ApplyState as: applyState) {
+            if (as.getReplicatedLogEntry().getTerm() == 1) {
                 fail("Got unexpected ApplyState: " + as);
             }
         }
                 fail("Got unexpected ApplyState: " + as);
             }
         }
@@ -398,7 +402,7 @@ public class IsolationScenarioTest extends AbstractRaftActorIntegrationTest {
         follower1Actor.tell(TimeoutNow.INSTANCE, ActorRef.noSender());
 
         expectFirstMatching(follower1NotifierActor, RoleChanged.class,
         follower1Actor.tell(TimeoutNow.INSTANCE, ActorRef.noSender());
 
         expectFirstMatching(follower1NotifierActor, RoleChanged.class,
-                rc -> rc.getNewRole().equals(RaftState.Leader.name()));
+            rc -> rc.getNewRole().equals(RaftState.Leader.name()));
 
         currentTerm = follower1Context.getTermInformation().getCurrentTerm();
     }
 
         currentTerm = follower1Context.getTermInformation().getCurrentTerm();
     }
@@ -411,8 +415,10 @@ public class IsolationScenarioTest extends AbstractRaftActorIntegrationTest {
         leaderActor.underlyingActor().startDropMessages(AppendEntries.class);
         leaderActor.underlyingActor().startDropMessages(RequestVote.class);
 
         leaderActor.underlyingActor().startDropMessages(AppendEntries.class);
         leaderActor.underlyingActor().startDropMessages(RequestVote.class);
 
-        follower1Actor.underlyingActor().startDropMessages(AppendEntries.class, ae -> ae.getLeaderId().equals(leaderId));
-        follower2Actor.underlyingActor().startDropMessages(AppendEntries.class, ae -> ae.getLeaderId().equals(leaderId));
+        follower1Actor.underlyingActor().startDropMessages(AppendEntries.class,
+            ae -> ae.getLeaderId().equals(leaderId));
+        follower2Actor.underlyingActor().startDropMessages(AppendEntries.class,
+            ae -> ae.getLeaderId().equals(leaderId));
 
         clearMessages(follower1CollectorActor);
         clearMessages(follower1NotifierActor);
 
         clearMessages(follower1CollectorActor);
         clearMessages(follower1NotifierActor);
@@ -429,15 +435,15 @@ public class IsolationScenarioTest extends AbstractRaftActorIntegrationTest {
         followerConfigParams.setHeartBeatInterval(new FiniteDuration(100, TimeUnit.MILLISECONDS));
         followerConfigParams.setElectionTimeoutFactor(1000);
         follower1Actor = newTestRaftActor(follower1Id, TestRaftActor.newBuilder().peerAddresses(
         followerConfigParams.setHeartBeatInterval(new FiniteDuration(100, TimeUnit.MILLISECONDS));
         followerConfigParams.setElectionTimeoutFactor(1000);
         follower1Actor = newTestRaftActor(follower1Id, TestRaftActor.newBuilder().peerAddresses(
-                ImmutableMap.of(leaderId, testActorPath(leaderId), follower2Id, testActorPath(follower2Id))).
-                config(followerConfigParams).roleChangeNotifier(follower1NotifierActor));
+                ImmutableMap.of(leaderId, testActorPath(leaderId), follower2Id, testActorPath(follower2Id)))
+                .config(followerConfigParams).roleChangeNotifier(follower1NotifierActor));
 
         follower2Actor = newTestRaftActor(follower2Id, ImmutableMap.of(leaderId, testActorPath(leaderId),
                 follower1Id, testActorPath(follower1Id)), followerConfigParams);
 
 
         follower2Actor = newTestRaftActor(follower2Id, ImmutableMap.of(leaderId, testActorPath(leaderId),
                 follower1Id, testActorPath(follower1Id)), followerConfigParams);
 
-        peerAddresses = ImmutableMap.<String, String>builder().
-                put(follower1Id, follower1Actor.path().toString()).
-                put(follower2Id, follower2Actor.path().toString()).build();
+        peerAddresses = ImmutableMap.<String, String>builder()
+                .put(follower1Id, follower1Actor.path().toString())
+                .put(follower2Id, follower2Actor.path().toString()).build();
 
         leaderConfigParams = newLeaderConfigParams();
         leaderConfigParams.setIsolatedLeaderCheckInterval(new FiniteDuration(500, TimeUnit.MILLISECONDS));
 
         leaderConfigParams = newLeaderConfigParams();
         leaderConfigParams.setIsolatedLeaderCheckInterval(new FiniteDuration(500, TimeUnit.MILLISECONDS));
@@ -445,8 +451,8 @@ public class IsolationScenarioTest extends AbstractRaftActorIntegrationTest {
         leaderNotifierActor = factory.createTestActor(Props.create(MessageCollectorActor.class),
                 factory.generateActorId(leaderId + "-notifier"));
 
         leaderNotifierActor = factory.createTestActor(Props.create(MessageCollectorActor.class),
                 factory.generateActorId(leaderId + "-notifier"));
 
-        leaderActor = newTestRaftActor(leaderId, TestRaftActor.newBuilder().peerAddresses(peerAddresses).
-                config(leaderConfigParams).roleChangeNotifier(leaderNotifierActor));
+        leaderActor = newTestRaftActor(leaderId, TestRaftActor.newBuilder().peerAddresses(peerAddresses)
+                .config(leaderConfigParams).roleChangeNotifier(leaderNotifierActor));
 
         follower1CollectorActor = follower1Actor.underlyingActor().collectorActor();
         follower2CollectorActor = follower2Actor.underlyingActor().collectorActor();
 
         follower1CollectorActor = follower1Actor.underlyingActor().collectorActor();
         follower2CollectorActor = follower2Actor.underlyingActor().collectorActor();
index a86e9e1..76ef5f6 100644 (file)
@@ -11,6 +11,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.clearMessages;
 import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.expectFirstMatching;
 import static org.junit.Assert.assertNull;
 import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.clearMessages;
 import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.expectFirstMatching;
+
 import akka.actor.ActorRef;
 import akka.actor.Props;
 import akka.pattern.Patterns;
 import akka.actor.ActorRef;
 import akka.actor.Props;
 import akka.pattern.Patterns;
@@ -44,7 +45,7 @@ public class LeadershipTransferIntegrationTest extends AbstractRaftActorIntegrat
     private ActorRef follower3CollectorActor;
 
     @Test
     private ActorRef follower3CollectorActor;
 
     @Test
-    public void testLeaderTransferOnShutDown() throws Throwable {
+    public void testLeaderTransferOnShutDown() throws Exception {
         testLog.info("testLeaderTransferOnShutDown starting");
 
         createRaftActors();
         testLog.info("testLeaderTransferOnShutDown starting");
 
         createRaftActors();
@@ -70,7 +71,7 @@ public class LeadershipTransferIntegrationTest extends AbstractRaftActorIntegrat
         testLog.info("sendShutDown for {} ending", actor.path());
     }
 
         testLog.info("sendShutDown for {} ending", actor.path());
     }
 
-    private void sendShutDownToLeaderAndVerifyLeadershipTransferToFollower1() throws Throwable {
+    private void sendShutDownToLeaderAndVerifyLeadershipTransferToFollower1() throws Exception {
         testLog.info("sendShutDownToLeaderAndVerifyLeadershipTransferToFollower1 starting");
 
         clearMessages(leaderNotifierActor);
         testLog.info("sendShutDownToLeaderAndVerifyLeadershipTransferToFollower1 starting");
 
         clearMessages(leaderNotifierActor);
@@ -79,7 +80,7 @@ public class LeadershipTransferIntegrationTest extends AbstractRaftActorIntegrat
         clearMessages(follower3NotifierActor);
 
         FiniteDuration duration = FiniteDuration.create(5, TimeUnit.SECONDS);
         clearMessages(follower3NotifierActor);
 
         FiniteDuration duration = FiniteDuration.create(5, TimeUnit.SECONDS);
-        Future<Boolean> stopFuture = Patterns.gracefulStop(leaderActor, duration, Shutdown.INSTANCE);
+        final Future<Boolean> stopFuture = Patterns.gracefulStop(leaderActor, duration, Shutdown.INSTANCE);
 
         assertNullLeaderIdChange(leaderNotifierActor);
         assertNullLeaderIdChange(follower1NotifierActor);
 
         assertNullLeaderIdChange(leaderNotifierActor);
         assertNullLeaderIdChange(follower1NotifierActor);
@@ -119,34 +120,34 @@ public class LeadershipTransferIntegrationTest extends AbstractRaftActorIntegrat
                 factory.generateActorId(follower1Id + "-notifier"));
         follower1Actor = newTestRaftActor(follower1Id, TestRaftActor.newBuilder().peerAddresses(
                 ImmutableMap.of(leaderId, testActorPath(leaderId), follower2Id, testActorPath(follower2Id),
                 factory.generateActorId(follower1Id + "-notifier"));
         follower1Actor = newTestRaftActor(follower1Id, TestRaftActor.newBuilder().peerAddresses(
                 ImmutableMap.of(leaderId, testActorPath(leaderId), follower2Id, testActorPath(follower2Id),
-                        follower3Id, testActorPath(follower3Id))).
-                config(newFollowerConfigParams()).roleChangeNotifier(follower1NotifierActor));
+                        follower3Id, testActorPath(follower3Id)))
+                .config(newFollowerConfigParams()).roleChangeNotifier(follower1NotifierActor));
 
         follower2NotifierActor = factory.createTestActor(Props.create(MessageCollectorActor.class),
                 factory.generateActorId(follower2Id + "-notifier"));
         follower2Actor = newTestRaftActor(follower2Id,TestRaftActor.newBuilder().peerAddresses(
                 ImmutableMap.of(leaderId, testActorPath(leaderId), follower1Id, follower1Actor.path().toString(),
 
         follower2NotifierActor = factory.createTestActor(Props.create(MessageCollectorActor.class),
                 factory.generateActorId(follower2Id + "-notifier"));
         follower2Actor = newTestRaftActor(follower2Id,TestRaftActor.newBuilder().peerAddresses(
                 ImmutableMap.of(leaderId, testActorPath(leaderId), follower1Id, follower1Actor.path().toString(),
-                        follower3Id, testActorPath(follower3Id))).
-                config(newFollowerConfigParams()).roleChangeNotifier(follower2NotifierActor));
+                        follower3Id, testActorPath(follower3Id)))
+                .config(newFollowerConfigParams()).roleChangeNotifier(follower2NotifierActor));
 
         follower3NotifierActor = factory.createTestActor(Props.create(MessageCollectorActor.class),
                 factory.generateActorId(follower3Id + "-notifier"));
         follower3Actor = newTestRaftActor(follower3Id,TestRaftActor.newBuilder().peerAddresses(
                 ImmutableMap.of(leaderId, testActorPath(leaderId), follower1Id, follower1Actor.path().toString(),
 
         follower3NotifierActor = factory.createTestActor(Props.create(MessageCollectorActor.class),
                 factory.generateActorId(follower3Id + "-notifier"));
         follower3Actor = newTestRaftActor(follower3Id,TestRaftActor.newBuilder().peerAddresses(
                 ImmutableMap.of(leaderId, testActorPath(leaderId), follower1Id, follower1Actor.path().toString(),
-                        follower2Id, follower2Actor.path().toString())).
-                config(newFollowerConfigParams()).roleChangeNotifier(follower3NotifierActor));
+                        follower2Id, follower2Actor.path().toString()))
+                .config(newFollowerConfigParams()).roleChangeNotifier(follower3NotifierActor));
 
 
-        peerAddresses = ImmutableMap.<String, String>builder().
-                put(follower1Id, follower1Actor.path().toString()).
-                put(follower2Id, follower2Actor.path().toString()).
-                put(follower3Id, follower3Actor.path().toString()).build();
+        peerAddresses = ImmutableMap.<String, String>builder()
+                .put(follower1Id, follower1Actor.path().toString())
+                .put(follower2Id, follower2Actor.path().toString())
+                .put(follower3Id, follower3Actor.path().toString()).build();
 
         leaderConfigParams = newLeaderConfigParams();
         leaderConfigParams.setElectionTimeoutFactor(3);
         leaderNotifierActor = factory.createTestActor(Props.create(MessageCollectorActor.class),
                 factory.generateActorId(leaderId + "-notifier"));
 
         leaderConfigParams = newLeaderConfigParams();
         leaderConfigParams.setElectionTimeoutFactor(3);
         leaderNotifierActor = factory.createTestActor(Props.create(MessageCollectorActor.class),
                 factory.generateActorId(leaderId + "-notifier"));
-        leaderActor = newTestRaftActor(leaderId, TestRaftActor.newBuilder().peerAddresses(peerAddresses).
-                config(leaderConfigParams).roleChangeNotifier(leaderNotifierActor));
+        leaderActor = newTestRaftActor(leaderId, TestRaftActor.newBuilder().peerAddresses(peerAddresses)
+                .config(leaderConfigParams).roleChangeNotifier(leaderNotifierActor));
 
         follower1CollectorActor = follower1Actor.underlyingActor().collectorActor();
         follower2CollectorActor = follower2Actor.underlyingActor().collectorActor();
 
         follower1CollectorActor = follower1Actor.underlyingActor().collectorActor();
         follower2CollectorActor = follower2Actor.underlyingActor().collectorActor();
@@ -171,7 +172,7 @@ public class LeadershipTransferIntegrationTest extends AbstractRaftActorIntegrat
     }
 
     @Test
     }
 
     @Test
-    public void testLeaderTransferAborted() throws Throwable {
+    public void testLeaderTransferAborted() throws Exception {
         testLog.info("testLeaderTransferAborted starting");
 
         createRaftActors();
         testLog.info("testLeaderTransferAborted starting");
 
         createRaftActors();
@@ -188,7 +189,7 @@ public class LeadershipTransferIntegrationTest extends AbstractRaftActorIntegrat
     }
 
     @Test
     }
 
     @Test
-    public void testLeaderTransferSkippedOnShutdownWithNoFollowers() throws Throwable {
+    public void testLeaderTransferSkippedOnShutdownWithNoFollowers() throws Exception {
         testLog.info("testLeaderTransferSkippedOnShutdownWithNoFollowers starting");
 
         leaderActor = newTestRaftActor(leaderId, TestRaftActor.newBuilder().config(newLeaderConfigParams()));
         testLog.info("testLeaderTransferSkippedOnShutdownWithNoFollowers starting");
 
         leaderActor = newTestRaftActor(leaderId, TestRaftActor.newBuilder().config(newLeaderConfigParams()));
index 2f1a391..08967d2 100644 (file)
@@ -8,6 +8,11 @@
 package org.opendaylight.controller.cluster.raft;
 
 import static org.junit.Assert.assertEquals;
 package org.opendaylight.controller.cluster.raft;
 
 import static org.junit.Assert.assertEquals;
+
+import akka.actor.ActorRef;
+import akka.dispatch.Dispatchers;
+import akka.testkit.JavaTestKit;
+import akka.testkit.TestActorRef;
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.Uninterruptibles;
 import java.util.Arrays;
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.Uninterruptibles;
 import java.util.Arrays;
@@ -27,10 +32,6 @@ import org.opendaylight.controller.cluster.raft.utils.InMemoryJournal;
 import org.opendaylight.controller.cluster.raft.utils.InMemorySnapshotStore;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.opendaylight.controller.cluster.raft.utils.InMemorySnapshotStore;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import akka.actor.ActorRef;
-import akka.dispatch.Dispatchers;
-import akka.testkit.JavaTestKit;
-import akka.testkit.TestActorRef;
 
 /**
  * Unit tests for migrated messages on recovery.
 
 /**
  * Unit tests for migrated messages on recovery.
@@ -43,7 +44,7 @@ public class MigratedMessagesTest extends AbstractActorTest {
     private TestActorFactory factory;
 
     @Before
     private TestActorFactory factory;
 
     @Before
-    public void setUp(){
+    public void setUp() {
         factory = new TestActorFactory(getSystem());
     }
 
         factory = new TestActorFactory(getSystem());
     }
 
@@ -72,8 +73,8 @@ public class MigratedMessagesTest extends AbstractActorTest {
 
         factory.killActor(actor, new JavaTestKit(getSystem()));
 
 
         factory.killActor(actor, new JavaTestKit(getSystem()));
 
-        actor = factory.createTestActor(MockRaftActor.builder().id(id).config(config).persistent(Optional.of(false)).props().
-                    withDispatcher(Dispatchers.DefaultDispatcherId()), id);
+        actor = factory.createTestActor(MockRaftActor.builder().id(id).config(config)
+                .persistent(Optional.of(false)).props().withDispatcher(Dispatchers.DefaultDispatcherId()), id);
         mockRaftActor = actor.underlyingActor();
         mockRaftActor.waitForRecoveryComplete();
 
         mockRaftActor = actor.underlyingActor();
         mockRaftActor.waitForRecoveryComplete();
 
@@ -163,9 +164,9 @@ public class MigratedMessagesTest extends AbstractActorTest {
             }
         };
 
             }
         };
 
-        TestActorRef<MockRaftActor> raftActorRef = factory.createTestActor(MockRaftActor.builder().id(id).
-                config(config).snapshotCohort(snapshotCohort).persistent(Optional.of(true)).props().
-                    withDispatcher(Dispatchers.DefaultDispatcherId()), id);
+        TestActorRef<MockRaftActor> raftActorRef = factory.createTestActor(MockRaftActor.builder().id(id)
+                .config(config).snapshotCohort(snapshotCohort).persistent(Optional.of(true)).props()
+                    .withDispatcher(Dispatchers.DefaultDispatcherId()), id);
         MockRaftActor mockRaftActor = raftActorRef.underlyingActor();
 
         mockRaftActor.waitForRecoveryComplete();
         MockRaftActor mockRaftActor = raftActorRef.underlyingActor();
 
         mockRaftActor.waitForRecoveryComplete();
@@ -193,17 +194,17 @@ public class MigratedMessagesTest extends AbstractActorTest {
         InMemoryJournal.addEntry(persistenceId, 3, new ReplicatedLogImplEntry(0, 1, persistedServerConfig));
 
         TestActorRef<MockRaftActor> actor = doTestSnapshotAfterStartupWithMigratedMessage(persistenceId,
         InMemoryJournal.addEntry(persistenceId, 3, new ReplicatedLogImplEntry(0, 1, persistedServerConfig));
 
         TestActorRef<MockRaftActor> actor = doTestSnapshotAfterStartupWithMigratedMessage(persistenceId,
-                persistent, snapshot -> {
-            assertEquals("getElectionVotedFor", persistenceId, snapshot.getElectionVotedFor());
-            assertEquals("getElectionTerm", 1, snapshot.getElectionTerm());
-            assertEquals("getServerConfiguration", new HashSet<>(expectedServerConfig.getServerConfig()),
-                    new HashSet<>(snapshot.getServerConfiguration().getServerConfig()));
-        });
+            persistent, snapshot -> {
+                assertEquals("getElectionVotedFor", persistenceId, snapshot.getElectionVotedFor());
+                assertEquals("getElectionTerm", 1, snapshot.getElectionTerm());
+                assertEquals("getServerConfiguration", new HashSet<>(expectedServerConfig.getServerConfig()),
+                        new HashSet<>(snapshot.getServerConfiguration().getServerConfig()));
+            });
 
         return actor;
     }
 
 
         return actor;
     }
 
-
+    @SuppressWarnings("checkstyle:IllegalCatch")
     private TestActorRef<MockRaftActor> doTestSnapshotAfterStartupWithMigratedMessage(String id, boolean persistent,
             Consumer<Snapshot> snapshotVerifier) {
         InMemorySnapshotStore.addSnapshotSavedLatch(id);
     private TestActorRef<MockRaftActor> doTestSnapshotAfterStartupWithMigratedMessage(String id, boolean persistent,
             Consumer<Snapshot> snapshotVerifier) {
         InMemorySnapshotStore.addSnapshotSavedLatch(id);
@@ -222,9 +223,9 @@ public class MigratedMessagesTest extends AbstractActorTest {
             }
         };
 
             }
         };
 
-        TestActorRef<MockRaftActor> raftActorRef = factory.createTestActor(MockRaftActor.builder().id(id).
-                config(config).snapshotCohort(snapshotCohort).persistent(Optional.of(persistent)).props().
-                    withDispatcher(Dispatchers.DefaultDispatcherId()), id);
+        TestActorRef<MockRaftActor> raftActorRef = factory.createTestActor(MockRaftActor.builder().id(id)
+                .config(config).snapshotCohort(snapshotCohort).persistent(Optional.of(persistent)).props()
+                    .withDispatcher(Dispatchers.DefaultDispatcherId()), id);
         MockRaftActor mockRaftActor = raftActorRef.underlyingActor();
 
         mockRaftActor.waitForRecoveryComplete();
         MockRaftActor mockRaftActor = raftActorRef.underlyingActor();
 
         mockRaftActor.waitForRecoveryComplete();
index 88865d5..b4b558b 100644 (file)
@@ -10,10 +10,12 @@ package org.opendaylight.controller.cluster.raft;
 
 import static org.junit.Assert.assertEquals;
 import static org.mockito.Mockito.mock;
 
 import static org.junit.Assert.assertEquals;
 import static org.mockito.Mockito.mock;
+
 import akka.actor.ActorRef;
 import akka.actor.Props;
 import com.google.common.base.Function;
 import com.google.common.base.Optional;
 import akka.actor.ActorRef;
 import akka.actor.Props;
 import com.google.common.base.Function;
 import com.google.common.base.Optional;
+import com.google.common.base.Throwables;
 import com.google.common.util.concurrent.Uninterruptibles;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import com.google.common.util.concurrent.Uninterruptibles;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
@@ -56,7 +58,7 @@ public class MockRaftActor extends RaftActor implements RaftActorRecoveryCohort,
         this.snapshotCohortDelegate = builder.snapshotCohort != null ? builder.snapshotCohort :
             mock(RaftActorSnapshotCohort.class);
 
         this.snapshotCohortDelegate = builder.snapshotCohort != null ? builder.snapshotCohort :
             mock(RaftActorSnapshotCohort.class);
 
-        if(builder.dataPersistenceProvider == null){
+        if (builder.dataPersistenceProvider == null) {
             setPersistence(builder.persistent.isPresent() ? builder.persistent.get() : true);
         } else {
             setPersistence(builder.dataPersistenceProvider);
             setPersistence(builder.persistent.isPresent() ? builder.persistent.get() : true);
         } else {
             setPersistence(builder.dataPersistenceProvider);
@@ -91,7 +93,7 @@ public class MockRaftActor extends RaftActor implements RaftActorRecoveryCohort,
         try {
             assertEquals("Recovery complete", true, recoveryComplete.await(5,  TimeUnit.SECONDS));
         } catch (InterruptedException e) {
         try {
             assertEquals("Recovery complete", true, recoveryComplete.await(5,  TimeUnit.SECONDS));
         } catch (InterruptedException e) {
-            e.printStackTrace();
+            Throwables.propagate(e);
         }
     }
 
         }
     }
 
@@ -99,14 +101,14 @@ public class MockRaftActor extends RaftActor implements RaftActorRecoveryCohort,
         try {
             assertEquals("Behavior initialized", true, initializeBehaviorComplete.await(5,  TimeUnit.SECONDS));
         } catch (InterruptedException e) {
         try {
             assertEquals("Behavior initialized", true, initializeBehaviorComplete.await(5,  TimeUnit.SECONDS));
         } catch (InterruptedException e) {
-            e.printStackTrace();
+            Throwables.propagate(e);
         }
     }
 
 
         }
     }
 
 
-    public void waitUntilLeader(){
-        for(int i = 0;i < 10; i++){
-            if(isLeader()){
+    public void waitUntilLeader() {
+        for (int i = 0; i < 10; i++) {
+            if (isLeader()) {
                 break;
             }
             Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
                 break;
             }
             Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
@@ -168,14 +170,18 @@ public class MockRaftActor extends RaftActor implements RaftActorRecoveryCohort,
     }
 
     private void applySnapshotBytes(byte[] bytes) {
     }
 
     private void applySnapshotBytes(byte[] bytes) {
+        if (bytes.length == 0) {
+            return;
+        }
+
         try {
             Object data = toObject(bytes);
             if (data instanceof List) {
                 state.clear();
                 state.addAll((List<?>) data);
             }
         try {
             Object data = toObject(bytes);
             if (data instanceof List) {
                 state.clear();
                 state.addAll((List<?>) data);
             }
-        } catch (Exception e) {
-            e.printStackTrace();
+        } catch (ClassNotFoundException | IOException e) {
+            Throwables.propagate(e);
         }
     }
 
         }
     }
 
@@ -212,12 +218,12 @@ public class MockRaftActor extends RaftActor implements RaftActorRecoveryCohort,
 
     @Override
     protected void handleCommand(final Object message) {
 
     @Override
     protected void handleCommand(final Object message) {
-        if(message instanceof RaftActorBehavior) {
+        if (message instanceof RaftActorBehavior) {
             super.changeCurrentBehavior((RaftActorBehavior)message);
         } else {
             super.handleCommand(message);
 
             super.changeCurrentBehavior((RaftActorBehavior)message);
         } else {
             super.handleCommand(message);
 
-            if(RaftActorSnapshotMessageSupport.COMMIT_SNAPSHOT.equals(message)) {
+            if (RaftActorSnapshotMessageSupport.COMMIT_SNAPSHOT.equals(message)) {
                 snapshotCommitted.countDown();
             }
         }
                 snapshotCommitted.countDown();
             }
         }
@@ -225,7 +231,7 @@ public class MockRaftActor extends RaftActor implements RaftActorRecoveryCohort,
 
     @Override
     protected void pauseLeader(Runnable operation) {
 
     @Override
     protected void pauseLeader(Runnable operation) {
-        if(pauseLeaderFunction != null) {
+        if (pauseLeaderFunction != null) {
             pauseLeaderFunction.apply(operation);
         } else {
             super.pauseLeader(operation);
             pauseLeaderFunction.apply(operation);
         } else {
             super.pauseLeader(operation);
@@ -251,7 +257,7 @@ public class MockRaftActor extends RaftActor implements RaftActorRecoveryCohort,
         return obj;
     }
 
         return obj;
     }
 
-    public ReplicatedLog getReplicatedLog(){
+    public ReplicatedLog getReplicatedLog() {
         return this.getRaftActorContext().getReplicatedLog();
     }
 
         return this.getRaftActorContext().getReplicatedLog();
     }
 
@@ -260,15 +266,14 @@ public class MockRaftActor extends RaftActor implements RaftActorRecoveryCohort,
         return restoreFromSnapshot;
     }
 
         return restoreFromSnapshot;
     }
 
-    public static Props props(final String id, final Map<String, String> peerAddresses,
-            ConfigParams config){
+    public static Props props(final String id, final Map<String, String> peerAddresses, ConfigParams config) {
         return builder().id(id).peerAddresses(peerAddresses).config(config).props();
     }
 
     public static Props props(final String id, final Map<String, String> peerAddresses,
         return builder().id(id).peerAddresses(peerAddresses).config(config).props();
     }
 
     public static Props props(final String id, final Map<String, String> peerAddresses,
-                              ConfigParams config, DataPersistenceProvider dataPersistenceProvider){
-        return builder().id(id).peerAddresses(peerAddresses).config(config).
-                dataPersistenceProvider(dataPersistenceProvider).props();
+                              ConfigParams config, DataPersistenceProvider dataPersistenceProvider) {
+        return builder().id(id).peerAddresses(peerAddresses).config(config)
+                .dataPersistenceProvider(dataPersistenceProvider).props();
     }
 
     public static Builder builder() {
     }
 
     public static Builder builder() {
@@ -297,53 +302,53 @@ public class MockRaftActor extends RaftActor implements RaftActorRecoveryCohort,
             return (T) this;
         }
 
             return (T) this;
         }
 
-        public T id(String id) {
-            this.id = id;
+        public T id(String newId) {
+            this.id = newId;
             return self();
         }
 
             return self();
         }
 
-        public T peerAddresses(Map<String, String> peerAddresses) {
-            this.peerAddresses = peerAddresses;
+        public T peerAddresses(Map<String, String> newPeerAddresses) {
+            this.peerAddresses = newPeerAddresses;
             return self();
         }
 
             return self();
         }
 
-        public T config(ConfigParams config) {
-            this.config = config;
+        public T config(ConfigParams newConfig) {
+            this.config = newConfig;
             return self();
         }
 
             return self();
         }
 
-        public T dataPersistenceProvider(DataPersistenceProvider dataPersistenceProvider) {
-            this.dataPersistenceProvider = dataPersistenceProvider;
+        public T dataPersistenceProvider(DataPersistenceProvider newDataPersistenceProvider) {
+            this.dataPersistenceProvider = newDataPersistenceProvider;
             return self();
         }
 
             return self();
         }
 
-        public T roleChangeNotifier(ActorRef roleChangeNotifier) {
-            this.roleChangeNotifier = roleChangeNotifier;
+        public T roleChangeNotifier(ActorRef newRoleChangeNotifier) {
+            this.roleChangeNotifier = newRoleChangeNotifier;
             return self();
         }
 
             return self();
         }
 
-        public T snapshotMessageSupport(RaftActorSnapshotMessageSupport snapshotMessageSupport) {
-            this.snapshotMessageSupport = snapshotMessageSupport;
+        public T snapshotMessageSupport(RaftActorSnapshotMessageSupport newSnapshotMessageSupport) {
+            this.snapshotMessageSupport = newSnapshotMessageSupport;
             return self();
         }
 
             return self();
         }
 
-        public T restoreFromSnapshot(byte[] restoreFromSnapshot) {
-            this.restoreFromSnapshot = restoreFromSnapshot;
+        public T restoreFromSnapshot(byte[] newRestoreFromSnapshot) {
+            this.restoreFromSnapshot = newRestoreFromSnapshot;
             return self();
         }
 
             return self();
         }
 
-        public T persistent(Optional<Boolean> persistent) {
-            this.persistent = persistent;
+        public T persistent(Optional<Boolean> newPersistent) {
+            this.persistent = newPersistent;
             return self();
         }
 
             return self();
         }
 
-        public T pauseLeaderFunction(Function<Runnable, Void> pauseLeaderFunction) {
-            this.pauseLeaderFunction = pauseLeaderFunction;
+        public T pauseLeaderFunction(Function<Runnable, Void> newPauseLeaderFunction) {
+            this.pauseLeaderFunction = newPauseLeaderFunction;
             return self();
         }
 
             return self();
         }
 
-        public T snapshotCohort(RaftActorSnapshotCohort snapshotCohort) {
-            this.snapshotCohort = snapshotCohort;
+        public T snapshotCohort(RaftActorSnapshotCohort newSnapshotCohort) {
+            this.snapshotCohort = newSnapshotCohort;
             return self();
         }
 
             return self();
         }
 
index 32d3ae6..95764ad 100644 (file)
@@ -13,6 +13,7 @@ import akka.actor.ActorSelection;
 import akka.actor.ActorSystem;
 import akka.actor.Props;
 import akka.japi.Procedure;
 import akka.actor.ActorSystem;
 import akka.actor.Props;
 import akka.japi.Procedure;
+import com.google.common.base.Throwables;
 import java.io.Serializable;
 import java.util.HashMap;
 import java.util.Map;
 import java.io.Serializable;
 import java.util.HashMap;
 import java.util.Map;
@@ -45,27 +46,26 @@ public class MockRaftActorContext extends RaftActorContextImpl {
             }
 
             @Override
             }
 
             @Override
-            public void update(long currentTerm, String votedFor){
-                this.currentTerm = currentTerm;
-                this.votedFor = votedFor;
+            public void update(long newTerm, String newVotedFor) {
+                this.currentTerm = newTerm;
+                this.votedFor = newVotedFor;
 
                 // TODO : Write to some persistent state
             }
 
 
                 // TODO : Write to some persistent state
             }
 
-            @Override public void updateAndPersist(long currentTerm,
-                String votedFor) {
-                update(currentTerm, votedFor);
+            @Override public void updateAndPersist(long newTerm, String newVotedFor) {
+                update(newTerm, newVotedFor);
             }
         };
     }
 
             }
         };
     }
 
-    public MockRaftActorContext(){
+    public MockRaftActorContext() {
         super(null, null, "test", newElectionTerm(), -1, -1, new HashMap<>(),
                 new DefaultConfigParamsImpl(), new NonPersistentDataProvider(), LOG);
         setReplicatedLog(new MockReplicatedLogBuilder().build());
     }
 
         super(null, null, "test", newElectionTerm(), -1, -1, new HashMap<>(),
                 new DefaultConfigParamsImpl(), new NonPersistentDataProvider(), LOG);
         setReplicatedLog(new MockReplicatedLogBuilder().build());
     }
 
-    public MockRaftActorContext(String id, ActorSystem system, ActorRef actor){
+    public MockRaftActorContext(String id, ActorSystem system, ActorRef actor) {
         super(actor, null, id, newElectionTerm(), -1, -1, new HashMap<>(),
                 new DefaultConfigParamsImpl(), new NonPersistentDataProvider(), LOG);
 
         super(actor, null, id, newElectionTerm(), -1, -1, new HashMap<>(),
                 new DefaultConfigParamsImpl(), new NonPersistentDataProvider(), LOG);
 
@@ -75,7 +75,7 @@ public class MockRaftActorContext extends RaftActorContextImpl {
     }
 
 
     }
 
 
-    public void initReplicatedLog(){
+    public void initReplicatedLog() {
         SimpleReplicatedLog replicatedLog = new SimpleReplicatedLog();
         long term = getTermInformation().getCurrentTerm();
         replicatedLog.append(new MockReplicatedLogEntry(term, 0, new MockPayload("1")));
         SimpleReplicatedLog replicatedLog = new SimpleReplicatedLog();
         long term = getTermInformation().getCurrentTerm();
         replicatedLog.append(new MockReplicatedLogEntry(term, 0, new MockPayload("1")));
@@ -99,18 +99,18 @@ public class MockRaftActorContext extends RaftActorContextImpl {
 
     @Override public ActorSelection getPeerActorSelection(String peerId) {
         String peerAddress = getPeerAddress(peerId);
 
     @Override public ActorSelection getPeerActorSelection(String peerId) {
         String peerAddress = getPeerAddress(peerId);
-        if(peerAddress != null){
+        if (peerAddress != null) {
             return actorSelection(peerAddress);
         }
         return null;
     }
 
     public void setPeerAddresses(Map<String, String> peerAddresses) {
             return actorSelection(peerAddress);
         }
         return null;
     }
 
     public void setPeerAddresses(Map<String, String> peerAddresses) {
-        for(String id: getPeerIds()) {
+        for (String id: getPeerIds()) {
             removePeer(id);
         }
 
             removePeer(id);
         }
 
-        for(Map.Entry<String, String> e: peerAddresses.entrySet()) {
+        for (Map.Entry<String, String> e: peerAddresses.entrySet()) {
             addToPeers(e.getKey(), e.getValue(), VotingState.VOTING);
         }
     }
             addToPeers(e.getKey(), e.getValue(), VotingState.VOTING);
         }
     }
@@ -132,12 +132,6 @@ public class MockRaftActorContext extends RaftActorContextImpl {
     }
 
     public static class SimpleReplicatedLog extends AbstractReplicatedLogImpl {
     }
 
     public static class SimpleReplicatedLog extends AbstractReplicatedLogImpl {
-        @Override
-        public void appendAndPersist(
-            ReplicatedLogEntry replicatedLogEntry) {
-            append(replicatedLogEntry);
-        }
-
         @Override
         public int dataSize() {
             return -1;
         @Override
         public int dataSize() {
             return -1;
@@ -153,14 +147,21 @@ public class MockRaftActorContext extends RaftActorContextImpl {
         }
 
         @Override
         }
 
         @Override
+        public void appendAndPersist(
+            ReplicatedLogEntry replicatedLogEntry) {
+            append(replicatedLogEntry);
+        }
+
+        @Override
+        @SuppressWarnings("checkstyle:IllegalCatch")
         public void appendAndPersist(ReplicatedLogEntry replicatedLogEntry, Procedure<ReplicatedLogEntry> callback) {
             append(replicatedLogEntry);
 
         public void appendAndPersist(ReplicatedLogEntry replicatedLogEntry, Procedure<ReplicatedLogEntry> callback) {
             append(replicatedLogEntry);
 
-            if(callback != null) {
+            if (callback != null) {
                 try {
                     callback.apply(replicatedLogEntry);
                 } catch (Exception e) {
                 try {
                     callback.apply(replicatedLogEntry);
                 } catch (Exception e) {
-                    e.printStackTrace();
+                    Throwables.propagate(e);
                 }
             }
         }
                 }
             }
         }
@@ -174,13 +175,13 @@ public class MockRaftActorContext extends RaftActorContextImpl {
         public MockPayload() {
         }
 
         public MockPayload() {
         }
 
-        public MockPayload(String s) {
-            this.value = s;
+        public MockPayload(String data) {
+            this.value = data;
             size = value.length();
         }
 
             size = value.length();
         }
 
-        public MockPayload(String s, int size) {
-            this(s);
+        public MockPayload(String data, int size) {
+            this(data);
             this.size = size;
         }
 
             this.size = size;
         }
 
@@ -198,7 +199,7 @@ public class MockRaftActorContext extends RaftActorContextImpl {
         public int hashCode() {
             final int prime = 31;
             int result = 1;
         public int hashCode() {
             final int prime = 31;
             int result = 1;
-            result = prime * result + ((value == null) ? 0 : value.hashCode());
+            result = prime * result + (value == null ? 0 : value.hashCode());
             return result;
         }
 
             return result;
         }
 
@@ -232,7 +233,7 @@ public class MockRaftActorContext extends RaftActorContextImpl {
         private final long index;
         private final Payload data;
 
         private final long index;
         private final Payload data;
 
-        public MockReplicatedLogEntry(long term, long index, Payload data){
+        public MockReplicatedLogEntry(long term, long index, Payload data) {
 
             this.term = term;
             this.index = index;
 
             this.term = term;
             this.index = index;
@@ -260,9 +261,9 @@ public class MockRaftActorContext extends RaftActorContextImpl {
         public int hashCode() {
             final int prime = 31;
             int result = 1;
         public int hashCode() {
             final int prime = 31;
             int result = 1;
-            result = prime * result + ((data == null) ? 0 : data.hashCode());
-            result = prime * result + (int) (index ^ (index >>> 32));
-            result = prime * result + (int) (term ^ (term >>> 32));
+            result = prime * result + (data == null ? 0 : data.hashCode());
+            result = prime * result + (int) (index ^ index >>> 32);
+            result = prime * result + (int) (term ^ term >>> 32);
             return result;
         }
 
             return result;
         }
 
@@ -307,8 +308,9 @@ public class MockRaftActorContext extends RaftActorContextImpl {
         private final ReplicatedLog mockLog = new SimpleReplicatedLog();
 
         public  MockReplicatedLogBuilder createEntries(int start, int end, int term) {
         private final ReplicatedLog mockLog = new SimpleReplicatedLog();
 
         public  MockReplicatedLogBuilder createEntries(int start, int end, int term) {
-            for (int i=start; i<end; i++) {
-                this.mockLog.append(new ReplicatedLogImplEntry(i, term, new MockRaftActorContext.MockPayload(Integer.toString(i))));
+            for (int i = start; i < end; i++) {
+                this.mockLog.append(new ReplicatedLogImplEntry(i, term,
+                        new MockRaftActorContext.MockPayload(Integer.toString(i))));
             }
             return this;
         }
             }
             return this;
         }
index 7bf22b4..7db9d4c 100644 (file)
@@ -8,6 +8,9 @@
 package org.opendaylight.controller.cluster.raft;
 
 import static org.junit.Assert.assertEquals;
 package org.opendaylight.controller.cluster.raft;
 
 import static org.junit.Assert.assertEquals;
+
+import akka.actor.ActorRef;
+import akka.dispatch.Dispatchers;
 import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Sets;
 import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Sets;
@@ -26,8 +29,6 @@ import org.opendaylight.controller.cluster.raft.persisted.UpdateElectionTerm;
 import org.opendaylight.controller.cluster.raft.policy.DisableElectionsRaftPolicy;
 import org.opendaylight.controller.cluster.raft.utils.InMemoryJournal;
 import org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor;
 import org.opendaylight.controller.cluster.raft.policy.DisableElectionsRaftPolicy;
 import org.opendaylight.controller.cluster.raft.utils.InMemoryJournal;
 import org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor;
-import akka.actor.ActorRef;
-import akka.dispatch.Dispatchers;
 import scala.concurrent.duration.FiniteDuration;
 
 /**
 import scala.concurrent.duration.FiniteDuration;
 
 /**
@@ -304,8 +305,8 @@ public class NonVotingFollowerIntegrationTest extends AbstractRaftActorIntegrati
         DefaultConfigParamsImpl follower2ConfigParams = newFollowerConfigParams();
         follower2ConfigParams.setCustomRaftPolicyImplementationClass(DisableElectionsRaftPolicy.class.getName());
         follower2Actor = newTestRaftActor(follower2Id, TestRaftActor.newBuilder().peerAddresses(
         DefaultConfigParamsImpl follower2ConfigParams = newFollowerConfigParams();
         follower2ConfigParams.setCustomRaftPolicyImplementationClass(DisableElectionsRaftPolicy.class.getName());
         follower2Actor = newTestRaftActor(follower2Id, TestRaftActor.newBuilder().peerAddresses(
-                ImmutableMap.of(leaderId, testActorPath(leaderId), follower1Id, follower1Actor.path().toString())).
-                    config(follower2ConfigParams).persistent(Optional.of(false)));
+                ImmutableMap.of(leaderId, testActorPath(leaderId), follower1Id, follower1Actor.path().toString()))
+                    .config(follower2ConfigParams).persistent(Optional.of(false)));
         TestRaftActor follower2Instance = follower2Actor.underlyingActor();
         follower2Instance.waitForRecoveryComplete();
         follower2CollectorActor = follower2Instance.collectorActor();
         TestRaftActor follower2Instance = follower2Actor.underlyingActor();
         follower2Instance.waitForRecoveryComplete();
         follower2CollectorActor = follower2Instance.collectorActor();
@@ -364,8 +365,8 @@ public class NonVotingFollowerIntegrationTest extends AbstractRaftActorIntegrati
         setupLeaderAndNonVotingFollower();
 
         ((DefaultConfigParamsImpl)follower1Context.getConfigParams()).setElectionTimeoutFactor(2);
         setupLeaderAndNonVotingFollower();
 
         ((DefaultConfigParamsImpl)follower1Context.getConfigParams()).setElectionTimeoutFactor(2);
-        ((DefaultConfigParamsImpl)follower1Context.getConfigParams()).
-                setHeartBeatInterval(FiniteDuration.apply(100, TimeUnit.MILLISECONDS));
+        ((DefaultConfigParamsImpl)follower1Context.getConfigParams())
+                .setHeartBeatInterval(FiniteDuration.apply(100, TimeUnit.MILLISECONDS));
 
         MessageCollectorActor.clearMessages(roleChangeNotifier);
         follower1Actor.tell(ElectionTimeout.INSTANCE, ActorRef.noSender());
 
         MessageCollectorActor.clearMessages(roleChangeNotifier);
         follower1Actor.tell(ElectionTimeout.INSTANCE, ActorRef.noSender());
@@ -385,8 +386,8 @@ public class NonVotingFollowerIntegrationTest extends AbstractRaftActorIntegrati
 
     private void createNewLeaderActor() {
         expSnapshotState.clear();
 
     private void createNewLeaderActor() {
         expSnapshotState.clear();
-        leaderActor = newTestRaftActor(leaderId, TestRaftActor.newBuilder().peerAddresses(peerAddresses).
-                config(leaderConfigParams).persistent(Optional.of(false)));
+        leaderActor = newTestRaftActor(leaderId, TestRaftActor.newBuilder().peerAddresses(peerAddresses)
+                .config(leaderConfigParams).persistent(Optional.of(false)));
         leaderInstance = leaderActor.underlyingActor();
         leaderCollectorActor = leaderInstance.collectorActor();
         waitUntilLeader(leaderActor);
         leaderInstance = leaderActor.underlyingActor();
         leaderCollectorActor = leaderInstance.collectorActor();
         waitUntilLeader(leaderActor);
@@ -395,31 +396,31 @@ public class NonVotingFollowerIntegrationTest extends AbstractRaftActorIntegrati
 
     private void setupLeaderAndNonVotingFollower() {
         snapshotBatchCount = 100;
 
     private void setupLeaderAndNonVotingFollower() {
         snapshotBatchCount = 100;
-        int initialTerm = 1;
+        int persistedTerm = 1;
 
         // Set up a persisted ServerConfigurationPayload with the leader voting and the follower non-voting.
 
         ServerConfigurationPayload persistedServerConfig = new ServerConfigurationPayload(Arrays.asList(
                 new ServerInfo(leaderId, true), new ServerInfo(follower1Id, false)));
 
         // Set up a persisted ServerConfigurationPayload with the leader voting and the follower non-voting.
 
         ServerConfigurationPayload persistedServerConfig = new ServerConfigurationPayload(Arrays.asList(
                 new ServerInfo(leaderId, true), new ServerInfo(follower1Id, false)));
-        ReplicatedLogImplEntry persistedServerConfigEntry = new ReplicatedLogImplEntry(0, initialTerm,
+        ReplicatedLogImplEntry persistedServerConfigEntry = new ReplicatedLogImplEntry(0, persistedTerm,
                 persistedServerConfig);
 
                 persistedServerConfig);
 
-        InMemoryJournal.addEntry(leaderId, 1, new UpdateElectionTerm(initialTerm, leaderId));
+        InMemoryJournal.addEntry(leaderId, 1, new UpdateElectionTerm(persistedTerm, leaderId));
         InMemoryJournal.addEntry(leaderId, 2, persistedServerConfigEntry);
         InMemoryJournal.addEntry(leaderId, 2, persistedServerConfigEntry);
-        InMemoryJournal.addEntry(follower1Id, 1, new UpdateElectionTerm(initialTerm, leaderId));
+        InMemoryJournal.addEntry(follower1Id, 1, new UpdateElectionTerm(persistedTerm, leaderId));
         InMemoryJournal.addEntry(follower1Id, 2, persistedServerConfigEntry);
 
         DefaultConfigParamsImpl followerConfigParams = newFollowerConfigParams();
         follower1Actor = newTestRaftActor(follower1Id, follower1Builder.peerAddresses(
         InMemoryJournal.addEntry(follower1Id, 2, persistedServerConfigEntry);
 
         DefaultConfigParamsImpl followerConfigParams = newFollowerConfigParams();
         follower1Actor = newTestRaftActor(follower1Id, follower1Builder.peerAddresses(
-                ImmutableMap.of(leaderId, testActorPath(leaderId))).config(followerConfigParams).
-                    persistent(Optional.of(false)));
+                ImmutableMap.of(leaderId, testActorPath(leaderId))).config(followerConfigParams)
+                    .persistent(Optional.of(false)));
 
 
-        peerAddresses = ImmutableMap.<String, String>builder().
-                put(follower1Id, follower1Actor.path().toString()).build();
+        peerAddresses = ImmutableMap.<String, String>builder()
+                .put(follower1Id, follower1Actor.path().toString()).build();
 
         leaderConfigParams = newLeaderConfigParams();
 
         leaderConfigParams = newLeaderConfigParams();
-        leaderActor = newTestRaftActor(leaderId, TestRaftActor.newBuilder().peerAddresses(peerAddresses).
-                config(leaderConfigParams).persistent(Optional.of(false)));
+        leaderActor = newTestRaftActor(leaderId, TestRaftActor.newBuilder().peerAddresses(peerAddresses)
+                .config(leaderConfigParams).persistent(Optional.of(false)));
 
         followerInstance = follower1Actor.underlyingActor();
         follower1CollectorActor = followerInstance.collectorActor();
 
         followerInstance = follower1Actor.underlyingActor();
         follower1CollectorActor = followerInstance.collectorActor();
@@ -434,7 +435,7 @@ public class NonVotingFollowerIntegrationTest extends AbstractRaftActorIntegrati
 
         // Verify leader's context after startup
 
 
         // Verify leader's context after startup
 
-        currentTerm = initialTerm + 1;
+        currentTerm = persistedTerm + 1;
         assertEquals("Leader term", currentTerm, leaderContext.getTermInformation().getCurrentTerm());
         assertEquals("Leader server config", Sets.newHashSet(persistedServerConfig.getServerConfig()),
                 Sets.newHashSet(leaderContext.getPeerServerInfo(true).getServerConfig()));
         assertEquals("Leader term", currentTerm, leaderContext.getTermInformation().getCurrentTerm());
         assertEquals("Leader server config", Sets.newHashSet(persistedServerConfig.getServerConfig()),
                 Sets.newHashSet(leaderContext.getPeerServerInfo(true).getServerConfig()));
index d451ea1..a1ada53 100644 (file)
@@ -11,6 +11,7 @@ import static org.junit.Assert.assertEquals;
 import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.clearMessages;
 import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.expectFirstMatching;
 import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.expectMatching;
 import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.clearMessages;
 import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.expectFirstMatching;
 import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.expectMatching;
+
 import akka.actor.Actor;
 import akka.actor.ActorRef;
 import akka.actor.Props;
 import akka.actor.Actor;
 import akka.actor.ActorRef;
 import akka.actor.Props;
@@ -81,7 +82,7 @@ public class PreLeaderScenarioTest extends AbstractRaftActorIntegrationTest {
         assertEquals("Role change 2", RaftState.PreLeader.name(), roleChange.get(1).getNewRole());
         assertEquals("Role change 3", RaftState.Leader.name(), roleChange.get(2).getNewRole());
 
         assertEquals("Role change 2", RaftState.PreLeader.name(), roleChange.get(1).getNewRole());
         assertEquals("Role change 3", RaftState.Leader.name(), roleChange.get(2).getNewRole());
 
-        long previousTerm = currentTerm;
+        final long previousTerm = currentTerm;
         currentTerm = follower1Context.getTermInformation().getCurrentTerm();
 
         // Since it went to Leader, it should've appended and successfully replicated a NoopPaylod with the
         currentTerm = follower1Context.getTermInformation().getCurrentTerm();
 
         // Since it went to Leader, it should've appended and successfully replicated a NoopPaylod with the
@@ -110,8 +111,8 @@ public class PreLeaderScenarioTest extends AbstractRaftActorIntegrationTest {
         killActor(follower1Actor);
 
         follower1Actor = newTestRaftActor(follower1Id, TestRaftActor.newBuilder().peerAddresses(
         killActor(follower1Actor);
 
         follower1Actor = newTestRaftActor(follower1Id, TestRaftActor.newBuilder().peerAddresses(
-                ImmutableMap.of(leaderId, testActorPath(leaderId), follower2Id, testActorPath(follower2Id))).
-                config(followerConfigParams));
+                ImmutableMap.of(leaderId, testActorPath(leaderId), follower2Id, testActorPath(follower2Id)))
+                .config(followerConfigParams));
         follower1Actor.underlyingActor().waitForRecoveryComplete();
         follower1Context = follower1Actor.underlyingActor().getRaftActorContext();
 
         follower1Actor.underlyingActor().waitForRecoveryComplete();
         follower1Context = follower1Actor.underlyingActor().getRaftActorContext();
 
@@ -136,15 +137,15 @@ public class PreLeaderScenarioTest extends AbstractRaftActorIntegrationTest {
         followerConfigParams.setHeartBeatInterval(new FiniteDuration(100, TimeUnit.MILLISECONDS));
         followerConfigParams.setSnapshotBatchCount(snapshotBatchCount);
         follower1Actor = newTestRaftActor(follower1Id, TestRaftActor.newBuilder().peerAddresses(
         followerConfigParams.setHeartBeatInterval(new FiniteDuration(100, TimeUnit.MILLISECONDS));
         followerConfigParams.setSnapshotBatchCount(snapshotBatchCount);
         follower1Actor = newTestRaftActor(follower1Id, TestRaftActor.newBuilder().peerAddresses(
-                ImmutableMap.of(leaderId, testActorPath(leaderId), follower2Id, testActorPath(follower2Id))).
-                config(followerConfigParams).roleChangeNotifier(follower1NotifierActor));
+                ImmutableMap.of(leaderId, testActorPath(leaderId), follower2Id, testActorPath(follower2Id)))
+                .config(followerConfigParams).roleChangeNotifier(follower1NotifierActor));
 
         follower2Actor = newTestRaftActor(follower2Id, ImmutableMap.of(leaderId, testActorPath(leaderId),
                 follower1Id, testActorPath(follower1Id)), followerConfigParams);
 
 
         follower2Actor = newTestRaftActor(follower2Id, ImmutableMap.of(leaderId, testActorPath(leaderId),
                 follower1Id, testActorPath(follower1Id)), followerConfigParams);
 
-        peerAddresses = ImmutableMap.<String, String>builder().
-                put(follower1Id, follower1Actor.path().toString()).
-                put(follower2Id, follower2Actor.path().toString()).build();
+        peerAddresses = ImmutableMap.<String, String>builder()
+                .put(follower1Id, follower1Actor.path().toString())
+                .put(follower2Id, follower2Actor.path().toString()).build();
 
         leaderConfigParams = newLeaderConfigParams();
         leaderConfigParams.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
 
         leaderConfigParams = newLeaderConfigParams();
         leaderConfigParams.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
index e957551..874a17c 100644 (file)
@@ -16,6 +16,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.reset;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.reset;
 import static org.mockito.Mockito.verify;
+
 import akka.actor.Props;
 import akka.testkit.TestActorRef;
 import com.google.common.collect.ImmutableMap;
 import akka.actor.Props;
 import akka.testkit.TestActorRef;
 import com.google.common.collect.ImmutableMap;
@@ -121,10 +122,10 @@ public class RaftActorContextImplTest extends AbstractActorTest {
 
     private static void verifyPeerInfo(RaftActorContextImpl context, String peerId, Boolean voting) {
         PeerInfo peerInfo = context.getPeerInfo(peerId);
 
     private static void verifyPeerInfo(RaftActorContextImpl context, String peerId, Boolean voting) {
         PeerInfo peerInfo = context.getPeerInfo(peerId);
-        if(voting != null) {
+        if (voting != null) {
             assertNotNull("Expected peer " + peerId, peerInfo);
             assertNotNull("Expected peer " + peerId, peerInfo);
-            assertEquals("getVotingState for " + peerId, voting.booleanValue() ? VotingState.VOTING : VotingState.NON_VOTING,
-                    peerInfo.getVotingState());
+            assertEquals("getVotingState for " + peerId, voting.booleanValue()
+                    ? VotingState.VOTING : VotingState.NON_VOTING, peerInfo.getVotingState());
         } else {
             assertNull("Unexpected peer " + peerId, peerInfo);
         }
         } else {
             assertNull("Unexpected peer " + peerId, peerInfo);
         }
index c4a21d9..287d86c 100644 (file)
@@ -9,8 +9,9 @@ package org.opendaylight.controller.cluster.raft;
 
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.doReturn;
 
 import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+
 import akka.japi.Procedure;
 import org.junit.Before;
 import org.junit.Test;
 import akka.japi.Procedure;
 import org.junit.Before;
 import org.junit.Test;
index 754e3e4..ed96159 100644 (file)
@@ -11,6 +11,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.timeout;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.timeout;
 import static org.mockito.Mockito.verify;
+
 import akka.dispatch.Dispatchers;
 import com.google.common.base.Function;
 import org.junit.After;
 import akka.dispatch.Dispatchers;
 import com.google.common.base.Function;
 import org.junit.After;
@@ -38,8 +39,8 @@ public class RaftActorLeadershipTransferCohortTest extends AbstractActorTest {
 
     private void setup(String testName) {
         String persistenceId = factory.generateActorId(testName + "-leader-");
 
     private void setup(String testName) {
         String persistenceId = factory.generateActorId(testName + "-leader-");
-        mockRaftActor = factory.<MockRaftActor>createTestActor(MockRaftActor.builder().id(persistenceId).config(
-                config).pauseLeaderFunction(pauseLeaderFunction).props().withDispatcher(Dispatchers.DefaultDispatcherId()),
+        mockRaftActor = factory.<MockRaftActor>createTestActor(MockRaftActor.builder().id(persistenceId).config(config)
+                .pauseLeaderFunction(pauseLeaderFunction).props().withDispatcher(Dispatchers.DefaultDispatcherId()),
                 persistenceId).underlyingActor();
         cohort = new RaftActorLeadershipTransferCohort(mockRaftActor);
         cohort.addOnComplete(onComplete);
                 persistenceId).underlyingActor();
         cohort = new RaftActorLeadershipTransferCohort(mockRaftActor);
         cohort.addOnComplete(onComplete);
@@ -88,12 +89,7 @@ public class RaftActorLeadershipTransferCohortTest extends AbstractActorTest {
 
     @Test
     public void testPauseLeaderTimeout() {
 
     @Test
     public void testPauseLeaderTimeout() {
-        pauseLeaderFunction = new Function<Runnable, Void>() {
-            @Override
-            public Void apply(Runnable input) {
-                return null;
-            }
-        };
+        pauseLeaderFunction = input -> null;
 
         setup("testPauseLeaderTimeout");
         cohort.init();
 
         setup("testPauseLeaderTimeout");
         cohort.init();
index 3795103..6d5e7e7 100644 (file)
@@ -18,6 +18,7 @@ import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyNoMoreInteractions;
+
 import akka.persistence.RecoveryCompleted;
 import akka.persistence.SnapshotMetadata;
 import akka.persistence.SnapshotOffer;
 import akka.persistence.RecoveryCompleted;
 import akka.persistence.SnapshotMetadata;
 import akka.persistence.SnapshotOffer;
@@ -74,8 +75,8 @@ public class RaftActorRecoverySupportTest {
     public void setup() {
         MockitoAnnotations.initMocks(this);
 
     public void setup() {
         MockitoAnnotations.initMocks(this);
 
-        context = new RaftActorContextImpl(null, null, localId, new ElectionTermImpl(mockPersistentProvider, "test", LOG),
-                -1, -1, Collections.<String,String>emptyMap(), configParams, mockPersistence, LOG);
+        context = new RaftActorContextImpl(null, null, localId, new ElectionTermImpl(mockPersistentProvider, "test",
+                LOG), -1, -1, Collections.<String,String>emptyMap(), configParams, mockPersistence, LOG);
 
         support = new RaftActorRecoverySupport(context, mockCohort);
 
 
         support = new RaftActorRecoverySupport(context, mockCohort);
 
@@ -148,7 +149,7 @@ public class RaftActorRecoverySupportTest {
         InOrder inOrder = Mockito.inOrder(mockCohort);
         inOrder.verify(mockCohort).startLogRecoveryBatch(5);
 
         InOrder inOrder = Mockito.inOrder(mockCohort);
         inOrder.verify(mockCohort).startLogRecoveryBatch(5);
 
-        for(int i = 0; i < replicatedLog.size() - 1; i++) {
+        for (int i = 0; i < replicatedLog.size() - 1; i++) {
             inOrder.verify(mockCohort).appendRecoveredLogEntry(replicatedLog.get(i).getData());
         }
 
             inOrder.verify(mockCohort).appendRecoveredLogEntry(replicatedLog.get(i).getData());
         }
 
@@ -223,7 +224,7 @@ public class RaftActorRecoverySupportTest {
         InOrder inOrder = Mockito.inOrder(mockCohort);
         inOrder.verify(mockCohort).startLogRecoveryBatch(anyInt());
 
         InOrder inOrder = Mockito.inOrder(mockCohort);
         inOrder.verify(mockCohort).startLogRecoveryBatch(anyInt());
 
-        for(int i = 0; i < replicatedLog.size(); i++) {
+        for (int i = 0; i < replicatedLog.size(); i++) {
             inOrder.verify(mockCohort).appendRecoveredLogEntry(replicatedLog.get(i).getData());
         }
 
             inOrder.verify(mockCohort).appendRecoveredLogEntry(replicatedLog.get(i).getData());
         }
 
@@ -265,7 +266,6 @@ public class RaftActorRecoverySupportTest {
         assertEquals("Voted For", "member2", context.getTermInformation().getVotedFor());
     }
 
         assertEquals("Voted For", "member2", context.getTermInformation().getVotedFor());
     }
 
-    @SuppressWarnings("unchecked")
     @Test
     public void testDataRecoveredWithPersistenceDisabled() {
         doNothing().when(mockCohort).applyRecoverySnapshot(aryEq(new byte[0]));
     @Test
     public void testDataRecoveredWithPersistenceDisabled() {
         doNothing().when(mockCohort).applyRecoverySnapshot(aryEq(new byte[0]));
index cba4dd9..9c7322d 100644 (file)
@@ -14,6 +14,7 @@ import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorAct
 import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.clearMessages;
 import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.expectFirstMatching;
 import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.expectMatching;
 import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.clearMessages;
 import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.expectFirstMatching;
 import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor.expectMatching;
+
 import akka.actor.ActorRef;
 import akka.actor.Props;
 import akka.actor.UntypedActor;
 import akka.actor.ActorRef;
 import akka.actor.Props;
 import akka.actor.UntypedActor;
@@ -103,6 +104,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         InMemorySnapshotStore.clear();
     }
 
         InMemorySnapshotStore.clear();
     }
 
+    @SuppressWarnings("checkstyle:IllegalCatch")
     private void setupNewFollower() {
         DefaultConfigParamsImpl configParams = newFollowerConfigParams();
 
     private void setupNewFollower() {
         DefaultConfigParamsImpl configParams = newFollowerConfigParams();
 
@@ -157,7 +159,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         clearMessages(followerActor);
 
         MockLeaderRaftActor leaderRaftActor = leaderActor.underlyingActor();
         clearMessages(followerActor);
 
         MockLeaderRaftActor leaderRaftActor = leaderActor.underlyingActor();
-        TestActorRef<MessageCollectorActor> leaderCollectorActor = newLeaderCollectorActor(leaderRaftActor);
+        final TestActorRef<MessageCollectorActor> leaderCollectorActor = newLeaderCollectorActor(leaderRaftActor);
 
         leaderActor.tell(new AddServer(NEW_SERVER_ID, newFollowerRaftActor.path().toString(), true), testKit.getRef());
 
 
         leaderActor.tell(new AddServer(NEW_SERVER_ID, newFollowerRaftActor.path().toString(), true), testKit.getRef());
 
@@ -198,7 +200,8 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
 
         assertEquals("Follower peers", Sets.newHashSet(LEADER_ID, NEW_SERVER_ID), followerActorContext.getPeerIds());
 
 
         assertEquals("Follower peers", Sets.newHashSet(LEADER_ID, NEW_SERVER_ID), followerActorContext.getPeerIds());
 
-        assertEquals("New follower peers", Sets.newHashSet(LEADER_ID, FOLLOWER_ID), newFollowerActorContext.getPeerIds());
+        assertEquals("New follower peers", Sets.newHashSet(LEADER_ID, FOLLOWER_ID),
+                newFollowerActorContext.getPeerIds());
 
         expectFirstMatching(newFollowerCollectorActor, ApplyState.class);
         expectFirstMatching(followerActor, ApplyState.class);
 
         expectFirstMatching(newFollowerCollectorActor, ApplyState.class);
         expectFirstMatching(followerActor, ApplyState.class);
@@ -238,9 +241,9 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
                 actorFactory.generateActorId(LEADER_ID));
 
         MockLeaderRaftActor leaderRaftActor = leaderActor.underlyingActor();
                 actorFactory.generateActorId(LEADER_ID));
 
         MockLeaderRaftActor leaderRaftActor = leaderActor.underlyingActor();
-        RaftActorContext leaderActorContext = leaderRaftActor.getRaftActorContext();
+        final RaftActorContext leaderActorContext = leaderRaftActor.getRaftActorContext();
 
 
-        TestActorRef<MessageCollectorActor> leaderCollectorActor = newLeaderCollectorActor(leaderRaftActor);
+        final TestActorRef<MessageCollectorActor> leaderCollectorActor = newLeaderCollectorActor(leaderRaftActor);
 
         leaderActor.tell(new AddServer(NEW_SERVER_ID, newFollowerRaftActor.path().toString(), true), testKit.getRef());
 
 
         leaderActor.tell(new AddServer(NEW_SERVER_ID, newFollowerRaftActor.path().toString(), true), testKit.getRef());
 
@@ -291,9 +294,9 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
                 actorFactory.generateActorId(LEADER_ID));
 
         MockLeaderRaftActor leaderRaftActor = leaderActor.underlyingActor();
                 actorFactory.generateActorId(LEADER_ID));
 
         MockLeaderRaftActor leaderRaftActor = leaderActor.underlyingActor();
-        RaftActorContext leaderActorContext = leaderRaftActor.getRaftActorContext();
+        final RaftActorContext leaderActorContext = leaderRaftActor.getRaftActorContext();
 
 
-        TestActorRef<MessageCollectorActor> leaderCollectorActor = newLeaderCollectorActor(leaderRaftActor);
+        final TestActorRef<MessageCollectorActor> leaderCollectorActor = newLeaderCollectorActor(leaderRaftActor);
 
         leaderActor.tell(new AddServer(NEW_SERVER_ID, newFollowerRaftActor.path().toString(), false), testKit.getRef());
 
 
         leaderActor.tell(new AddServer(NEW_SERVER_ID, newFollowerRaftActor.path().toString(), false), testKit.getRef());
 
@@ -361,9 +364,9 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
                 actorFactory.generateActorId(LEADER_ID));
 
         MockLeaderRaftActor leaderRaftActor = leaderActor.underlyingActor();
                 actorFactory.generateActorId(LEADER_ID));
 
         MockLeaderRaftActor leaderRaftActor = leaderActor.underlyingActor();
-        RaftActorContext leaderActorContext = leaderRaftActor.getRaftActorContext();
+        final RaftActorContext leaderActorContext = leaderRaftActor.getRaftActorContext();
 
 
-        TestActorRef<MessageCollectorActor> leaderCollectorActor = newLeaderCollectorActor(leaderRaftActor);
+        final TestActorRef<MessageCollectorActor> leaderCollectorActor = newLeaderCollectorActor(leaderRaftActor);
 
         RaftActorContext follower2ActorContext = newFollowerContext(NEW_SERVER_ID2, followerActor);
         Follower newFollower2 = new Follower(follower2ActorContext);
 
         RaftActorContext follower2ActorContext = newFollowerContext(NEW_SERVER_ID2, followerActor);
         Follower newFollower2 = new Follower(follower2ActorContext);
@@ -424,7 +427,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
                 actorFactory.generateActorId(LEADER_ID));
 
         MockLeaderRaftActor leaderRaftActor = leaderActor.underlyingActor();
                 actorFactory.generateActorId(LEADER_ID));
 
         MockLeaderRaftActor leaderRaftActor = leaderActor.underlyingActor();
-        RaftActorContext leaderActorContext = leaderRaftActor.getRaftActorContext();
+        final RaftActorContext leaderActorContext = leaderRaftActor.getRaftActorContext();
 
         TestActorRef<MessageCollectorActor> leaderCollectorActor = newLeaderCollectorActor(leaderRaftActor);
 
 
         TestActorRef<MessageCollectorActor> leaderCollectorActor = newLeaderCollectorActor(leaderRaftActor);
 
@@ -506,7 +509,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         RaftActorContext leaderActorContext = leaderRaftActor.getRaftActorContext();
         ((DefaultConfigParamsImpl)leaderActorContext.getConfigParams()).setElectionTimeoutFactor(100);
 
         RaftActorContext leaderActorContext = leaderRaftActor.getRaftActorContext();
         ((DefaultConfigParamsImpl)leaderActorContext.getConfigParams()).setElectionTimeoutFactor(100);
 
-        TestActorRef<MessageCollectorActor> leaderCollectorActor = newLeaderCollectorActor(leaderRaftActor);
+        final TestActorRef<MessageCollectorActor> leaderCollectorActor = newLeaderCollectorActor(leaderRaftActor);
 
         // Drop the commit message so the snapshot doesn't complete yet.
         leaderRaftActor.setDropMessageOfType(COMMIT_MESSAGE_CLASS);
 
         // Drop the commit message so the snapshot doesn't complete yet.
         leaderRaftActor.setDropMessageOfType(COMMIT_MESSAGE_CLASS);
@@ -563,7 +566,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
 
         leaderActor.tell(new AddServer(NEW_SERVER_ID, newFollowerRaftActor.path().toString(), true), testKit.getRef());
 
 
         leaderActor.tell(new AddServer(NEW_SERVER_ID, newFollowerRaftActor.path().toString(), true), testKit.getRef());
 
-        UnInitializedFollowerSnapshotReply snapshotReply = expectFirstMatching(leaderCollectorActor,
+        final UnInitializedFollowerSnapshotReply snapshotReply = expectFirstMatching(leaderCollectorActor,
                 UnInitializedFollowerSnapshotReply.class);
 
         // Prevent election timeout when the leader switches to follower
                 UnInitializedFollowerSnapshotReply.class);
 
         // Prevent election timeout when the leader switches to follower
@@ -627,12 +630,13 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
 
         TestActorRef<MockRaftActor> noLeaderActor = actorFactory.createTestActor(
                 MockRaftActor.builder().id(LEADER_ID).peerAddresses(ImmutableMap.of(FOLLOWER_ID,
 
         TestActorRef<MockRaftActor> noLeaderActor = actorFactory.createTestActor(
                 MockRaftActor.builder().id(LEADER_ID).peerAddresses(ImmutableMap.of(FOLLOWER_ID,
-                        followerActor.path().toString())).config(configParams).persistent(Optional.of(false)).
-                        props().withDispatcher(Dispatchers.DefaultDispatcherId()),
+                        followerActor.path().toString())).config(configParams).persistent(Optional.of(false))
+                        .props().withDispatcher(Dispatchers.DefaultDispatcherId()),
                 actorFactory.generateActorId(LEADER_ID));
         noLeaderActor.underlyingActor().waitForInitializeBehaviorComplete();
 
                 actorFactory.generateActorId(LEADER_ID));
         noLeaderActor.underlyingActor().waitForInitializeBehaviorComplete();
 
-        noLeaderActor.tell(new AddServer(NEW_SERVER_ID, newFollowerRaftActor.path().toString(), true), testKit.getRef());
+        noLeaderActor.tell(new AddServer(NEW_SERVER_ID, newFollowerRaftActor.path().toString(), true),
+                testKit.getRef());
         AddServerReply addServerReply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), AddServerReply.class);
         assertEquals("getStatus", ServerChangeStatus.NO_LEADER, addServerReply.getStatus());
 
         AddServerReply addServerReply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), AddServerReply.class);
         assertEquals("getStatus", ServerChangeStatus.NO_LEADER, addServerReply.getStatus());
 
@@ -652,16 +656,15 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
                 actorFactory.generateActorId(LEADER_ID));
 
         MockLeaderRaftActor leaderRaftActor = leaderActor.underlyingActor();
                 actorFactory.generateActorId(LEADER_ID));
 
         MockLeaderRaftActor leaderRaftActor = leaderActor.underlyingActor();
-        RaftActorContext leaderActorContext = leaderRaftActor.getRaftActorContext();
+        final RaftActorContext leaderActorContext = leaderRaftActor.getRaftActorContext();
 
 
-        TestActorRef<MessageCollectorActor> leaderCollectorActor = newLeaderCollectorActor(leaderRaftActor);
+        final TestActorRef<MessageCollectorActor> leaderCollectorActor = newLeaderCollectorActor(leaderRaftActor);
 
         // Drop UnInitializedFollowerSnapshotReply initially
         leaderRaftActor.setDropMessageOfType(UnInitializedFollowerSnapshotReply.class);
 
         MockNewFollowerRaftActor newFollowerRaftActorInstance = newFollowerRaftActor.underlyingActor();
 
         // Drop UnInitializedFollowerSnapshotReply initially
         leaderRaftActor.setDropMessageOfType(UnInitializedFollowerSnapshotReply.class);
 
         MockNewFollowerRaftActor newFollowerRaftActorInstance = newFollowerRaftActor.underlyingActor();
-        TestActorRef<MessageCollectorActor> newFollowerCollectorActor =
-                newCollectorActor(newFollowerRaftActorInstance, NEW_SERVER_ID);
+        newFollowerCollectorActor = newCollectorActor(newFollowerRaftActorInstance, NEW_SERVER_ID);
 
         // Drop AppendEntries to the new follower so consensus isn't reached
         newFollowerRaftActorInstance.setDropMessageOfType(AppendEntries.class);
 
         // Drop AppendEntries to the new follower so consensus isn't reached
         newFollowerRaftActorInstance.setDropMessageOfType(AppendEntries.class);
@@ -734,15 +737,16 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
 
         TestActorRef<MockRaftActor> followerRaftActor = actorFactory.createTestActor(
                 MockRaftActor.builder().id(FOLLOWER_ID).peerAddresses(ImmutableMap.of(LEADER_ID,
 
         TestActorRef<MockRaftActor> followerRaftActor = actorFactory.createTestActor(
                 MockRaftActor.builder().id(FOLLOWER_ID).peerAddresses(ImmutableMap.of(LEADER_ID,
-                        leaderActor.path().toString())).config(configParams).persistent(Optional.of(false)).
-                        props().withDispatcher(Dispatchers.DefaultDispatcherId()),
+                        leaderActor.path().toString())).config(configParams).persistent(Optional.of(false))
+                        .props().withDispatcher(Dispatchers.DefaultDispatcherId()),
                 actorFactory.generateActorId(FOLLOWER_ID));
         followerRaftActor.underlyingActor().waitForInitializeBehaviorComplete();
 
         followerRaftActor.tell(new AppendEntries(1, LEADER_ID, 0, 1, Collections.<ReplicatedLogEntry>emptyList(),
                 -1, -1, (short)0), leaderActor);
 
                 actorFactory.generateActorId(FOLLOWER_ID));
         followerRaftActor.underlyingActor().waitForInitializeBehaviorComplete();
 
         followerRaftActor.tell(new AppendEntries(1, LEADER_ID, 0, 1, Collections.<ReplicatedLogEntry>emptyList(),
                 -1, -1, (short)0), leaderActor);
 
-        followerRaftActor.tell(new AddServer(NEW_SERVER_ID, newFollowerRaftActor.path().toString(), true), testKit.getRef());
+        followerRaftActor.tell(new AddServer(NEW_SERVER_ID, newFollowerRaftActor.path().toString(), true),
+                testKit.getRef());
         expectFirstMatching(leaderActor, AddServer.class);
 
         LOG.info("testAddServerForwardedToLeader ending");
         expectFirstMatching(leaderActor, AddServer.class);
 
         LOG.info("testAddServerForwardedToLeader ending");
@@ -756,11 +760,12 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         configParams.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
         TestActorRef<MockRaftActor> noLeaderActor = actorFactory.createTestActor(
                 MockRaftActor.builder().id(LEADER_ID).peerAddresses(ImmutableMap.of(FOLLOWER_ID,
         configParams.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
         TestActorRef<MockRaftActor> noLeaderActor = actorFactory.createTestActor(
                 MockRaftActor.builder().id(LEADER_ID).peerAddresses(ImmutableMap.of(FOLLOWER_ID,
-                        followerActor.path().toString())).config(configParams).persistent(Optional.of(false)).
-                        props().withDispatcher(Dispatchers.DefaultDispatcherId()),
+                        followerActor.path().toString())).config(configParams).persistent(Optional.of(false))
+                        .props().withDispatcher(Dispatchers.DefaultDispatcherId()),
                 actorFactory.generateActorId(LEADER_ID));
 
                 actorFactory.generateActorId(LEADER_ID));
 
-        RaftActorServerConfigurationSupport support = new RaftActorServerConfigurationSupport(noLeaderActor.underlyingActor());
+        RaftActorServerConfigurationSupport support = new RaftActorServerConfigurationSupport(
+                noLeaderActor.underlyingActor());
 
         ReplicatedLogEntry serverConfigEntry = new MockRaftActorContext.MockReplicatedLogEntry(1, 1,
                 new ServerConfigurationPayload(Collections.<ServerInfo>emptyList()));
 
         ReplicatedLogEntry serverConfigEntry = new MockRaftActorContext.MockReplicatedLogEntry(1, 1,
                 new ServerConfigurationPayload(Collections.<ServerInfo>emptyList()));
@@ -784,13 +789,14 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
 
         TestActorRef<MockRaftActor> leaderActor = actorFactory.createTestActor(
                 MockRaftActor.builder().id(LEADER_ID).peerAddresses(ImmutableMap.of(FOLLOWER_ID,
 
         TestActorRef<MockRaftActor> leaderActor = actorFactory.createTestActor(
                 MockRaftActor.builder().id(LEADER_ID).peerAddresses(ImmutableMap.of(FOLLOWER_ID,
-                        followerActor.path().toString())).config(configParams).persistent(Optional.of(false)).
-                        props().withDispatcher(Dispatchers.DefaultDispatcherId()),
+                        followerActor.path().toString())).config(configParams).persistent(Optional.of(false))
+                        .props().withDispatcher(Dispatchers.DefaultDispatcherId()),
                 actorFactory.generateActorId(LEADER_ID));
         leaderActor.underlyingActor().waitForInitializeBehaviorComplete();
 
         leaderActor.tell(new RemoveServer(FOLLOWER_ID), testKit.getRef());
                 actorFactory.generateActorId(LEADER_ID));
         leaderActor.underlyingActor().waitForInitializeBehaviorComplete();
 
         leaderActor.tell(new RemoveServer(FOLLOWER_ID), testKit.getRef());
-        RemoveServerReply removeServerReply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), RemoveServerReply.class);
+        RemoveServerReply removeServerReply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"),
+                RemoveServerReply.class);
         assertEquals("getStatus", ServerChangeStatus.NO_LEADER, removeServerReply.getStatus());
 
         LOG.info("testRemoveServerWithNoLeader ending");
         assertEquals("getStatus", ServerChangeStatus.NO_LEADER, removeServerReply.getStatus());
 
         LOG.info("testRemoveServerWithNoLeader ending");
@@ -808,7 +814,8 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
                 actorFactory.generateActorId(LEADER_ID));
 
         leaderActor.tell(new RemoveServer(NEW_SERVER_ID), testKit.getRef());
                 actorFactory.generateActorId(LEADER_ID));
 
         leaderActor.tell(new RemoveServer(NEW_SERVER_ID), testKit.getRef());
-        RemoveServerReply removeServerReply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), RemoveServerReply.class);
+        RemoveServerReply removeServerReply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"),
+                RemoveServerReply.class);
         assertEquals("getStatus", ServerChangeStatus.DOES_NOT_EXIST, removeServerReply.getStatus());
 
         LOG.info("testRemoveServerNonExistentServer ending");
         assertEquals("getStatus", ServerChangeStatus.DOES_NOT_EXIST, removeServerReply.getStatus());
 
         LOG.info("testRemoveServerNonExistentServer ending");
@@ -827,8 +834,8 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
 
         TestActorRef<MockRaftActor> followerRaftActor = actorFactory.createTestActor(
                 MockRaftActor.builder().id(FOLLOWER_ID).peerAddresses(ImmutableMap.of(LEADER_ID,
 
         TestActorRef<MockRaftActor> followerRaftActor = actorFactory.createTestActor(
                 MockRaftActor.builder().id(FOLLOWER_ID).peerAddresses(ImmutableMap.of(LEADER_ID,
-                        leaderActor.path().toString())).config(configParams).persistent(Optional.of(false)).
-                        props().withDispatcher(Dispatchers.DefaultDispatcherId()),
+                        leaderActor.path().toString())).config(configParams).persistent(Optional.of(false))
+                        .props().withDispatcher(Dispatchers.DefaultDispatcherId()),
                 actorFactory.generateActorId(FOLLOWER_ID));
         followerRaftActor.underlyingActor().waitForInitializeBehaviorComplete();
 
                 actorFactory.generateActorId(FOLLOWER_ID));
         followerRaftActor.underlyingActor().waitForInitializeBehaviorComplete();
 
@@ -858,23 +865,26 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
                         initialActorContext).withDispatcher(Dispatchers.DefaultDispatcherId()),
                 actorFactory.generateActorId(LEADER_ID));
 
                         initialActorContext).withDispatcher(Dispatchers.DefaultDispatcherId()),
                 actorFactory.generateActorId(LEADER_ID));
 
-        TestActorRef<MessageCollectorActor> leaderCollector = newLeaderCollectorActor(leaderActor.underlyingActor());
+        final TestActorRef<MessageCollectorActor> leaderCollector =
+                newLeaderCollectorActor(leaderActor.underlyingActor());
 
 
-        TestActorRef<MessageCollectorActor> collector =
-                actorFactory.createTestActor(MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
+        TestActorRef<MessageCollectorActor> collector = actorFactory.createTestActor(MessageCollectorActor.props()
+                .withDispatcher(Dispatchers.DefaultDispatcherId()),
                         actorFactory.generateActorId("collector"));
                         actorFactory.generateActorId("collector"));
-        TestActorRef<CollectingMockRaftActor> followerRaftActor = actorFactory.createTestActor(
+        actorFactory.createTestActor(
                 CollectingMockRaftActor.props(FOLLOWER_ID, ImmutableMap.of(LEADER_ID, leaderActor.path().toString()),
                         configParams, NO_PERSISTENCE, collector).withDispatcher(Dispatchers.DefaultDispatcherId()),
                 followerActorId);
 
         leaderActor.tell(new RemoveServer(FOLLOWER_ID), testKit.getRef());
                 CollectingMockRaftActor.props(FOLLOWER_ID, ImmutableMap.of(LEADER_ID, leaderActor.path().toString()),
                         configParams, NO_PERSISTENCE, collector).withDispatcher(Dispatchers.DefaultDispatcherId()),
                 followerActorId);
 
         leaderActor.tell(new RemoveServer(FOLLOWER_ID), testKit.getRef());
-        RemoveServerReply removeServerReply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), RemoveServerReply.class);
+        RemoveServerReply removeServerReply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"),
+                RemoveServerReply.class);
         assertEquals("getStatus", ServerChangeStatus.OK, removeServerReply.getStatus());
 
         final ApplyState applyState = MessageCollectorActor.expectFirstMatching(leaderCollector, ApplyState.class);
         assertEquals(0L, applyState.getReplicatedLogEntry().getIndex());
         assertEquals("getStatus", ServerChangeStatus.OK, removeServerReply.getStatus());
 
         final ApplyState applyState = MessageCollectorActor.expectFirstMatching(leaderCollector, ApplyState.class);
         assertEquals(0L, applyState.getReplicatedLogEntry().getIndex());
-        verifyServerConfigurationPayloadEntry(leaderActor.underlyingActor().getRaftActorContext().getReplicatedLog(), votingServer(LEADER_ID));
+        verifyServerConfigurationPayloadEntry(leaderActor.underlyingActor().getRaftActorContext().getReplicatedLog(),
+                votingServer(LEADER_ID));
 
         RaftActorBehavior currentBehavior = leaderActor.underlyingActor().getCurrentBehavior();
         assertTrue("Expected Leader", currentBehavior instanceof Leader);
 
         RaftActorBehavior currentBehavior = leaderActor.underlyingActor().getCurrentBehavior();
         assertTrue("Expected Leader", currentBehavior instanceof Leader);
@@ -902,17 +912,21 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
                         initialActorContext).withDispatcher(Dispatchers.DefaultDispatcherId()),
                 actorFactory.generateActorId(LEADER_ID));
 
                         initialActorContext).withDispatcher(Dispatchers.DefaultDispatcherId()),
                 actorFactory.generateActorId(LEADER_ID));
 
-        TestActorRef<MessageCollectorActor> leaderCollector = newLeaderCollectorActor(leaderActor.underlyingActor());
+        final TestActorRef<MessageCollectorActor> leaderCollector =
+                newLeaderCollectorActor(leaderActor.underlyingActor());
 
 
-        TestActorRef<MessageCollectorActor> followerCollector = actorFactory.createTestActor(MessageCollectorActor.props().
-                withDispatcher(Dispatchers.DefaultDispatcherId()), actorFactory.generateActorId("collector"));
+        final TestActorRef<MessageCollectorActor> followerCollector =
+                actorFactory.createTestActor(MessageCollectorActor.props()
+                .withDispatcher(Dispatchers.DefaultDispatcherId()), actorFactory.generateActorId("collector"));
         actorFactory.createTestActor(
                 CollectingMockRaftActor.props(FOLLOWER_ID, ImmutableMap.of(LEADER_ID, leaderActor.path().toString()),
         actorFactory.createTestActor(
                 CollectingMockRaftActor.props(FOLLOWER_ID, ImmutableMap.of(LEADER_ID, leaderActor.path().toString()),
-                        configParams, NO_PERSISTENCE, followerCollector).withDispatcher(Dispatchers.DefaultDispatcherId()),
+                        configParams, NO_PERSISTENCE, followerCollector)
+                        .withDispatcher(Dispatchers.DefaultDispatcherId()),
                 followerActorId);
 
         leaderActor.tell(new RemoveServer(LEADER_ID), testKit.getRef());
                 followerActorId);
 
         leaderActor.tell(new RemoveServer(LEADER_ID), testKit.getRef());
-        RemoveServerReply removeServerReply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), RemoveServerReply.class);
+        RemoveServerReply removeServerReply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"),
+                RemoveServerReply.class);
         assertEquals("getStatus", ServerChangeStatus.OK, removeServerReply.getStatus());
 
         final ApplyState applyState = MessageCollectorActor.expectFirstMatching(followerCollector, ApplyState.class);
         assertEquals("getStatus", ServerChangeStatus.OK, removeServerReply.getStatus());
 
         final ApplyState applyState = MessageCollectorActor.expectFirstMatching(followerCollector, ApplyState.class);
@@ -935,7 +949,8 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
                 actorFactory.generateActorId(LEADER_ID));
 
         leaderActor.tell(new RemoveServer(LEADER_ID), testKit.getRef());
                 actorFactory.generateActorId(LEADER_ID));
 
         leaderActor.tell(new RemoveServer(LEADER_ID), testKit.getRef());
-        RemoveServerReply removeServerReply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), RemoveServerReply.class);
+        RemoveServerReply removeServerReply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"),
+                RemoveServerReply.class);
         assertEquals("getStatus", ServerChangeStatus.NOT_SUPPORTED, removeServerReply.getStatus());
 
         LOG.info("testRemoveServerLeaderWithNoFollowers ending");
         assertEquals("getStatus", ServerChangeStatus.NOT_SUPPORTED, removeServerReply.getStatus());
 
         LOG.info("testRemoveServerLeaderWithNoFollowers ending");
@@ -956,25 +971,25 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
 
         TestActorRef<MockLeaderRaftActor> leaderActor = actorFactory.createTestActor(
                 MockLeaderRaftActor.props(ImmutableMap.of(FOLLOWER_ID, follower1ActorPath,
 
         TestActorRef<MockLeaderRaftActor> leaderActor = actorFactory.createTestActor(
                 MockLeaderRaftActor.props(ImmutableMap.of(FOLLOWER_ID, follower1ActorPath,
-                        FOLLOWER_ID2, follower2ActorPath), new MockRaftActorContext()).
-                        withDispatcher(Dispatchers.DefaultDispatcherId()), actorFactory.generateActorId(LEADER_ID));
+                        FOLLOWER_ID2, follower2ActorPath), new MockRaftActorContext())
+                        .withDispatcher(Dispatchers.DefaultDispatcherId()), actorFactory.generateActorId(LEADER_ID));
         TestActorRef<MessageCollectorActor> leaderCollector = newLeaderCollectorActor(leaderActor.underlyingActor());
 
         TestActorRef<MessageCollectorActor> follower1Collector = actorFactory.createTestActor(
                 MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
                 actorFactory.generateActorId("collector"));
         TestActorRef<MessageCollectorActor> leaderCollector = newLeaderCollectorActor(leaderActor.underlyingActor());
 
         TestActorRef<MessageCollectorActor> follower1Collector = actorFactory.createTestActor(
                 MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
                 actorFactory.generateActorId("collector"));
-        TestActorRef<CollectingMockRaftActor> follower1RaftActor = actorFactory.createTestActor(
+        final TestActorRef<CollectingMockRaftActor> follower1RaftActor = actorFactory.createTestActor(
                 CollectingMockRaftActor.props(FOLLOWER_ID, ImmutableMap.of(LEADER_ID, leaderActor.path().toString(),
                 CollectingMockRaftActor.props(FOLLOWER_ID, ImmutableMap.of(LEADER_ID, leaderActor.path().toString(),
-                        FOLLOWER_ID2, follower2ActorPath), configParams, NO_PERSISTENCE, follower1Collector).
-                        withDispatcher(Dispatchers.DefaultDispatcherId()), follower1ActorId);
+                        FOLLOWER_ID2, follower2ActorPath), configParams, NO_PERSISTENCE, follower1Collector)
+                        .withDispatcher(Dispatchers.DefaultDispatcherId()), follower1ActorId);
 
         TestActorRef<MessageCollectorActor> follower2Collector = actorFactory.createTestActor(
                 MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
                 actorFactory.generateActorId("collector"));
 
         TestActorRef<MessageCollectorActor> follower2Collector = actorFactory.createTestActor(
                 MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
                 actorFactory.generateActorId("collector"));
-        TestActorRef<CollectingMockRaftActor> follower2RaftActor = actorFactory.createTestActor(
+        final TestActorRef<CollectingMockRaftActor> follower2RaftActor = actorFactory.createTestActor(
                 CollectingMockRaftActor.props(FOLLOWER_ID2, ImmutableMap.of(LEADER_ID, leaderActor.path().toString(),
                 CollectingMockRaftActor.props(FOLLOWER_ID2, ImmutableMap.of(LEADER_ID, leaderActor.path().toString(),
-                        FOLLOWER_ID, follower1ActorPath), configParams, NO_PERSISTENCE, follower2Collector).
-                        withDispatcher(Dispatchers.DefaultDispatcherId()), follower2ActorId);
+                        FOLLOWER_ID, follower1ActorPath), configParams, NO_PERSISTENCE, follower2Collector)
+                        .withDispatcher(Dispatchers.DefaultDispatcherId()), follower2ActorId);
 
         // Send first ChangeServersVotingStatus message
 
 
         // Send first ChangeServersVotingStatus message
 
@@ -989,12 +1004,14 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
                 votingServer(LEADER_ID), nonVotingServer(FOLLOWER_ID), nonVotingServer(FOLLOWER_ID2));
 
         MessageCollectorActor.expectFirstMatching(follower1Collector, ApplyState.class);
                 votingServer(LEADER_ID), nonVotingServer(FOLLOWER_ID), nonVotingServer(FOLLOWER_ID2));
 
         MessageCollectorActor.expectFirstMatching(follower1Collector, ApplyState.class);
-        verifyServerConfigurationPayloadEntry(follower1RaftActor.underlyingActor().getRaftActorContext().getReplicatedLog(),
-                votingServer(LEADER_ID), nonVotingServer(FOLLOWER_ID), nonVotingServer(FOLLOWER_ID2));
+        verifyServerConfigurationPayloadEntry(follower1RaftActor.underlyingActor().getRaftActorContext()
+                .getReplicatedLog(), votingServer(LEADER_ID), nonVotingServer(FOLLOWER_ID),
+                nonVotingServer(FOLLOWER_ID2));
 
         MessageCollectorActor.expectFirstMatching(follower2Collector, ApplyState.class);
 
         MessageCollectorActor.expectFirstMatching(follower2Collector, ApplyState.class);
-        verifyServerConfigurationPayloadEntry(follower2RaftActor.underlyingActor().getRaftActorContext().getReplicatedLog(),
-                votingServer(LEADER_ID), nonVotingServer(FOLLOWER_ID), nonVotingServer(FOLLOWER_ID2));
+        verifyServerConfigurationPayloadEntry(follower2RaftActor.underlyingActor().getRaftActorContext()
+                .getReplicatedLog(), votingServer(LEADER_ID), nonVotingServer(FOLLOWER_ID),
+                nonVotingServer(FOLLOWER_ID2));
 
         MessageCollectorActor.clearMessages(leaderCollector);
         MessageCollectorActor.clearMessages(follower1Collector);
 
         MessageCollectorActor.clearMessages(leaderCollector);
         MessageCollectorActor.clearMessages(follower1Collector);
@@ -1011,12 +1028,12 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
                 votingServer(LEADER_ID), votingServer(FOLLOWER_ID), nonVotingServer(FOLLOWER_ID2));
 
         MessageCollectorActor.expectFirstMatching(follower1Collector, ApplyState.class);
                 votingServer(LEADER_ID), votingServer(FOLLOWER_ID), nonVotingServer(FOLLOWER_ID2));
 
         MessageCollectorActor.expectFirstMatching(follower1Collector, ApplyState.class);
-        verifyServerConfigurationPayloadEntry(follower1RaftActor.underlyingActor().getRaftActorContext().getReplicatedLog(),
-                votingServer(LEADER_ID), votingServer(FOLLOWER_ID), nonVotingServer(FOLLOWER_ID2));
+        verifyServerConfigurationPayloadEntry(follower1RaftActor.underlyingActor().getRaftActorContext()
+                .getReplicatedLog(), votingServer(LEADER_ID), votingServer(FOLLOWER_ID), nonVotingServer(FOLLOWER_ID2));
 
         MessageCollectorActor.expectFirstMatching(follower2Collector, ApplyState.class);
 
         MessageCollectorActor.expectFirstMatching(follower2Collector, ApplyState.class);
-        verifyServerConfigurationPayloadEntry(follower2RaftActor.underlyingActor().getRaftActorContext().getReplicatedLog(),
-                votingServer(LEADER_ID), votingServer(FOLLOWER_ID), nonVotingServer(FOLLOWER_ID2));
+        verifyServerConfigurationPayloadEntry(follower2RaftActor.underlyingActor().getRaftActorContext()
+                .getReplicatedLog(), votingServer(LEADER_ID), votingServer(FOLLOWER_ID), nonVotingServer(FOLLOWER_ID2));
 
         LOG.info("testChangeServersVotingStatus ending");
     }
 
         LOG.info("testChangeServersVotingStatus ending");
     }
@@ -1035,25 +1052,25 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
 
         TestActorRef<MockLeaderRaftActor> leaderActor = actorFactory.createTestActor(
                 MockLeaderRaftActor.props(ImmutableMap.of(FOLLOWER_ID, follower1ActorPath,
 
         TestActorRef<MockLeaderRaftActor> leaderActor = actorFactory.createTestActor(
                 MockLeaderRaftActor.props(ImmutableMap.of(FOLLOWER_ID, follower1ActorPath,
-                        FOLLOWER_ID2, follower2ActorPath), new MockRaftActorContext()).
-                        withDispatcher(Dispatchers.DefaultDispatcherId()), actorFactory.generateActorId(LEADER_ID));
+                        FOLLOWER_ID2, follower2ActorPath), new MockRaftActorContext())
+                        .withDispatcher(Dispatchers.DefaultDispatcherId()), actorFactory.generateActorId(LEADER_ID));
         TestActorRef<MessageCollectorActor> leaderCollector = newLeaderCollectorActor(leaderActor.underlyingActor());
 
         TestActorRef<MessageCollectorActor> follower1Collector = actorFactory.createTestActor(
                 MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
                 actorFactory.generateActorId("collector"));
         TestActorRef<MessageCollectorActor> leaderCollector = newLeaderCollectorActor(leaderActor.underlyingActor());
 
         TestActorRef<MessageCollectorActor> follower1Collector = actorFactory.createTestActor(
                 MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
                 actorFactory.generateActorId("collector"));
-        TestActorRef<CollectingMockRaftActor> follower1RaftActor = actorFactory.createTestActor(
+        final TestActorRef<CollectingMockRaftActor> follower1RaftActor = actorFactory.createTestActor(
                 CollectingMockRaftActor.props(FOLLOWER_ID, ImmutableMap.of(LEADER_ID, leaderActor.path().toString(),
                 CollectingMockRaftActor.props(FOLLOWER_ID, ImmutableMap.of(LEADER_ID, leaderActor.path().toString(),
-                        FOLLOWER_ID2, follower2ActorPath), configParams, NO_PERSISTENCE, follower1Collector).
-                        withDispatcher(Dispatchers.DefaultDispatcherId()), follower1ActorId);
+                        FOLLOWER_ID2, follower2ActorPath), configParams, NO_PERSISTENCE, follower1Collector)
+                        .withDispatcher(Dispatchers.DefaultDispatcherId()), follower1ActorId);
 
         TestActorRef<MessageCollectorActor> follower2Collector = actorFactory.createTestActor(
                 MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
                 actorFactory.generateActorId("collector"));
 
         TestActorRef<MessageCollectorActor> follower2Collector = actorFactory.createTestActor(
                 MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
                 actorFactory.generateActorId("collector"));
-        TestActorRef<CollectingMockRaftActor> follower2RaftActor = actorFactory.createTestActor(
+        final TestActorRef<CollectingMockRaftActor> follower2RaftActor = actorFactory.createTestActor(
                 CollectingMockRaftActor.props(FOLLOWER_ID2, ImmutableMap.of(LEADER_ID, leaderActor.path().toString(),
                 CollectingMockRaftActor.props(FOLLOWER_ID2, ImmutableMap.of(LEADER_ID, leaderActor.path().toString(),
-                        FOLLOWER_ID, follower1ActorPath), configParams, NO_PERSISTENCE, follower2Collector).
-                        withDispatcher(Dispatchers.DefaultDispatcherId()), follower2ActorId);
+                        FOLLOWER_ID, follower1ActorPath), configParams, NO_PERSISTENCE, follower2Collector)
+                        .withDispatcher(Dispatchers.DefaultDispatcherId()), follower2ActorId);
 
         // Send ChangeServersVotingStatus message
 
 
         // Send ChangeServersVotingStatus message
 
@@ -1066,12 +1083,12 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
                 nonVotingServer(LEADER_ID), votingServer(FOLLOWER_ID), votingServer(FOLLOWER_ID2));
 
         MessageCollectorActor.expectFirstMatching(follower1Collector, ApplyState.class);
                 nonVotingServer(LEADER_ID), votingServer(FOLLOWER_ID), votingServer(FOLLOWER_ID2));
 
         MessageCollectorActor.expectFirstMatching(follower1Collector, ApplyState.class);
-        verifyServerConfigurationPayloadEntry(follower1RaftActor.underlyingActor().getRaftActorContext().getReplicatedLog(),
-                nonVotingServer(LEADER_ID), votingServer(FOLLOWER_ID), votingServer(FOLLOWER_ID2));
+        verifyServerConfigurationPayloadEntry(follower1RaftActor.underlyingActor().getRaftActorContext()
+                .getReplicatedLog(), nonVotingServer(LEADER_ID), votingServer(FOLLOWER_ID), votingServer(FOLLOWER_ID2));
 
         MessageCollectorActor.expectFirstMatching(follower2Collector, ApplyState.class);
 
         MessageCollectorActor.expectFirstMatching(follower2Collector, ApplyState.class);
-        verifyServerConfigurationPayloadEntry(follower2RaftActor.underlyingActor().getRaftActorContext().getReplicatedLog(),
-                nonVotingServer(LEADER_ID), votingServer(FOLLOWER_ID), votingServer(FOLLOWER_ID2));
+        verifyServerConfigurationPayloadEntry(follower2RaftActor.underlyingActor().getRaftActorContext()
+                .getReplicatedLog(), nonVotingServer(LEADER_ID), votingServer(FOLLOWER_ID), votingServer(FOLLOWER_ID2));
 
         verifyRaftState(RaftState.Leader, follower1RaftActor.underlyingActor(), follower2RaftActor.underlyingActor());
         verifyRaftState(RaftState.Follower, leaderActor.underlyingActor());
 
         verifyRaftState(RaftState.Leader, follower1RaftActor.underlyingActor(), follower2RaftActor.underlyingActor());
         verifyRaftState(RaftState.Follower, leaderActor.underlyingActor());
@@ -1086,8 +1103,8 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         LOG.info("testChangeLeaderToNonVotingInSingleNode starting");
 
         TestActorRef<MockLeaderRaftActor> leaderActor = actorFactory.createTestActor(
         LOG.info("testChangeLeaderToNonVotingInSingleNode starting");
 
         TestActorRef<MockLeaderRaftActor> leaderActor = actorFactory.createTestActor(
-                MockLeaderRaftActor.props(ImmutableMap.of(), new MockRaftActorContext()).
-                        withDispatcher(Dispatchers.DefaultDispatcherId()), actorFactory.generateActorId(LEADER_ID));
+                MockLeaderRaftActor.props(ImmutableMap.of(), new MockRaftActorContext())
+                        .withDispatcher(Dispatchers.DefaultDispatcherId()), actorFactory.generateActorId(LEADER_ID));
 
         leaderActor.tell(new ChangeServersVotingStatus(ImmutableMap.of(LEADER_ID, false)), testKit.getRef());
         ServerChangeReply reply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), ServerChangeReply.class);
 
         leaderActor.tell(new ChangeServersVotingStatus(ImmutableMap.of(LEADER_ID, false)), testKit.getRef());
         ServerChangeReply reply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), ServerChangeReply.class);
@@ -1189,7 +1206,8 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         reply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), ServerChangeReply.class);
         assertEquals("getStatus", ServerChangeStatus.OK, reply.getStatus());
 
         reply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), ServerChangeReply.class);
         assertEquals("getStatus", ServerChangeStatus.OK, reply.getStatus());
 
-        ApplyJournalEntries apply = MessageCollectorActor.expectFirstMatching(node1Collector, ApplyJournalEntries.class);
+        ApplyJournalEntries apply = MessageCollectorActor.expectFirstMatching(node1Collector,
+                ApplyJournalEntries.class);
         assertEquals("getToIndex", 1, apply.getToIndex());
         verifyServerConfigurationPayloadEntry(node1RaftActor.getRaftActorContext().getReplicatedLog(),
                 votingServer(node1ID), votingServer(node2ID), nonVotingServer("downNode1"),
         assertEquals("getToIndex", 1, apply.getToIndex());
         verifyServerConfigurationPayloadEntry(node1RaftActor.getRaftActorContext().getReplicatedLog(),
                 votingServer(node1ID), votingServer(node2ID), nonVotingServer("downNode1"),
@@ -1215,8 +1233,9 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         final String node1ID = "node1";
         final String node2ID = "node2";
 
         final String node1ID = "node1";
         final String node2ID = "node2";
 
-        PeerAddressResolver peerAddressResolver = peerId -> peerId.equals(node1ID) ? actorFactory.createTestActorPath(node1ID) :
-            peerId.equals(node2ID) ? actorFactory.createTestActorPath(node2ID) : null;
+        final PeerAddressResolver peerAddressResolver = peerId -> peerId.equals(node1ID)
+                ? actorFactory.createTestActorPath(node1ID) : peerId.equals(node2ID)
+                        ? actorFactory.createTestActorPath(node2ID) : null;
 
         ServerConfigurationPayload persistedServerConfig = new ServerConfigurationPayload(Arrays.asList(
                 new ServerInfo(node1ID, false), new ServerInfo(node2ID, true)));
 
         ServerConfigurationPayload persistedServerConfig = new ServerConfigurationPayload(Arrays.asList(
                 new ServerInfo(node1ID, false), new ServerInfo(node2ID, true)));
@@ -1237,7 +1256,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         TestActorRef<CollectingMockRaftActor> node1RaftActorRef = actorFactory.createTestActor(
                 CollectingMockRaftActor.props(node1ID, ImmutableMap.<String, String>of(), configParams1,
                         PERSISTENT, node1Collector).withDispatcher(Dispatchers.DefaultDispatcherId()), node1ID);
         TestActorRef<CollectingMockRaftActor> node1RaftActorRef = actorFactory.createTestActor(
                 CollectingMockRaftActor.props(node1ID, ImmutableMap.<String, String>of(), configParams1,
                         PERSISTENT, node1Collector).withDispatcher(Dispatchers.DefaultDispatcherId()), node1ID);
-        CollectingMockRaftActor node1RaftActor = node1RaftActorRef.underlyingActor();
+        final CollectingMockRaftActor node1RaftActor = node1RaftActorRef.underlyingActor();
 
         DefaultConfigParamsImpl configParams2 = new DefaultConfigParamsImpl();
         configParams2.setElectionTimeoutFactor(1000000);
 
         DefaultConfigParamsImpl configParams2 = new DefaultConfigParamsImpl();
         configParams2.setElectionTimeoutFactor(1000000);
@@ -1277,8 +1296,9 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         final String node1ID = "node1";
         final String node2ID = "node2";
 
         final String node1ID = "node1";
         final String node2ID = "node2";
 
-        PeerAddressResolver peerAddressResolver = peerId -> peerId.equals(node1ID) ? actorFactory.createTestActorPath(node1ID) :
-            peerId.equals(node2ID) ? actorFactory.createTestActorPath(node2ID) : null;
+        final PeerAddressResolver peerAddressResolver = peerId -> peerId.equals(node1ID)
+                ? actorFactory.createTestActorPath(node1ID) : peerId.equals(node2ID)
+                        ? actorFactory.createTestActorPath(node2ID) : null;
 
         DefaultConfigParamsImpl configParams = new DefaultConfigParamsImpl();
         configParams.setHeartBeatInterval(new FiniteDuration(100, TimeUnit.MILLISECONDS));
 
         DefaultConfigParamsImpl configParams = new DefaultConfigParamsImpl();
         configParams.setHeartBeatInterval(new FiniteDuration(100, TimeUnit.MILLISECONDS));
@@ -1303,7 +1323,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         TestActorRef<CollectingMockRaftActor> node1RaftActorRef = actorFactory.createTestActor(
                 CollectingMockRaftActor.props(node1ID, ImmutableMap.<String, String>of(), configParams,
                         PERSISTENT, node1Collector).withDispatcher(Dispatchers.DefaultDispatcherId()), node1ID);
         TestActorRef<CollectingMockRaftActor> node1RaftActorRef = actorFactory.createTestActor(
                 CollectingMockRaftActor.props(node1ID, ImmutableMap.<String, String>of(), configParams,
                         PERSISTENT, node1Collector).withDispatcher(Dispatchers.DefaultDispatcherId()), node1ID);
-        CollectingMockRaftActor node1RaftActor = node1RaftActorRef.underlyingActor();
+        final CollectingMockRaftActor node1RaftActor = node1RaftActorRef.underlyingActor();
 
         TestActorRef<MessageCollectorActor> node2Collector = actorFactory.createTestActor(
                 MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
 
         TestActorRef<MessageCollectorActor> node2Collector = actorFactory.createTestActor(
                 MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
@@ -1311,7 +1331,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         TestActorRef<CollectingMockRaftActor> node2RaftActorRef = actorFactory.createTestActor(
                 CollectingMockRaftActor.props(node2ID, ImmutableMap.<String, String>of(), configParams,
                         PERSISTENT, node2Collector).withDispatcher(Dispatchers.DefaultDispatcherId()), node2ID);
         TestActorRef<CollectingMockRaftActor> node2RaftActorRef = actorFactory.createTestActor(
                 CollectingMockRaftActor.props(node2ID, ImmutableMap.<String, String>of(), configParams,
                         PERSISTENT, node2Collector).withDispatcher(Dispatchers.DefaultDispatcherId()), node2ID);
-        CollectingMockRaftActor node2RaftActor = node2RaftActorRef.underlyingActor();
+        final CollectingMockRaftActor node2RaftActor = node2RaftActorRef.underlyingActor();
 
         // Send a ChangeServersVotingStatus message to node1 to change mode1 to voting. This should cause
         // node1 to try to elect itself as leader in order to apply the new server config. However node1's log
 
         // Send a ChangeServersVotingStatus message to node1 to change mode1 to voting. This should cause
         // node1 to try to elect itself as leader in order to apply the new server config. However node1's log
@@ -1349,8 +1369,9 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         final String node1ID = "node1";
         final String node2ID = "node2";
 
         final String node1ID = "node1";
         final String node2ID = "node2";
 
-        configParams.setPeerAddressResolver(peerId -> peerId.equals(node1ID) ? actorFactory.createTestActorPath(node1ID) :
-            peerId.equals(node2ID) ? actorFactory.createTestActorPath(node2ID) : null);
+        configParams.setPeerAddressResolver(peerId -> peerId.equals(node1ID)
+                ? actorFactory.createTestActorPath(node1ID) : peerId.equals(node2ID)
+                        ? actorFactory.createTestActorPath(node2ID) : null);
 
         ServerConfigurationPayload persistedServerConfig = new ServerConfigurationPayload(Arrays.asList(
                 new ServerInfo(node1ID, false), new ServerInfo(node2ID, true)));
 
         ServerConfigurationPayload persistedServerConfig = new ServerConfigurationPayload(Arrays.asList(
                 new ServerInfo(node1ID, false), new ServerInfo(node2ID, true)));
@@ -1367,7 +1388,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         TestActorRef<CollectingMockRaftActor> node1RaftActorRef = actorFactory.createTestActor(
                 CollectingMockRaftActor.props(node1ID, ImmutableMap.<String, String>of(), configParams,
                         PERSISTENT, node1Collector).withDispatcher(Dispatchers.DefaultDispatcherId()), node1ID);
         TestActorRef<CollectingMockRaftActor> node1RaftActorRef = actorFactory.createTestActor(
                 CollectingMockRaftActor.props(node1ID, ImmutableMap.<String, String>of(), configParams,
                         PERSISTENT, node1Collector).withDispatcher(Dispatchers.DefaultDispatcherId()), node1ID);
-        CollectingMockRaftActor node1RaftActor = node1RaftActorRef.underlyingActor();
+        final CollectingMockRaftActor node1RaftActor = node1RaftActorRef.underlyingActor();
 
         TestActorRef<MessageCollectorActor> node2Collector = actorFactory.createTestActor(
                 MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
 
         TestActorRef<MessageCollectorActor> node2Collector = actorFactory.createTestActor(
                 MessageCollectorActor.props().withDispatcher(Dispatchers.DefaultDispatcherId()),
@@ -1411,9 +1432,9 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
 
     private static void verifyRaftState(RaftState expState, RaftActor... raftActors) {
         Stopwatch sw = Stopwatch.createStarted();
 
     private static void verifyRaftState(RaftState expState, RaftActor... raftActors) {
         Stopwatch sw = Stopwatch.createStarted();
-        while(sw.elapsed(TimeUnit.SECONDS) <= 5) {
-            for(RaftActor raftActor: raftActors) {
-                if(raftActor.getRaftState() == expState) {
+        while (sw.elapsed(TimeUnit.SECONDS) <= 5) {
+            for (RaftActor raftActor : raftActors) {
+                if (raftActor.getRaftState() == expState) {
                     return;
                 }
             }
                     return;
                 }
             }
@@ -1460,14 +1481,14 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
                 id, termInfo, -1, -1, ImmutableMap.of(LEADER_ID, ""), configParams, noPersistence, LOG);
     }
 
                 id, termInfo, -1, -1, ImmutableMap.of(LEADER_ID, ""), configParams, noPersistence, LOG);
     }
 
-    static abstract class AbstractMockRaftActor extends MockRaftActor {
+    abstract static class AbstractMockRaftActor extends MockRaftActor {
         private volatile TestActorRef<MessageCollectorActor> collectorActor;
         private volatile Class<?> dropMessageOfType;
 
         AbstractMockRaftActor(String id, Map<String, String> peerAddresses, Optional<ConfigParams> config,
                 boolean persistent, TestActorRef<MessageCollectorActor> collectorActor) {
         private volatile TestActorRef<MessageCollectorActor> collectorActor;
         private volatile Class<?> dropMessageOfType;
 
         AbstractMockRaftActor(String id, Map<String, String> peerAddresses, Optional<ConfigParams> config,
                 boolean persistent, TestActorRef<MessageCollectorActor> collectorActor) {
-            super(builder().id(id).peerAddresses(peerAddresses).config(config.get()).
-                    persistent(Optional.of(persistent)));
+            super(builder().id(id).peerAddresses(peerAddresses).config(config.get())
+                    .persistent(Optional.of(persistent)));
             this.collectorActor = collectorActor;
         }
 
             this.collectorActor = collectorActor;
         }
 
@@ -1481,11 +1502,11 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
 
         @Override
         public void handleCommand(Object message) {
 
         @Override
         public void handleCommand(Object message) {
-            if(dropMessageOfType == null || !dropMessageOfType.equals(message.getClass())) {
+            if (dropMessageOfType == null || !dropMessageOfType.equals(message.getClass())) {
                 super.handleCommand(message);
             }
 
                 super.handleCommand(message);
             }
 
-            if(collectorActor != null) {
+            if (collectorActor != null) {
                 collectorActor.tell(message, getSender());
             }
         }
                 collectorActor.tell(message, getSender());
             }
         }
@@ -1509,7 +1530,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         }
 
         public static Props props(final String id, final Map<String, String> peerAddresses,
         }
 
         public static Props props(final String id, final Map<String, String> peerAddresses,
-                ConfigParams config, boolean persistent, TestActorRef<MessageCollectorActor> collectorActor){
+                ConfigParams config, boolean persistent, TestActorRef<MessageCollectorActor> collectorActor) {
 
             return Props.create(CollectingMockRaftActor.class, id, peerAddresses, Optional.of(config),
                     persistent, collectorActor);
 
             return Props.create(CollectingMockRaftActor.class, id, peerAddresses, Optional.of(config),
                     persistent, collectorActor);
@@ -1524,7 +1545,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
             setPersistence(false);
 
             RaftActorContext context = getRaftActorContext();
             setPersistence(false);
 
             RaftActorContext context = getRaftActorContext();
-            for(int i = 0; i < fromContext.getReplicatedLog().size(); i++) {
+            for (int i = 0; i < fromContext.getReplicatedLog().size(); i++) {
                 ReplicatedLogEntry entry = fromContext.getReplicatedLog().get(i);
                 getState().add(entry.getData());
                 context.getReplicatedLog().append(entry);
                 ReplicatedLogEntry entry = fromContext.getReplicatedLog().get(i);
                 getState().add(entry.getData());
                 context.getReplicatedLog().append(entry);
@@ -1543,6 +1564,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         }
 
         @Override
         }
 
         @Override
+        @SuppressWarnings("checkstyle:IllegalCatch")
         public void createSnapshot(ActorRef actorRef) {
             try {
                 actorRef.tell(new CaptureSnapshotReply(RaftActorTest.fromObject(getState()).toByteArray()), actorRef);
         public void createSnapshot(ActorRef actorRef) {
             try {
                 actorRef.tell(new CaptureSnapshotReply(RaftActorTest.fromObject(getState()).toByteArray()), actorRef);
@@ -1561,7 +1583,8 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
 
     public static class MockNewFollowerRaftActor extends AbstractMockRaftActor {
         public MockNewFollowerRaftActor(ConfigParams config, TestActorRef<MessageCollectorActor> collectorActor) {
 
     public static class MockNewFollowerRaftActor extends AbstractMockRaftActor {
         public MockNewFollowerRaftActor(ConfigParams config, TestActorRef<MessageCollectorActor> collectorActor) {
-            super(NEW_SERVER_ID, Maps.<String, String>newHashMap(), Optional.of(config), NO_PERSISTENCE, collectorActor);
+            super(NEW_SERVER_ID, Maps.<String, String>newHashMap(), Optional.of(config), NO_PERSISTENCE,
+                    collectorActor);
             setPersistence(false);
         }
 
             setPersistence(false);
         }
 
index 406ed3c..b9b63dc 100644 (file)
@@ -13,6 +13,7 @@ import static org.mockito.Matchers.eq;
 import static org.mockito.Matchers.same;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Matchers.same;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.verify;
+
 import akka.actor.ActorRef;
 import akka.persistence.SaveSnapshotFailure;
 import akka.persistence.SaveSnapshotSuccess;
 import akka.actor.ActorRef;
 import akka.persistence.SaveSnapshotFailure;
 import akka.persistence.SaveSnapshotSuccess;
index 7654648..7477f14 100644 (file)
@@ -25,6 +25,7 @@ import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.reset;
 import static org.mockito.Mockito.timeout;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.reset;
 import static org.mockito.Mockito.timeout;
 import static org.mockito.Mockito.verify;
+
 import akka.actor.ActorRef;
 import akka.actor.PoisonPill;
 import akka.actor.Props;
 import akka.actor.ActorRef;
 import akka.actor.PoisonPill;
 import akka.actor.Props;
@@ -99,7 +100,7 @@ public class RaftActorTest extends AbstractActorTest {
     private TestActorFactory factory;
 
     @Before
     private TestActorFactory factory;
 
     @Before
-    public void setUp(){
+    public void setUp() {
         factory = new TestActorFactory(getSystem());
     }
 
         factory = new TestActorFactory(getSystem());
     }
 
@@ -116,7 +117,7 @@ public class RaftActorTest extends AbstractActorTest {
     }
 
     @Test
     }
 
     @Test
-    public void testFindLeaderWhenLeaderIsSelf(){
+    public void testFindLeaderWhenLeaderIsSelf() {
         RaftActorTestKit kit = new RaftActorTestKit(getSystem(), "testFindLeader");
         kit.waitUntilLeader();
     }
         RaftActorTestKit kit = new RaftActorTestKit(getSystem(), "testFindLeader");
         kit.waitUntilLeader();
     }
@@ -126,157 +127,153 @@ public class RaftActorTest extends AbstractActorTest {
     public void testRaftActorRecoveryWithPersistenceEnabled() throws Exception {
         TEST_LOG.info("testRaftActorRecoveryWithPersistenceEnabled starting");
 
     public void testRaftActorRecoveryWithPersistenceEnabled() throws Exception {
         TEST_LOG.info("testRaftActorRecoveryWithPersistenceEnabled starting");
 
-        new JavaTestKit(getSystem()) {{
-            String persistenceId = factory.generateActorId("follower-");
+        JavaTestKit kit = new JavaTestKit(getSystem());
+        String persistenceId = factory.generateActorId("follower-");
 
 
-            DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
+        DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
 
 
-            // Set the heartbeat interval high to essentially disable election otherwise the test
-            // may fail if the actor is switched to Leader and the commitIndex is set to the last
-            // log entry.
-            config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
+        // Set the heartbeat interval high to essentially disable election otherwise the test
+        // may fail if the actor is switched to Leader and the commitIndex is set to the last
+        // log entry.
+        config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
 
 
-            ImmutableMap<String, String> peerAddresses = ImmutableMap.<String, String>builder().put("member1", "address").build();
-            ActorRef followerActor = factory.createActor(MockRaftActor.props(persistenceId,
-                    peerAddresses, config), persistenceId);
+        ImmutableMap<String, String> peerAddresses = ImmutableMap.<String, String>builder()
+                .put("member1", "address").build();
+        ActorRef followerActor = factory.createActor(MockRaftActor.props(persistenceId,
+                peerAddresses, config), persistenceId);
 
 
-            watch(followerActor);
+        kit.watch(followerActor);
 
 
-            List<ReplicatedLogEntry> snapshotUnappliedEntries = new ArrayList<>();
-            ReplicatedLogEntry entry1 = new MockRaftActorContext.MockReplicatedLogEntry(1, 4,
-                    new MockRaftActorContext.MockPayload("E"));
-            snapshotUnappliedEntries.add(entry1);
+        List<ReplicatedLogEntry> snapshotUnappliedEntries = new ArrayList<>();
+        ReplicatedLogEntry entry1 = new MockRaftActorContext.MockReplicatedLogEntry(1, 4,
+                new MockRaftActorContext.MockPayload("E"));
+        snapshotUnappliedEntries.add(entry1);
 
 
-            int lastAppliedDuringSnapshotCapture = 3;
-            int lastIndexDuringSnapshotCapture = 4;
+        int lastAppliedDuringSnapshotCapture = 3;
+        int lastIndexDuringSnapshotCapture = 4;
 
 
-            // 4 messages as part of snapshot, which are applied to state
-            ByteString snapshotBytes = fromObject(Arrays.asList(
-                    new MockRaftActorContext.MockPayload("A"),
-                    new MockRaftActorContext.MockPayload("B"),
-                    new MockRaftActorContext.MockPayload("C"),
-                    new MockRaftActorContext.MockPayload("D")));
+        // 4 messages as part of snapshot, which are applied to state
+        ByteString snapshotBytes = fromObject(Arrays.asList(
+                new MockRaftActorContext.MockPayload("A"),
+                new MockRaftActorContext.MockPayload("B"),
+                new MockRaftActorContext.MockPayload("C"),
+                new MockRaftActorContext.MockPayload("D")));
+
+        Snapshot snapshot = Snapshot.create(snapshotBytes.toByteArray(),
+                snapshotUnappliedEntries, lastIndexDuringSnapshotCapture, 1,
+                lastAppliedDuringSnapshotCapture, 1);
+        InMemorySnapshotStore.addSnapshot(persistenceId, snapshot);
+
+        // 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));
+        entries.add(entry2);
+        entries.add(entry3);
+        entries.add(entry4);
+
+        final int lastAppliedToState = 5;
+        final int lastIndex = 7;
+
+        InMemoryJournal.addEntry(persistenceId, 5, entry2);
+        // 2 entries are applied to state besides the 4 entries in snapshot
+        InMemoryJournal.addEntry(persistenceId, 6, new ApplyJournalEntries(lastAppliedToState));
+        InMemoryJournal.addEntry(persistenceId, 7, entry3);
+        InMemoryJournal.addEntry(persistenceId, 8, entry4);
+
+        // kill the actor
+        followerActor.tell(PoisonPill.getInstance(), null);
+        kit.expectMsgClass(JavaTestKit.duration("5 seconds"), Terminated.class);
+
+        kit.unwatch(followerActor);
+
+        //reinstate the actor
+        TestActorRef<MockRaftActor> ref = factory.createTestActor(
+                MockRaftActor.props(persistenceId, peerAddresses, config));
+
+        MockRaftActor mockRaftActor = ref.underlyingActor();
 
 
-            Snapshot snapshot = Snapshot.create(snapshotBytes.toByteArray(),
-                    snapshotUnappliedEntries, lastIndexDuringSnapshotCapture, 1,
-                    lastAppliedDuringSnapshotCapture, 1);
-            InMemorySnapshotStore.addSnapshot(persistenceId, snapshot);
+        mockRaftActor.waitForRecoveryComplete();
 
 
-            // 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));
-            entries.add(entry2);
-            entries.add(entry3);
-            entries.add(entry4);
+        RaftActorContext context = mockRaftActor.getRaftActorContext();
+        assertEquals("Journal log size", snapshotUnappliedEntries.size() + entries.size(),
+                context.getReplicatedLog().size());
+        assertEquals("Journal data size", 10, context.getReplicatedLog().dataSize());
+        assertEquals("Last index", lastIndex, context.getReplicatedLog().lastIndex());
+        assertEquals("Last applied", lastAppliedToState, context.getLastApplied());
+        assertEquals("Commit index", lastAppliedToState, context.getCommitIndex());
+        assertEquals("Recovered state size", 6, mockRaftActor.getState().size());
 
 
-            int lastAppliedToState = 5;
-            int lastIndex = 7;
+        mockRaftActor.waitForInitializeBehaviorComplete();
 
 
-            InMemoryJournal.addEntry(persistenceId, 5, entry2);
-            // 2 entries are applied to state besides the 4 entries in snapshot
-            InMemoryJournal.addEntry(persistenceId, 6, new ApplyJournalEntries(lastAppliedToState));
-            InMemoryJournal.addEntry(persistenceId, 7, entry3);
-            InMemoryJournal.addEntry(persistenceId, 8, entry4);
+        assertEquals("getRaftState", RaftState.Follower, mockRaftActor.getRaftState());
 
 
-            // kill the actor
-            followerActor.tell(PoisonPill.getInstance(), null);
-            expectMsgClass(duration("5 seconds"), Terminated.class);
+        TEST_LOG.info("testRaftActorRecoveryWithPersistenceEnabled ending");
+    }
 
 
-            unwatch(followerActor);
+    @Test
+    public void testRaftActorRecoveryWithPersistenceDisabled() throws Exception {
+        String persistenceId = factory.generateActorId("follower-");
 
 
-            //reinstate the actor
-            TestActorRef<MockRaftActor> ref = factory.createTestActor(
-                    MockRaftActor.props(persistenceId, peerAddresses, config));
+        DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
 
 
-            MockRaftActor mockRaftActor = ref.underlyingActor();
+        config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
 
 
-            mockRaftActor.waitForRecoveryComplete();
+        TestActorRef<MockRaftActor> ref = factory.createTestActor(MockRaftActor.props(persistenceId,
+                ImmutableMap.<String, String>builder().put("member1", "address").build(),
+                config, new NonPersistentDataProvider()), persistenceId);
 
 
-            RaftActorContext context = mockRaftActor.getRaftActorContext();
-            assertEquals("Journal log size", snapshotUnappliedEntries.size() + entries.size(),
-                    context.getReplicatedLog().size());
-            assertEquals("Journal data size", 10, context.getReplicatedLog().dataSize());
-            assertEquals("Last index", lastIndex, context.getReplicatedLog().lastIndex());
-            assertEquals("Last applied", lastAppliedToState, context.getLastApplied());
-            assertEquals("Commit index", lastAppliedToState, context.getCommitIndex());
-            assertEquals("Recovered state size", 6, mockRaftActor.getState().size());
+        MockRaftActor mockRaftActor = ref.underlyingActor();
 
 
-            mockRaftActor.waitForInitializeBehaviorComplete();
+        mockRaftActor.waitForRecoveryComplete();
 
 
-            assertEquals("getRaftState", RaftState.Follower, mockRaftActor.getRaftState());
-        }};
+        mockRaftActor.waitForInitializeBehaviorComplete();
 
 
-        TEST_LOG.info("testRaftActorRecoveryWithPersistenceEnabled ending");
+        assertEquals("getRaftState", RaftState.Follower, mockRaftActor.getRaftState());
     }
 
     @Test
     }
 
     @Test
-    public void testRaftActorRecoveryWithPersistenceDisabled() throws Exception {
-        new JavaTestKit(getSystem()) {{
-            String persistenceId = factory.generateActorId("follower-");
+    public void testUpdateElectionTermPersistedWithPersistenceDisabled() throws Exception {
+        final JavaTestKit kit = new JavaTestKit(getSystem());
+        String persistenceId = factory.generateActorId("follower-");
+        DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
+        config.setHeartBeatInterval(new FiniteDuration(100, TimeUnit.MILLISECONDS));
+        config.setElectionTimeoutFactor(1);
 
 
-            DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
+        InMemoryJournal.addWriteMessagesCompleteLatch(persistenceId, 1);
 
 
-            config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
+        TestActorRef<MockRaftActor> ref = factory.createTestActor(MockRaftActor.props(persistenceId,
+                ImmutableMap.<String, String>builder().put("member1", "address").build(),
+                config, new NonPersistentDataProvider())
+                .withDispatcher(Dispatchers.DefaultDispatcherId()), persistenceId);
 
 
-            TestActorRef<MockRaftActor> ref = factory.createTestActor(MockRaftActor.props(persistenceId,
-                    ImmutableMap.<String, String>builder().put("member1", "address").build(),
-                    config, new NonPersistentDataProvider()), persistenceId);
+        InMemoryJournal.waitForWriteMessagesComplete(persistenceId);
+        List<UpdateElectionTerm> entries = InMemoryJournal.get(persistenceId, UpdateElectionTerm.class);
+        assertEquals("UpdateElectionTerm entries", 1, entries.size());
+        final UpdateElectionTerm updateEntry = entries.get(0);
 
 
-            MockRaftActor mockRaftActor = ref.underlyingActor();
+        factory.killActor(ref, kit);
 
 
-            mockRaftActor.waitForRecoveryComplete();
+        config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
+        ref = factory.createTestActor(MockRaftActor.props(persistenceId,
+                ImmutableMap.<String, String>builder().put("member1", "address").build(), config,
+                new NonPersistentDataProvider()).withDispatcher(Dispatchers.DefaultDispatcherId()),
+                factory.generateActorId("follower-"));
 
 
-            mockRaftActor.waitForInitializeBehaviorComplete();
+        MockRaftActor actor = ref.underlyingActor();
+        actor.waitForRecoveryComplete();
 
 
-            assertEquals("getRaftState", RaftState.Follower, mockRaftActor.getRaftState());
-        }};
-    }
+        RaftActorContext newContext = actor.getRaftActorContext();
+        assertEquals("electionTerm", updateEntry.getCurrentTerm(),
+                newContext.getTermInformation().getCurrentTerm());
+        assertEquals("votedFor", updateEntry.getVotedFor(), newContext.getTermInformation().getVotedFor());
 
 
-    @Test
-    public void testUpdateElectionTermPersistedWithPersistenceDisabled() throws Exception {
-        new JavaTestKit(getSystem()) {{
-            String persistenceId = factory.generateActorId("follower-");
-            DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
-            config.setHeartBeatInterval(new FiniteDuration(100, TimeUnit.MILLISECONDS));
-            config.setElectionTimeoutFactor(1);
-
-            InMemoryJournal.addWriteMessagesCompleteLatch(persistenceId, 1);
-
-            TestActorRef<MockRaftActor> ref = factory.createTestActor(MockRaftActor.props(persistenceId,
-                    ImmutableMap.<String, String>builder().put("member1", "address").build(),
-                    config, new NonPersistentDataProvider()).
-                            withDispatcher(Dispatchers.DefaultDispatcherId()), persistenceId);
-
-            InMemoryJournal.waitForWriteMessagesComplete(persistenceId);
-            List<UpdateElectionTerm> entries = InMemoryJournal.get(persistenceId, UpdateElectionTerm.class);
-            assertEquals("UpdateElectionTerm entries", 1, entries.size());
-            UpdateElectionTerm updateEntry = entries.get(0);
-
-            factory.killActor(ref, this);
-
-            config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
-            ref = factory.createTestActor(MockRaftActor.props(persistenceId,
-                    ImmutableMap.<String, String>builder().put("member1", "address").build(), config,
-                    new NonPersistentDataProvider()).
-                            withDispatcher(Dispatchers.DefaultDispatcherId()),
-                            factory.generateActorId("follower-"));
-
-            MockRaftActor actor = ref.underlyingActor();
-            actor.waitForRecoveryComplete();
-
-            RaftActorContext newContext = actor.getRaftActorContext();
-            assertEquals("electionTerm", updateEntry.getCurrentTerm(),
-                    newContext.getTermInformation().getCurrentTerm());
-            assertEquals("votedFor", updateEntry.getVotedFor(), newContext.getTermInformation().getVotedFor());
-
-            entries = InMemoryJournal.get(persistenceId, UpdateElectionTerm.class);
-            assertEquals("UpdateElectionTerm entries", 1, entries.size());
-        }};
+        entries = InMemoryJournal.get(persistenceId, UpdateElectionTerm.class);
+        assertEquals("UpdateElectionTerm entries", 1, entries.size());
     }
 
     @Test
     }
 
     @Test
@@ -332,8 +329,8 @@ public class RaftActorTest extends AbstractActorTest {
 
         RaftActorSnapshotMessageSupport mockSupport = mock(RaftActorSnapshotMessageSupport.class);
 
 
         RaftActorSnapshotMessageSupport mockSupport = mock(RaftActorSnapshotMessageSupport.class);
 
-        TestActorRef<MockRaftActor> mockActorRef = factory.createTestActor(MockRaftActor.builder().id(persistenceId).
-                config(config).snapshotMessageSupport(mockSupport).props());
+        TestActorRef<MockRaftActor> mockActorRef = factory.createTestActor(MockRaftActor.builder().id(persistenceId)
+                .config(config).snapshotMessageSupport(mockSupport).props());
 
         MockRaftActor mockRaftActor = mockActorRef.underlyingActor();
 
 
         MockRaftActor mockRaftActor = mockActorRef.underlyingActor();
 
@@ -356,7 +353,8 @@ public class RaftActorTest extends AbstractActorTest {
         doReturn(true).when(mockSupport).handleSnapshotMessage(same(saveSnapshotSuccess), any(ActorRef.class));
         mockRaftActor.handleCommand(saveSnapshotSuccess);
 
         doReturn(true).when(mockSupport).handleSnapshotMessage(same(saveSnapshotSuccess), any(ActorRef.class));
         mockRaftActor.handleCommand(saveSnapshotSuccess);
 
-        SaveSnapshotFailure saveSnapshotFailure = new SaveSnapshotFailure(new SnapshotMetadata("", 0L, 0L), new Throwable());
+        SaveSnapshotFailure saveSnapshotFailure = new SaveSnapshotFailure(new SnapshotMetadata("", 0L, 0L),
+                new Throwable());
         doReturn(true).when(mockSupport).handleSnapshotMessage(same(saveSnapshotFailure), any(ActorRef.class));
         mockRaftActor.handleCommand(saveSnapshotFailure);
 
         doReturn(true).when(mockSupport).handleSnapshotMessage(same(saveSnapshotFailure), any(ActorRef.class));
         mockRaftActor.handleCommand(saveSnapshotFailure);
 
@@ -377,585 +375,547 @@ public class RaftActorTest extends AbstractActorTest {
         verify(mockSupport).handleSnapshotMessage(same(GetSnapshot.INSTANCE), any(ActorRef.class));
     }
 
         verify(mockSupport).handleSnapshotMessage(same(GetSnapshot.INSTANCE), any(ActorRef.class));
     }
 
+    @SuppressWarnings("unchecked")
     @Test
     public void testApplyJournalEntriesCallsDataPersistence() throws Exception {
     @Test
     public void testApplyJournalEntriesCallsDataPersistence() throws Exception {
-        new JavaTestKit(getSystem()) {
-            {
-                String persistenceId = factory.generateActorId("leader-");
-
-                DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
-
-                config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
+        String persistenceId = factory.generateActorId("leader-");
 
 
-                DataPersistenceProvider dataPersistenceProvider = mock(DataPersistenceProvider.class);
+        DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
 
 
-                TestActorRef<MockRaftActor> mockActorRef = factory.createTestActor(MockRaftActor.props(persistenceId,
-                        Collections.<String, String>emptyMap(), config, dataPersistenceProvider), persistenceId);
+        config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
 
 
-                MockRaftActor mockRaftActor = mockActorRef.underlyingActor();
+        DataPersistenceProvider dataPersistenceProvider = mock(DataPersistenceProvider.class);
 
 
-                mockRaftActor.waitForInitializeBehaviorComplete();
+        TestActorRef<MockRaftActor> mockActorRef = factory.createTestActor(MockRaftActor.props(persistenceId,
+                Collections.<String, String>emptyMap(), config, dataPersistenceProvider), persistenceId);
 
 
-                mockRaftActor.waitUntilLeader();
+        MockRaftActor mockRaftActor = mockActorRef.underlyingActor();
 
 
-                mockRaftActor.onReceiveCommand(new ApplyJournalEntries(10));
+        mockRaftActor.waitForInitializeBehaviorComplete();
 
 
-                verify(dataPersistenceProvider).persist(any(ApplyJournalEntries.class), any(Procedure.class));
+        mockRaftActor.waitUntilLeader();
 
 
-            }
+        mockRaftActor.onReceiveCommand(new ApplyJournalEntries(10));
 
 
-        };
+        verify(dataPersistenceProvider).persist(any(ApplyJournalEntries.class), any(Procedure.class));
     }
 
     @Test
     public void testApplyState() throws Exception {
     }
 
     @Test
     public void testApplyState() throws Exception {
+        String persistenceId = factory.generateActorId("leader-");
 
 
-        new JavaTestKit(getSystem()) {
-            {
-                String persistenceId = factory.generateActorId("leader-");
-
-                DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
-
-                config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
+        DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
 
 
-                DataPersistenceProvider dataPersistenceProvider = mock(DataPersistenceProvider.class);
+        config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
 
 
-                TestActorRef<MockRaftActor> mockActorRef = factory.createTestActor(MockRaftActor.props(persistenceId,
-                        Collections.<String, String>emptyMap(), config, dataPersistenceProvider), persistenceId);
+        DataPersistenceProvider dataPersistenceProvider = mock(DataPersistenceProvider.class);
 
 
-                MockRaftActor mockRaftActor = mockActorRef.underlyingActor();
+        TestActorRef<MockRaftActor> mockActorRef = factory.createTestActor(MockRaftActor.props(persistenceId,
+                Collections.<String, String>emptyMap(), config, dataPersistenceProvider), persistenceId);
 
 
-                mockRaftActor.waitForInitializeBehaviorComplete();
+        MockRaftActor mockRaftActor = mockActorRef.underlyingActor();
 
 
-                ReplicatedLogEntry entry = new MockRaftActorContext.MockReplicatedLogEntry(1, 5,
-                        new MockRaftActorContext.MockPayload("F"));
+        mockRaftActor.waitForInitializeBehaviorComplete();
 
 
-                final Identifier id = new MockIdentifier("apply-state");
-                mockRaftActor.onReceiveCommand(new ApplyState(mockActorRef, id, entry));
+        ReplicatedLogEntry entry = new MockRaftActorContext.MockReplicatedLogEntry(1, 5,
+                new MockRaftActorContext.MockPayload("F"));
 
 
-                verify(mockRaftActor.actorDelegate).applyState(eq(mockActorRef), eq(id), anyObject());
+        final Identifier id = new MockIdentifier("apply-state");
+        mockRaftActor.onReceiveCommand(new ApplyState(mockActorRef, id, entry));
 
 
-            }
-        };
+        verify(mockRaftActor.actorDelegate).applyState(eq(mockActorRef), eq(id), anyObject());
     }
 
     @Test
     public void testRaftRoleChangeNotifierWhenRaftActorHasNoPeers() throws Exception {
     }
 
     @Test
     public void testRaftRoleChangeNotifierWhenRaftActorHasNoPeers() throws Exception {
-        new JavaTestKit(getSystem()) {{
-            TestActorRef<MessageCollectorActor> notifierActor = factory.createTestActor(
-                    Props.create(MessageCollectorActor.class));
-            MessageCollectorActor.waitUntilReady(notifierActor);
+        TestActorRef<MessageCollectorActor> notifierActor = factory.createTestActor(
+                Props.create(MessageCollectorActor.class));
+        MessageCollectorActor.waitUntilReady(notifierActor);
 
 
-            DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
-            long heartBeatInterval = 100;
-            config.setHeartBeatInterval(FiniteDuration.create(heartBeatInterval, TimeUnit.MILLISECONDS));
-            config.setElectionTimeoutFactor(20);
+        DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
+        long heartBeatInterval = 100;
+        config.setHeartBeatInterval(FiniteDuration.create(heartBeatInterval, TimeUnit.MILLISECONDS));
+        config.setElectionTimeoutFactor(20);
 
 
-            String persistenceId = factory.generateActorId("notifier-");
+        String persistenceId = factory.generateActorId("notifier-");
 
 
-            TestActorRef<MockRaftActor> raftActorRef = factory.createTestActor(MockRaftActor.builder().id(persistenceId).
-                    config(config).roleChangeNotifier(notifierActor).dataPersistenceProvider(
-                            new NonPersistentDataProvider()).props().withDispatcher(Dispatchers.DefaultDispatcherId()),
-                            persistenceId);
+        final TestActorRef<MockRaftActor> raftActorRef = factory.createTestActor(MockRaftActor.builder()
+                .id(persistenceId).config(config).roleChangeNotifier(notifierActor).dataPersistenceProvider(
+                        new NonPersistentDataProvider()).props().withDispatcher(Dispatchers.DefaultDispatcherId()),
+                persistenceId);
 
 
-            List<RoleChanged> matches =  MessageCollectorActor.expectMatching(notifierActor, RoleChanged.class, 3);
+        List<RoleChanged> matches =  MessageCollectorActor.expectMatching(notifierActor, RoleChanged.class, 3);
 
 
 
 
-            // check if the notifier got a role change from null to Follower
-            RoleChanged raftRoleChanged = matches.get(0);
-            assertEquals(persistenceId, raftRoleChanged.getMemberId());
-            assertNull(raftRoleChanged.getOldRole());
-            assertEquals(RaftState.Follower.name(), raftRoleChanged.getNewRole());
+        // check if the notifier got a role change from null to Follower
+        RoleChanged raftRoleChanged = matches.get(0);
+        assertEquals(persistenceId, raftRoleChanged.getMemberId());
+        assertNull(raftRoleChanged.getOldRole());
+        assertEquals(RaftState.Follower.name(), raftRoleChanged.getNewRole());
 
 
-            // check if the notifier got a role change from Follower to Candidate
-            raftRoleChanged = matches.get(1);
-            assertEquals(persistenceId, raftRoleChanged.getMemberId());
-            assertEquals(RaftState.Follower.name(), raftRoleChanged.getOldRole());
-            assertEquals(RaftState.Candidate.name(), raftRoleChanged.getNewRole());
+        // check if the notifier got a role change from Follower to Candidate
+        raftRoleChanged = matches.get(1);
+        assertEquals(persistenceId, raftRoleChanged.getMemberId());
+        assertEquals(RaftState.Follower.name(), raftRoleChanged.getOldRole());
+        assertEquals(RaftState.Candidate.name(), raftRoleChanged.getNewRole());
 
 
-            // check if the notifier got a role change from Candidate to Leader
-            raftRoleChanged = matches.get(2);
-            assertEquals(persistenceId, raftRoleChanged.getMemberId());
-            assertEquals(RaftState.Candidate.name(), raftRoleChanged.getOldRole());
-            assertEquals(RaftState.Leader.name(), raftRoleChanged.getNewRole());
+        // check if the notifier got a role change from Candidate to Leader
+        raftRoleChanged = matches.get(2);
+        assertEquals(persistenceId, raftRoleChanged.getMemberId());
+        assertEquals(RaftState.Candidate.name(), raftRoleChanged.getOldRole());
+        assertEquals(RaftState.Leader.name(), raftRoleChanged.getNewRole());
 
 
-            LeaderStateChanged leaderStateChange = MessageCollectorActor.expectFirstMatching(
-                    notifierActor, LeaderStateChanged.class);
+        LeaderStateChanged leaderStateChange = MessageCollectorActor.expectFirstMatching(
+                notifierActor, LeaderStateChanged.class);
 
 
-            assertEquals(raftRoleChanged.getMemberId(), leaderStateChange.getLeaderId());
-            assertEquals(MockRaftActor.PAYLOAD_VERSION, leaderStateChange.getLeaderPayloadVersion());
+        assertEquals(raftRoleChanged.getMemberId(), leaderStateChange.getLeaderId());
+        assertEquals(MockRaftActor.PAYLOAD_VERSION, leaderStateChange.getLeaderPayloadVersion());
 
 
-            notifierActor.underlyingActor().clear();
+        notifierActor.underlyingActor().clear();
 
 
-            MockRaftActor raftActor = raftActorRef.underlyingActor();
-            final String newLeaderId = "new-leader";
-            final short newLeaderVersion = 6;
-            Follower follower = new Follower(raftActor.getRaftActorContext()) {
-                @Override
-                public RaftActorBehavior handleMessage(ActorRef sender, Object message) {
-                    setLeaderId(newLeaderId);
-                    setLeaderPayloadVersion(newLeaderVersion);
-                    return this;
-                }
-            };
+        MockRaftActor raftActor = raftActorRef.underlyingActor();
+        final String newLeaderId = "new-leader";
+        final short newLeaderVersion = 6;
+        Follower follower = new Follower(raftActor.getRaftActorContext()) {
+            @Override
+            public RaftActorBehavior handleMessage(ActorRef sender, Object message) {
+                setLeaderId(newLeaderId);
+                setLeaderPayloadVersion(newLeaderVersion);
+                return this;
+            }
+        };
 
 
-            raftActor.newBehavior(follower);
+        raftActor.newBehavior(follower);
 
 
-            leaderStateChange = MessageCollectorActor.expectFirstMatching(notifierActor, LeaderStateChanged.class);
-            assertEquals(persistenceId, leaderStateChange.getMemberId());
-            assertEquals(null, leaderStateChange.getLeaderId());
+        leaderStateChange = MessageCollectorActor.expectFirstMatching(notifierActor, LeaderStateChanged.class);
+        assertEquals(persistenceId, leaderStateChange.getMemberId());
+        assertEquals(null, leaderStateChange.getLeaderId());
 
 
-            raftRoleChanged = MessageCollectorActor.expectFirstMatching(notifierActor, RoleChanged.class);
-            assertEquals(RaftState.Leader.name(), raftRoleChanged.getOldRole());
-            assertEquals(RaftState.Follower.name(), raftRoleChanged.getNewRole());
+        raftRoleChanged = MessageCollectorActor.expectFirstMatching(notifierActor, RoleChanged.class);
+        assertEquals(RaftState.Leader.name(), raftRoleChanged.getOldRole());
+        assertEquals(RaftState.Follower.name(), raftRoleChanged.getNewRole());
 
 
-            notifierActor.underlyingActor().clear();
+        notifierActor.underlyingActor().clear();
 
 
-            raftActor.handleCommand("any");
+        raftActor.handleCommand("any");
 
 
-            leaderStateChange = MessageCollectorActor.expectFirstMatching(notifierActor, LeaderStateChanged.class);
-            assertEquals(persistenceId, leaderStateChange.getMemberId());
-            assertEquals(newLeaderId, leaderStateChange.getLeaderId());
-            assertEquals(newLeaderVersion, leaderStateChange.getLeaderPayloadVersion());
+        leaderStateChange = MessageCollectorActor.expectFirstMatching(notifierActor, LeaderStateChanged.class);
+        assertEquals(persistenceId, leaderStateChange.getMemberId());
+        assertEquals(newLeaderId, leaderStateChange.getLeaderId());
+        assertEquals(newLeaderVersion, leaderStateChange.getLeaderPayloadVersion());
 
 
-            notifierActor.underlyingActor().clear();
+        notifierActor.underlyingActor().clear();
 
 
-            raftActor.handleCommand("any");
+        raftActor.handleCommand("any");
 
 
-            Uninterruptibles.sleepUninterruptibly(505, TimeUnit.MILLISECONDS);
-            leaderStateChange = MessageCollectorActor.getFirstMatching(notifierActor, LeaderStateChanged.class);
-            assertNull(leaderStateChange);
-        }};
+        Uninterruptibles.sleepUninterruptibly(505, TimeUnit.MILLISECONDS);
+        leaderStateChange = MessageCollectorActor.getFirstMatching(notifierActor, LeaderStateChanged.class);
+        assertNull(leaderStateChange);
     }
 
     @Test
     public void testRaftRoleChangeNotifierWhenRaftActorHasPeers() throws Exception {
     }
 
     @Test
     public void testRaftRoleChangeNotifierWhenRaftActorHasPeers() throws Exception {
-        new JavaTestKit(getSystem()) {{
-            ActorRef notifierActor = factory.createActor(Props.create(MessageCollectorActor.class));
-            MessageCollectorActor.waitUntilReady(notifierActor);
-
-            DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
-            long heartBeatInterval = 100;
-            config.setHeartBeatInterval(FiniteDuration.create(heartBeatInterval, TimeUnit.MILLISECONDS));
-            config.setElectionTimeoutFactor(1);
-
-            String persistenceId = factory.generateActorId("notifier-");
-
-            factory.createActor(MockRaftActor.builder().id(persistenceId).
-                    peerAddresses(ImmutableMap.of("leader", "fake/path")).
-                    config(config).roleChangeNotifier(notifierActor).props());
-
-            List<RoleChanged> matches =  null;
-            for(int i = 0; i < 5000 / heartBeatInterval; i++) {
-                matches = MessageCollectorActor.getAllMatching(notifierActor, RoleChanged.class);
-                assertNotNull(matches);
-                if(matches.size() == 3) {
-                    break;
-                }
-                Uninterruptibles.sleepUninterruptibly(heartBeatInterval, TimeUnit.MILLISECONDS);
-            }
+        ActorRef notifierActor = factory.createActor(Props.create(MessageCollectorActor.class));
+        MessageCollectorActor.waitUntilReady(notifierActor);
+
+        DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
+        long heartBeatInterval = 100;
+        config.setHeartBeatInterval(FiniteDuration.create(heartBeatInterval, TimeUnit.MILLISECONDS));
+        config.setElectionTimeoutFactor(1);
 
 
+        String persistenceId = factory.generateActorId("notifier-");
+
+        factory.createActor(MockRaftActor.builder().id(persistenceId)
+                .peerAddresses(ImmutableMap.of("leader", "fake/path"))
+                .config(config).roleChangeNotifier(notifierActor).props());
+
+        List<RoleChanged> matches =  null;
+        for (int i = 0; i < 5000 / heartBeatInterval; i++) {
+            matches = MessageCollectorActor.getAllMatching(notifierActor, RoleChanged.class);
             assertNotNull(matches);
             assertNotNull(matches);
-            assertEquals(2, matches.size());
+            if (matches.size() == 3) {
+                break;
+            }
+            Uninterruptibles.sleepUninterruptibly(heartBeatInterval, TimeUnit.MILLISECONDS);
+        }
 
 
-            // check if the notifier got a role change from null to Follower
-            RoleChanged raftRoleChanged = matches.get(0);
-            assertEquals(persistenceId, raftRoleChanged.getMemberId());
-            assertNull(raftRoleChanged.getOldRole());
-            assertEquals(RaftState.Follower.name(), raftRoleChanged.getNewRole());
+        assertNotNull(matches);
+        assertEquals(2, matches.size());
 
 
-            // check if the notifier got a role change from Follower to Candidate
-            raftRoleChanged = matches.get(1);
-            assertEquals(persistenceId, raftRoleChanged.getMemberId());
-            assertEquals(RaftState.Follower.name(), raftRoleChanged.getOldRole());
-            assertEquals(RaftState.Candidate.name(), raftRoleChanged.getNewRole());
+        // check if the notifier got a role change from null to Follower
+        RoleChanged raftRoleChanged = matches.get(0);
+        assertEquals(persistenceId, raftRoleChanged.getMemberId());
+        assertNull(raftRoleChanged.getOldRole());
+        assertEquals(RaftState.Follower.name(), raftRoleChanged.getNewRole());
 
 
-        }};
+        // check if the notifier got a role change from Follower to Candidate
+        raftRoleChanged = matches.get(1);
+        assertEquals(persistenceId, raftRoleChanged.getMemberId());
+        assertEquals(RaftState.Follower.name(), raftRoleChanged.getOldRole());
+        assertEquals(RaftState.Candidate.name(), raftRoleChanged.getNewRole());
     }
 
     @Test
     public void testFakeSnapshotsForLeaderWithInRealSnapshots() throws Exception {
     }
 
     @Test
     public void testFakeSnapshotsForLeaderWithInRealSnapshots() throws Exception {
-        new JavaTestKit(getSystem()) {
-            {
-                String persistenceId = factory.generateActorId("leader-");
-                String follower1Id = factory.generateActorId("follower-");
-
-                ActorRef followerActor1 =
-                        factory.createActor(Props.create(MessageCollectorActor.class));
+        final String persistenceId = factory.generateActorId("leader-");
+        final String follower1Id = factory.generateActorId("follower-");
 
 
-                DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
-                config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
-                config.setIsolatedLeaderCheckInterval(new FiniteDuration(1, TimeUnit.DAYS));
+        ActorRef followerActor1 =
+                factory.createActor(Props.create(MessageCollectorActor.class));
 
 
-                DataPersistenceProvider dataPersistenceProvider = mock(DataPersistenceProvider.class);
+        DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
+        config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
+        config.setIsolatedLeaderCheckInterval(new FiniteDuration(1, TimeUnit.DAYS));
 
 
-                Map<String, String> peerAddresses = new HashMap<>();
-                peerAddresses.put(follower1Id, followerActor1.path().toString());
+        DataPersistenceProvider dataPersistenceProvider = mock(DataPersistenceProvider.class);
 
 
-                TestActorRef<MockRaftActor> mockActorRef = factory.createTestActor(
-                        MockRaftActor.props(persistenceId, peerAddresses, config, dataPersistenceProvider), persistenceId);
+        Map<String, String> peerAddresses = new HashMap<>();
+        peerAddresses.put(follower1Id, followerActor1.path().toString());
 
 
-                MockRaftActor leaderActor = mockActorRef.underlyingActor();
+        TestActorRef<MockRaftActor> mockActorRef = factory.createTestActor(
+                MockRaftActor.props(persistenceId, peerAddresses, config, dataPersistenceProvider), persistenceId);
 
 
-                leaderActor.getRaftActorContext().setCommitIndex(4);
-                leaderActor.getRaftActorContext().setLastApplied(4);
-                leaderActor.getRaftActorContext().getTermInformation().update(1, persistenceId);
+        MockRaftActor leaderActor = mockActorRef.underlyingActor();
 
 
-                leaderActor.waitForInitializeBehaviorComplete();
+        leaderActor.getRaftActorContext().setCommitIndex(4);
+        leaderActor.getRaftActorContext().setLastApplied(4);
+        leaderActor.getRaftActorContext().getTermInformation().update(1, persistenceId);
 
 
-                // create 8 entries in the log - 0 to 4 are applied and will get picked up as part of the capture snapshot
+        leaderActor.waitForInitializeBehaviorComplete();
 
 
-                Leader leader = new Leader(leaderActor.getRaftActorContext());
-                leaderActor.setCurrentBehavior(leader);
-                assertEquals(RaftState.Leader, leaderActor.getCurrentBehavior().state());
+        // create 8 entries in the log - 0 to 4 are applied and will get picked up as part of the capture snapshot
 
 
-                MockRaftActorContext.MockReplicatedLogBuilder logBuilder = new MockRaftActorContext.MockReplicatedLogBuilder();
-                leaderActor.getRaftActorContext().setReplicatedLog(logBuilder.createEntries(0, 8, 1).build());
+        Leader leader = new Leader(leaderActor.getRaftActorContext());
+        leaderActor.setCurrentBehavior(leader);
+        assertEquals(RaftState.Leader, leaderActor.getCurrentBehavior().state());
 
 
-                assertEquals(8, leaderActor.getReplicatedLog().size());
+        MockRaftActorContext.MockReplicatedLogBuilder logBuilder = new MockRaftActorContext.MockReplicatedLogBuilder();
+        leaderActor.getRaftActorContext().setReplicatedLog(logBuilder.createEntries(0, 8, 1).build());
 
 
-                leaderActor.getRaftActorContext().getSnapshotManager()
-                        .capture(new MockRaftActorContext.MockReplicatedLogEntry(1, 6,
-                                new MockRaftActorContext.MockPayload("x")), 4);
+        assertEquals(8, leaderActor.getReplicatedLog().size());
 
 
-                verify(leaderActor.snapshotCohortDelegate).createSnapshot(any(ActorRef.class));
+        leaderActor.getRaftActorContext().getSnapshotManager().capture(
+                new MockRaftActorContext.MockReplicatedLogEntry(1, 6, new MockRaftActorContext.MockPayload("x")), 4);
 
 
-                assertEquals(8, leaderActor.getReplicatedLog().size());
+        verify(leaderActor.snapshotCohortDelegate).createSnapshot(any(ActorRef.class));
 
 
-                assertEquals(RaftState.Leader, leaderActor.getCurrentBehavior().state());
-                //fake snapshot on index 5
-                leaderActor.onReceiveCommand(new AppendEntriesReply(follower1Id, 1, true, 5, 1, (short)0));
+        assertEquals(8, leaderActor.getReplicatedLog().size());
 
 
-                assertEquals(8, leaderActor.getReplicatedLog().size());
+        assertEquals(RaftState.Leader, leaderActor.getCurrentBehavior().state());
+        //fake snapshot on index 5
+        leaderActor.onReceiveCommand(new AppendEntriesReply(follower1Id, 1, true, 5, 1, (short)0));
 
 
-                //fake snapshot on index 6
-                assertEquals(RaftState.Leader, leaderActor.getCurrentBehavior().state());
-                leaderActor.onReceiveCommand(new AppendEntriesReply(follower1Id, 1, true, 6, 1, (short)0));
-                assertEquals(8, leaderActor.getReplicatedLog().size());
+        assertEquals(8, leaderActor.getReplicatedLog().size());
 
 
-                assertEquals(RaftState.Leader, leaderActor.getCurrentBehavior().state());
+        //fake snapshot on index 6
+        assertEquals(RaftState.Leader, leaderActor.getCurrentBehavior().state());
+        leaderActor.onReceiveCommand(new AppendEntriesReply(follower1Id, 1, true, 6, 1, (short)0));
+        assertEquals(8, leaderActor.getReplicatedLog().size());
 
 
-                assertEquals(8, leaderActor.getReplicatedLog().size());
+        assertEquals(RaftState.Leader, leaderActor.getCurrentBehavior().state());
 
 
-                ByteString snapshotBytes = fromObject(Arrays.asList(
-                        new MockRaftActorContext.MockPayload("foo-0"),
-                        new MockRaftActorContext.MockPayload("foo-1"),
-                        new MockRaftActorContext.MockPayload("foo-2"),
-                        new MockRaftActorContext.MockPayload("foo-3"),
-                        new MockRaftActorContext.MockPayload("foo-4")));
+        assertEquals(8, leaderActor.getReplicatedLog().size());
 
 
-                leaderActor.getRaftActorContext().getSnapshotManager().persist(snapshotBytes.toByteArray(),
-                        Runtime.getRuntime().totalMemory());
+        ByteString snapshotBytes = fromObject(Arrays.asList(
+                new MockRaftActorContext.MockPayload("foo-0"),
+                new MockRaftActorContext.MockPayload("foo-1"),
+                new MockRaftActorContext.MockPayload("foo-2"),
+                new MockRaftActorContext.MockPayload("foo-3"),
+                new MockRaftActorContext.MockPayload("foo-4")));
 
 
-                assertTrue(leaderActor.getRaftActorContext().getSnapshotManager().isCapturing());
+        leaderActor.getRaftActorContext().getSnapshotManager().persist(snapshotBytes.toByteArray(),
+                Runtime.getRuntime().totalMemory());
 
 
-                // The commit is needed to complete the snapshot creation process
-                leaderActor.getRaftActorContext().getSnapshotManager().commit(-1, -1);
+        assertTrue(leaderActor.getRaftActorContext().getSnapshotManager().isCapturing());
 
 
-                // capture snapshot reply should remove the snapshotted entries only
-                assertEquals(3, leaderActor.getReplicatedLog().size());
-                assertEquals(7, leaderActor.getReplicatedLog().lastIndex());
+        // The commit is needed to complete the snapshot creation process
+        leaderActor.getRaftActorContext().getSnapshotManager().commit(-1, -1);
 
 
-                // add another non-replicated entry
-                leaderActor.getReplicatedLog().append(
-                        new ReplicatedLogImplEntry(8, 1, new MockRaftActorContext.MockPayload("foo-8")));
+        // capture snapshot reply should remove the snapshotted entries only
+        assertEquals(3, leaderActor.getReplicatedLog().size());
+        assertEquals(7, leaderActor.getReplicatedLog().lastIndex());
 
 
-                //fake snapshot on index 7, since lastApplied = 7 , we would keep the last applied
-                leaderActor.onReceiveCommand(new AppendEntriesReply(follower1Id, 1, true, 7, 1, (short)0));
-                assertEquals(2, leaderActor.getReplicatedLog().size());
-                assertEquals(8, leaderActor.getReplicatedLog().lastIndex());
+        // add another non-replicated entry
+        leaderActor.getReplicatedLog().append(
+                new ReplicatedLogImplEntry(8, 1, new MockRaftActorContext.MockPayload("foo-8")));
 
 
-            }
-        };
+        //fake snapshot on index 7, since lastApplied = 7 , we would keep the last applied
+        leaderActor.onReceiveCommand(new AppendEntriesReply(follower1Id, 1, true, 7, 1, (short)0));
+        assertEquals(2, leaderActor.getReplicatedLog().size());
+        assertEquals(8, leaderActor.getReplicatedLog().lastIndex());
     }
 
     @Test
     public void testFakeSnapshotsForFollowerWithInRealSnapshots() throws Exception {
     }
 
     @Test
     public void testFakeSnapshotsForFollowerWithInRealSnapshots() throws Exception {
-        new JavaTestKit(getSystem()) {
-            {
-                String persistenceId = factory.generateActorId("follower-");
-                String leaderId = factory.generateActorId("leader-");
+        final String persistenceId = factory.generateActorId("follower-");
+        final String leaderId = factory.generateActorId("leader-");
 
 
 
 
-                ActorRef leaderActor1 =
-                        factory.createActor(Props.create(MessageCollectorActor.class));
+        ActorRef leaderActor1 =
+                factory.createActor(Props.create(MessageCollectorActor.class));
 
 
-                DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
-                config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
-                config.setIsolatedLeaderCheckInterval(new FiniteDuration(1, TimeUnit.DAYS));
+        DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
+        config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
+        config.setIsolatedLeaderCheckInterval(new FiniteDuration(1, TimeUnit.DAYS));
 
 
-                DataPersistenceProvider dataPersistenceProvider = mock(DataPersistenceProvider.class);
+        DataPersistenceProvider dataPersistenceProvider = mock(DataPersistenceProvider.class);
 
 
-                Map<String, String> peerAddresses = new HashMap<>();
-                peerAddresses.put(leaderId, leaderActor1.path().toString());
+        Map<String, String> peerAddresses = new HashMap<>();
+        peerAddresses.put(leaderId, leaderActor1.path().toString());
 
 
-                TestActorRef<MockRaftActor> mockActorRef = factory.createTestActor(
-                        MockRaftActor.props(persistenceId, peerAddresses, config, dataPersistenceProvider), persistenceId);
+        TestActorRef<MockRaftActor> mockActorRef = factory.createTestActor(
+                MockRaftActor.props(persistenceId, peerAddresses, config, dataPersistenceProvider), persistenceId);
 
 
-                MockRaftActor followerActor = mockActorRef.underlyingActor();
-                followerActor.getRaftActorContext().setCommitIndex(4);
-                followerActor.getRaftActorContext().setLastApplied(4);
-                followerActor.getRaftActorContext().getTermInformation().update(1, persistenceId);
+        MockRaftActor followerActor = mockActorRef.underlyingActor();
+        followerActor.getRaftActorContext().setCommitIndex(4);
+        followerActor.getRaftActorContext().setLastApplied(4);
+        followerActor.getRaftActorContext().getTermInformation().update(1, persistenceId);
 
 
-                followerActor.waitForInitializeBehaviorComplete();
+        followerActor.waitForInitializeBehaviorComplete();
 
 
 
 
-                Follower follower = new Follower(followerActor.getRaftActorContext());
-                followerActor.setCurrentBehavior(follower);
-                assertEquals(RaftState.Follower, followerActor.getCurrentBehavior().state());
+        Follower follower = new Follower(followerActor.getRaftActorContext());
+        followerActor.setCurrentBehavior(follower);
+        assertEquals(RaftState.Follower, followerActor.getCurrentBehavior().state());
 
 
-                // create 6 entries in the log - 0 to 4 are applied and will get picked up as part of the capture snapshot
-                MockRaftActorContext.MockReplicatedLogBuilder logBuilder = new MockRaftActorContext.MockReplicatedLogBuilder();
-                followerActor.getRaftActorContext().setReplicatedLog(logBuilder.createEntries(0, 6, 1).build());
+        // create 6 entries in the log - 0 to 4 are applied and will get picked up as part of the capture snapshot
+        MockRaftActorContext.MockReplicatedLogBuilder logBuilder = new MockRaftActorContext.MockReplicatedLogBuilder();
+        followerActor.getRaftActorContext().setReplicatedLog(logBuilder.createEntries(0, 6, 1).build());
 
 
-                // log has indices 0-5
-                assertEquals(6, followerActor.getReplicatedLog().size());
+        // log has indices 0-5
+        assertEquals(6, followerActor.getReplicatedLog().size());
 
 
-                //snapshot on 4
-                followerActor.getRaftActorContext().getSnapshotManager().capture(
-                        new MockRaftActorContext.MockReplicatedLogEntry(1, 5,
-                                new MockRaftActorContext.MockPayload("D")), 4);
+        //snapshot on 4
+        followerActor.getRaftActorContext().getSnapshotManager().capture(
+                new MockRaftActorContext.MockReplicatedLogEntry(1, 5,
+                        new MockRaftActorContext.MockPayload("D")), 4);
 
 
-                verify(followerActor.snapshotCohortDelegate).createSnapshot(any(ActorRef.class));
+        verify(followerActor.snapshotCohortDelegate).createSnapshot(any(ActorRef.class));
 
 
-                assertEquals(6, followerActor.getReplicatedLog().size());
+        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"))
+        //fake snapshot on index 6
+        List<ReplicatedLogEntry> entries =
+                Arrays.asList(
+                        (ReplicatedLogEntry) new MockRaftActorContext.MockReplicatedLogEntry(1, 6,
+                                new MockRaftActorContext.MockPayload("foo-6"))
                         );
                         );
-                followerActor.onReceiveCommand(new AppendEntries(1, leaderId, 5, 1, entries, 5, 5, (short)0));
-                assertEquals(7, followerActor.getReplicatedLog().size());
+        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());
+        //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 MockRaftActorContext.MockReplicatedLogEntry(1, 7,
+                                new MockRaftActorContext.MockPayload("foo-7"))
                         );
                         );
-                followerActor.onReceiveCommand(new AppendEntries(1, leaderId, 6, 1, entries, 6, 6, (short) 0));
-                assertEquals(8, followerActor.getReplicatedLog().size());
+        followerActor.onReceiveCommand(new AppendEntries(1, leaderId, 6, 1, entries, 6, 6, (short) 0));
+        assertEquals(8, followerActor.getReplicatedLog().size());
 
 
-                assertEquals(RaftState.Follower, followerActor.getCurrentBehavior().state());
+        assertEquals(RaftState.Follower, followerActor.getCurrentBehavior().state());
 
 
 
 
-                ByteString snapshotBytes = fromObject(Arrays.asList(
-                        new MockRaftActorContext.MockPayload("foo-0"),
-                        new MockRaftActorContext.MockPayload("foo-1"),
-                        new MockRaftActorContext.MockPayload("foo-2"),
-                        new MockRaftActorContext.MockPayload("foo-3"),
-                        new MockRaftActorContext.MockPayload("foo-4")));
-                followerActor.onReceiveCommand(new CaptureSnapshotReply(snapshotBytes.toByteArray()));
-                assertTrue(followerActor.getRaftActorContext().getSnapshotManager().isCapturing());
+        ByteString snapshotBytes = fromObject(Arrays.asList(
+                new MockRaftActorContext.MockPayload("foo-0"),
+                new MockRaftActorContext.MockPayload("foo-1"),
+                new MockRaftActorContext.MockPayload("foo-2"),
+                new MockRaftActorContext.MockPayload("foo-3"),
+                new MockRaftActorContext.MockPayload("foo-4")));
+        followerActor.onReceiveCommand(new CaptureSnapshotReply(snapshotBytes.toByteArray()));
+        assertTrue(followerActor.getRaftActorContext().getSnapshotManager().isCapturing());
 
 
-                // The commit is needed to complete the snapshot creation process
-                followerActor.getRaftActorContext().getSnapshotManager().commit(-1, -1);
+        // The commit is needed to complete the snapshot creation process
+        followerActor.getRaftActorContext().getSnapshotManager().commit(-1, -1);
 
 
-                // capture snapshot reply should remove the snapshotted entries only till replicatedToAllIndex
-                assertEquals(3, followerActor.getReplicatedLog().size()); //indexes 5,6,7 left in the log
-                assertEquals(7, followerActor.getReplicatedLog().lastIndex());
+        // capture snapshot reply should remove the snapshotted entries only till replicatedToAllIndex
+        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 MockRaftActorContext.MockReplicatedLogEntry(1, 8,
+                                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));
+        // send an additional entry 8 with leaderCommit = 7
+        followerActor.onReceiveCommand(new AppendEntries(1, leaderId, 7, 1, entries, 7, 7, (short) 0));
 
 
-                // 7 and 8, as lastapplied is 7
-                assertEquals(2, followerActor.getReplicatedLog().size());
-
-            }
-        };
+        // 7 and 8, as lastapplied is 7
+        assertEquals(2, followerActor.getReplicatedLog().size());
     }
 
     @Test
     public void testFakeSnapshotsForLeaderWithInInitiateSnapshots() throws Exception {
     }
 
     @Test
     public void testFakeSnapshotsForLeaderWithInInitiateSnapshots() throws Exception {
-        new JavaTestKit(getSystem()) {
-            {
-                String persistenceId = factory.generateActorId("leader-");
-                String follower1Id = factory.generateActorId("follower-");
-                String follower2Id = factory.generateActorId("follower-");
-
-                ActorRef followerActor1 =
-                        factory.createActor(Props.create(MessageCollectorActor.class), follower1Id);
-                ActorRef followerActor2 =
-                        factory.createActor(Props.create(MessageCollectorActor.class), follower2Id);
-
-                DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
-                config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
-                config.setIsolatedLeaderCheckInterval(new FiniteDuration(1, TimeUnit.DAYS));
-
-                DataPersistenceProvider dataPersistenceProvider = mock(DataPersistenceProvider.class);
-
-                Map<String, String> peerAddresses = new HashMap<>();
-                peerAddresses.put(follower1Id, followerActor1.path().toString());
-                peerAddresses.put(follower2Id, followerActor2.path().toString());
-
-                TestActorRef<MockRaftActor> mockActorRef = factory.createTestActor(
-                        MockRaftActor.props(persistenceId, peerAddresses, config, dataPersistenceProvider), persistenceId);
-
-                MockRaftActor leaderActor = mockActorRef.underlyingActor();
-                leaderActor.getRaftActorContext().setCommitIndex(9);
-                leaderActor.getRaftActorContext().setLastApplied(9);
-                leaderActor.getRaftActorContext().getTermInformation().update(1, persistenceId);
-
-                leaderActor.waitForInitializeBehaviorComplete();
-
-                Leader leader = new Leader(leaderActor.getRaftActorContext());
-                leaderActor.setCurrentBehavior(leader);
-                assertEquals(RaftState.Leader, leaderActor.getCurrentBehavior().state());
-
-                // create 5 entries in the log
-                MockRaftActorContext.MockReplicatedLogBuilder logBuilder = new MockRaftActorContext.MockReplicatedLogBuilder();
-                leaderActor.getRaftActorContext().setReplicatedLog(logBuilder.createEntries(5, 10, 1).build());
-
-                //set the snapshot index to 4 , 0 to 4 are snapshotted
-                leaderActor.getRaftActorContext().getReplicatedLog().setSnapshotIndex(4);
-                //setting replicatedToAllIndex = 9, for the log to clear
-                leader.setReplicatedToAllIndex(9);
-                assertEquals(5, leaderActor.getReplicatedLog().size());
-                assertEquals(RaftState.Leader, leaderActor.getCurrentBehavior().state());
-
-                leaderActor.onReceiveCommand(new AppendEntriesReply(follower1Id, 1, true, 9, 1, (short) 0));
-                assertEquals(5, leaderActor.getReplicatedLog().size());
-                assertEquals(RaftState.Leader, leaderActor.getCurrentBehavior().state());
-
-                // set the 2nd follower nextIndex to 1 which has been snapshotted
-                leaderActor.onReceiveCommand(new AppendEntriesReply(follower2Id, 1, true, 0, 1, (short)0));
-                assertEquals(5, leaderActor.getReplicatedLog().size());
-                assertEquals(RaftState.Leader, leaderActor.getCurrentBehavior().state());
-
-                // simulate a real snapshot
-                leaderActor.onReceiveCommand(SendHeartBeat.INSTANCE);
-                assertEquals(5, leaderActor.getReplicatedLog().size());
-                assertEquals(String.format("expected to be Leader but was %s. Current Leader = %s ",
-                        leaderActor.getCurrentBehavior().state(), leaderActor.getLeaderId())
-                        , RaftState.Leader, leaderActor.getCurrentBehavior().state());
-
-
-                //reply from a slow follower does not initiate a fake snapshot
-                leaderActor.onReceiveCommand(new AppendEntriesReply(follower2Id, 1, true, 9, 1, (short)0));
-                assertEquals("Fake snapshot should not happen when Initiate is in progress", 5, leaderActor.getReplicatedLog().size());
-
-                ByteString snapshotBytes = fromObject(Arrays.asList(
-                        new MockRaftActorContext.MockPayload("foo-0"),
-                        new MockRaftActorContext.MockPayload("foo-1"),
-                        new MockRaftActorContext.MockPayload("foo-2"),
-                        new MockRaftActorContext.MockPayload("foo-3"),
-                        new MockRaftActorContext.MockPayload("foo-4")));
-                leaderActor.onReceiveCommand(new CaptureSnapshotReply(snapshotBytes.toByteArray()));
-                assertTrue(leaderActor.getRaftActorContext().getSnapshotManager().isCapturing());
-
-                assertEquals("Real snapshot didn't clear the log till replicatedToAllIndex", 0, leaderActor.getReplicatedLog().size());
-
-                //reply from a slow follower after should not raise errors
-                leaderActor.onReceiveCommand(new AppendEntriesReply(follower2Id, 1, true, 5, 1, (short) 0));
-                assertEquals(0, leaderActor.getReplicatedLog().size());
-            }
-        };
+        final String persistenceId = factory.generateActorId("leader-");
+        final String follower1Id = factory.generateActorId("follower-");
+        final String follower2Id = factory.generateActorId("follower-");
+
+        final ActorRef followerActor1 = factory.createActor(Props.create(MessageCollectorActor.class), follower1Id);
+        final ActorRef followerActor2 = factory.createActor(Props.create(MessageCollectorActor.class), follower2Id);
+
+        DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
+        config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
+        config.setIsolatedLeaderCheckInterval(new FiniteDuration(1, TimeUnit.DAYS));
+
+        DataPersistenceProvider dataPersistenceProvider = mock(DataPersistenceProvider.class);
+
+        Map<String, String> peerAddresses = new HashMap<>();
+        peerAddresses.put(follower1Id, followerActor1.path().toString());
+        peerAddresses.put(follower2Id, followerActor2.path().toString());
+
+        TestActorRef<MockRaftActor> mockActorRef = factory.createTestActor(
+                MockRaftActor.props(persistenceId, peerAddresses, config, dataPersistenceProvider), persistenceId);
+
+        MockRaftActor leaderActor = mockActorRef.underlyingActor();
+        leaderActor.getRaftActorContext().setCommitIndex(9);
+        leaderActor.getRaftActorContext().setLastApplied(9);
+        leaderActor.getRaftActorContext().getTermInformation().update(1, persistenceId);
+
+        leaderActor.waitForInitializeBehaviorComplete();
+
+        Leader leader = new Leader(leaderActor.getRaftActorContext());
+        leaderActor.setCurrentBehavior(leader);
+        assertEquals(RaftState.Leader, leaderActor.getCurrentBehavior().state());
+
+        // create 5 entries in the log
+        MockRaftActorContext.MockReplicatedLogBuilder logBuilder = new MockRaftActorContext.MockReplicatedLogBuilder();
+        leaderActor.getRaftActorContext().setReplicatedLog(logBuilder.createEntries(5, 10, 1).build());
+
+        //set the snapshot index to 4 , 0 to 4 are snapshotted
+        leaderActor.getRaftActorContext().getReplicatedLog().setSnapshotIndex(4);
+        //setting replicatedToAllIndex = 9, for the log to clear
+        leader.setReplicatedToAllIndex(9);
+        assertEquals(5, leaderActor.getReplicatedLog().size());
+        assertEquals(RaftState.Leader, leaderActor.getCurrentBehavior().state());
+
+        leaderActor.onReceiveCommand(new AppendEntriesReply(follower1Id, 1, true, 9, 1, (short) 0));
+        assertEquals(5, leaderActor.getReplicatedLog().size());
+        assertEquals(RaftState.Leader, leaderActor.getCurrentBehavior().state());
+
+        // set the 2nd follower nextIndex to 1 which has been snapshotted
+        leaderActor.onReceiveCommand(new AppendEntriesReply(follower2Id, 1, true, 0, 1, (short)0));
+        assertEquals(5, leaderActor.getReplicatedLog().size());
+        assertEquals(RaftState.Leader, leaderActor.getCurrentBehavior().state());
+
+        // simulate a real snapshot
+        leaderActor.onReceiveCommand(SendHeartBeat.INSTANCE);
+        assertEquals(5, leaderActor.getReplicatedLog().size());
+        assertEquals(String.format("expected to be Leader but was %s. Current Leader = %s ",
+                leaderActor.getCurrentBehavior().state(), leaderActor.getLeaderId()),
+                RaftState.Leader, leaderActor.getCurrentBehavior().state());
+
+
+        //reply from a slow follower does not initiate a fake snapshot
+        leaderActor.onReceiveCommand(new AppendEntriesReply(follower2Id, 1, true, 9, 1, (short)0));
+        assertEquals("Fake snapshot should not happen when Initiate is in progress", 5,
+                leaderActor.getReplicatedLog().size());
+
+        ByteString snapshotBytes = fromObject(Arrays.asList(
+                new MockRaftActorContext.MockPayload("foo-0"),
+                new MockRaftActorContext.MockPayload("foo-1"),
+                new MockRaftActorContext.MockPayload("foo-2"),
+                new MockRaftActorContext.MockPayload("foo-3"),
+                new MockRaftActorContext.MockPayload("foo-4")));
+        leaderActor.onReceiveCommand(new CaptureSnapshotReply(snapshotBytes.toByteArray()));
+        assertTrue(leaderActor.getRaftActorContext().getSnapshotManager().isCapturing());
+
+        assertEquals("Real snapshot didn't clear the log till replicatedToAllIndex", 0,
+                leaderActor.getReplicatedLog().size());
+
+        //reply from a slow follower after should not raise errors
+        leaderActor.onReceiveCommand(new AppendEntriesReply(follower2Id, 1, true, 5, 1, (short) 0));
+        assertEquals(0, leaderActor.getReplicatedLog().size());
     }
 
     @Test
     public void testRealSnapshotWhenReplicatedToAllIndexMinusOne() throws Exception {
     }
 
     @Test
     public void testRealSnapshotWhenReplicatedToAllIndexMinusOne() throws Exception {
-        new JavaTestKit(getSystem()) {{
-            String persistenceId = factory.generateActorId("leader-");
-            DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
-            config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
-            config.setIsolatedLeaderCheckInterval(new FiniteDuration(1, TimeUnit.DAYS));
-            config.setSnapshotBatchCount(5);
-
-            DataPersistenceProvider dataPersistenceProvider = new NonPersistentDataProvider();
-
-            Map<String, String> peerAddresses = ImmutableMap.<String, String>builder().put("member1", "address").build();
-
-            TestActorRef<MockRaftActor> mockActorRef = factory.createTestActor(
-                    MockRaftActor.props(persistenceId, peerAddresses, config, dataPersistenceProvider), persistenceId);
-
-            MockRaftActor leaderActor = mockActorRef.underlyingActor();
-            leaderActor.getRaftActorContext().setCommitIndex(3);
-            leaderActor.getRaftActorContext().setLastApplied(3);
-            leaderActor.getRaftActorContext().getTermInformation().update(1, persistenceId);
-
-            leaderActor.waitForInitializeBehaviorComplete();
-            for(int i=0;i< 4;i++) {
-                leaderActor.getReplicatedLog()
-                        .append(new MockRaftActorContext.MockReplicatedLogEntry(1, i,
-                                new MockRaftActorContext.MockPayload("A")));
-            }
+        String persistenceId = factory.generateActorId("leader-");
+        DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
+        config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
+        config.setIsolatedLeaderCheckInterval(new FiniteDuration(1, TimeUnit.DAYS));
+        config.setSnapshotBatchCount(5);
+
+        DataPersistenceProvider dataPersistenceProvider = new NonPersistentDataProvider();
 
 
-            Leader leader = new Leader(leaderActor.getRaftActorContext());
-            leaderActor.setCurrentBehavior(leader);
-            assertEquals(RaftState.Leader, leaderActor.getCurrentBehavior().state());
+        Map<String, String> peerAddresses = ImmutableMap.<String, String>builder().put("member1", "address").build();
+
+        TestActorRef<MockRaftActor> mockActorRef = factory.createTestActor(
+                MockRaftActor.props(persistenceId, peerAddresses, config, dataPersistenceProvider), persistenceId);
+
+        MockRaftActor leaderActor = mockActorRef.underlyingActor();
+        leaderActor.getRaftActorContext().setCommitIndex(3);
+        leaderActor.getRaftActorContext().setLastApplied(3);
+        leaderActor.getRaftActorContext().getTermInformation().update(1, persistenceId);
+
+        leaderActor.waitForInitializeBehaviorComplete();
+        for (int i = 0; i < 4; i++) {
+            leaderActor.getReplicatedLog().append(new MockRaftActorContext.MockReplicatedLogEntry(1, i,
+                    new MockRaftActorContext.MockPayload("A")));
+        }
 
 
-            // Simulate an install snaphost to a follower.
-            leaderActor.getRaftActorContext().getSnapshotManager().captureToInstall(
-                    leaderActor.getReplicatedLog().last(), -1, "member1");
+        Leader leader = new Leader(leaderActor.getRaftActorContext());
+        leaderActor.setCurrentBehavior(leader);
+        assertEquals(RaftState.Leader, leaderActor.getCurrentBehavior().state());
 
 
-            // Now send a CaptureSnapshotReply
-            mockActorRef.tell(new CaptureSnapshotReply(fromObject("foo").toByteArray()), mockActorRef);
+        // Simulate an install snaphost to a follower.
+        leaderActor.getRaftActorContext().getSnapshotManager().captureToInstall(
+                leaderActor.getReplicatedLog().last(), -1, "member1");
 
 
-            // Trimming log in this scenario is a no-op
-            assertEquals(-1, leaderActor.getReplicatedLog().getSnapshotIndex());
-            assertTrue(leaderActor.getRaftActorContext().getSnapshotManager().isCapturing());
-            assertEquals(-1, leader.getReplicatedToAllIndex());
+        // Now send a CaptureSnapshotReply
+        mockActorRef.tell(new CaptureSnapshotReply(fromObject("foo").toByteArray()), mockActorRef);
 
 
-        }};
+        // Trimming log in this scenario is a no-op
+        assertEquals(-1, leaderActor.getReplicatedLog().getSnapshotIndex());
+        assertTrue(leaderActor.getRaftActorContext().getSnapshotManager().isCapturing());
+        assertEquals(-1, leader.getReplicatedToAllIndex());
     }
 
     @Test
     public void testRealSnapshotWhenReplicatedToAllIndexNotInReplicatedLog() throws Exception {
     }
 
     @Test
     public void testRealSnapshotWhenReplicatedToAllIndexNotInReplicatedLog() throws Exception {
-        new JavaTestKit(getSystem()) {{
-            String persistenceId = factory.generateActorId("leader-");
-            DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
-            config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
-            config.setIsolatedLeaderCheckInterval(new FiniteDuration(1, TimeUnit.DAYS));
-            config.setSnapshotBatchCount(5);
-
-            DataPersistenceProvider dataPersistenceProvider = new NonPersistentDataProvider();
-
-            Map<String, String> peerAddresses = ImmutableMap.<String, String>builder().put("member1", "address").build();
-
-            TestActorRef<MockRaftActor> mockActorRef = factory.createTestActor(
-                    MockRaftActor.props(persistenceId, peerAddresses, config, dataPersistenceProvider), persistenceId);
-
-            MockRaftActor leaderActor = mockActorRef.underlyingActor();
-            leaderActor.getRaftActorContext().setCommitIndex(3);
-            leaderActor.getRaftActorContext().setLastApplied(3);
-            leaderActor.getRaftActorContext().getTermInformation().update(1, persistenceId);
-            leaderActor.getReplicatedLog().setSnapshotIndex(3);
-
-            leaderActor.waitForInitializeBehaviorComplete();
-            Leader leader = new Leader(leaderActor.getRaftActorContext());
-            leaderActor.setCurrentBehavior(leader);
-            leader.setReplicatedToAllIndex(3);
-            assertEquals(RaftState.Leader, leaderActor.getCurrentBehavior().state());
-
-            // Persist another entry (this will cause a CaptureSnapshot to be triggered
-            leaderActor.persistData(mockActorRef, new MockIdentifier("x"),
-                new MockRaftActorContext.MockPayload("duh"));
+        String persistenceId = factory.generateActorId("leader-");
+        DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
+        config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
+        config.setIsolatedLeaderCheckInterval(new FiniteDuration(1, TimeUnit.DAYS));
+        config.setSnapshotBatchCount(5);
 
 
-            // Now send a CaptureSnapshotReply
-            mockActorRef.tell(new CaptureSnapshotReply(fromObject("foo").toByteArray()), mockActorRef);
+        DataPersistenceProvider dataPersistenceProvider = new NonPersistentDataProvider();
 
 
-            // Trimming log in this scenario is a no-op
-            assertEquals(3, leaderActor.getReplicatedLog().getSnapshotIndex());
-            assertTrue(leaderActor.getRaftActorContext().getSnapshotManager().isCapturing());
-            assertEquals(3, leader.getReplicatedToAllIndex());
+        Map<String, String> peerAddresses = ImmutableMap.<String, String>builder().put("member1", "address").build();
 
 
-        }};
+        TestActorRef<MockRaftActor> mockActorRef = factory.createTestActor(
+                MockRaftActor.props(persistenceId, peerAddresses, config, dataPersistenceProvider), persistenceId);
+
+        MockRaftActor leaderActor = mockActorRef.underlyingActor();
+        leaderActor.getRaftActorContext().setCommitIndex(3);
+        leaderActor.getRaftActorContext().setLastApplied(3);
+        leaderActor.getRaftActorContext().getTermInformation().update(1, persistenceId);
+        leaderActor.getReplicatedLog().setSnapshotIndex(3);
+
+        leaderActor.waitForInitializeBehaviorComplete();
+        Leader leader = new Leader(leaderActor.getRaftActorContext());
+        leaderActor.setCurrentBehavior(leader);
+        leader.setReplicatedToAllIndex(3);
+        assertEquals(RaftState.Leader, leaderActor.getCurrentBehavior().state());
+
+        // Persist another entry (this will cause a CaptureSnapshot to be triggered
+        leaderActor.persistData(mockActorRef, new MockIdentifier("x"),
+                new MockRaftActorContext.MockPayload("duh"));
+
+        // Now send a CaptureSnapshotReply
+        mockActorRef.tell(new CaptureSnapshotReply(fromObject("foo").toByteArray()), mockActorRef);
+
+        // Trimming log in this scenario is a no-op
+        assertEquals(3, leaderActor.getReplicatedLog().getSnapshotIndex());
+        assertTrue(leaderActor.getRaftActorContext().getSnapshotManager().isCapturing());
+        assertEquals(3, leader.getReplicatedToAllIndex());
     }
 
     @Test
     }
 
     @Test
-    public void testSwitchBehavior(){
+    public void testSwitchBehavior() {
         String persistenceId = factory.generateActorId("leader-");
         DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
         String persistenceId = factory.generateActorId("leader-");
         DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
-        config.setCustomRaftPolicyImplementationClass("org.opendaylight.controller.cluster.raft.policy.DisableElectionsRaftPolicy");
+        config.setCustomRaftPolicyImplementationClass(DisableElectionsRaftPolicy.class.getName());
         config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
         config.setIsolatedLeaderCheckInterval(new FiniteDuration(1, TimeUnit.DAYS));
         config.setSnapshotBatchCount(5);
         config.setHeartBeatInterval(new FiniteDuration(1, TimeUnit.DAYS));
         config.setIsolatedLeaderCheckInterval(new FiniteDuration(1, TimeUnit.DAYS));
         config.setSnapshotBatchCount(5);
@@ -993,21 +953,21 @@ public class RaftActorTest extends AbstractActorTest {
     }
 
     public static ByteString fromObject(Object snapshot) throws Exception {
     }
 
     public static ByteString fromObject(Object snapshot) throws Exception {
-        ByteArrayOutputStream b = null;
-        ObjectOutputStream o = null;
+        ByteArrayOutputStream bos = null;
+        ObjectOutputStream os = null;
         try {
         try {
-            b = new ByteArrayOutputStream();
-            o = new ObjectOutputStream(b);
-            o.writeObject(snapshot);
-            byte[] snapshotBytes = b.toByteArray();
+            bos = new ByteArrayOutputStream();
+            os = new ObjectOutputStream(bos);
+            os.writeObject(snapshot);
+            byte[] snapshotBytes = bos.toByteArray();
             return ByteString.copyFrom(snapshotBytes);
         } finally {
             return ByteString.copyFrom(snapshotBytes);
         } finally {
-            if (o != null) {
-                o.flush();
-                o.close();
+            if (os != null) {
+                os.flush();
+                os.close();
             }
             }
-            if (b != null) {
-                b.close();
+            if (bos != null) {
+                bos.close();
             }
         }
     }
             }
         }
     }
@@ -1064,7 +1024,7 @@ public class RaftActorTest extends AbstractActorTest {
     public void testGetSnapshot() throws Exception {
         TEST_LOG.info("testGetSnapshot starting");
 
     public void testGetSnapshot() throws Exception {
         TEST_LOG.info("testGetSnapshot starting");
 
-        JavaTestKit kit = new JavaTestKit(getSystem());
+        final JavaTestKit kit = new JavaTestKit(getSystem());
 
         String persistenceId = factory.generateActorId("test-actor-");
         DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
 
         String persistenceId = factory.generateActorId("test-actor-");
         DefaultConfigParamsImpl config = new DefaultConfigParamsImpl();
@@ -1082,8 +1042,8 @@ public class RaftActorTest extends AbstractActorTest {
                 new MockRaftActorContext.MockPayload("C")));
 
         TestActorRef<MockRaftActor> raftActorRef = factory.createTestActor(MockRaftActor.props(persistenceId,
                 new MockRaftActorContext.MockPayload("C")));
 
         TestActorRef<MockRaftActor> raftActorRef = factory.createTestActor(MockRaftActor.props(persistenceId,
-                ImmutableMap.<String, String>builder().put("member1", "address").build(), config).
-                    withDispatcher(Dispatchers.DefaultDispatcherId()), persistenceId);
+                ImmutableMap.<String, String>builder().put("member1", "address").build(), config)
+                    .withDispatcher(Dispatchers.DefaultDispatcherId()), persistenceId);
         MockRaftActor mockRaftActor = raftActorRef.underlyingActor();
 
         mockRaftActor.waitForRecoveryComplete();
         MockRaftActor mockRaftActor = raftActorRef.underlyingActor();
 
         mockRaftActor.waitForRecoveryComplete();
@@ -1114,7 +1074,8 @@ public class RaftActorTest extends AbstractActorTest {
 
         // Test with timeout
 
 
         // Test with timeout
 
-        mockRaftActor.getSnapshotMessageSupport().setSnapshotReplyActorTimeout(Duration.create(200, TimeUnit.MILLISECONDS));
+        mockRaftActor.getSnapshotMessageSupport().setSnapshotReplyActorTimeout(
+                Duration.create(200, TimeUnit.MILLISECONDS));
         reset(mockRaftActor.snapshotCohortDelegate);
 
         raftActorRef.tell(GetSnapshot.INSTANCE, kit.getRef());
         reset(mockRaftActor.snapshotCohortDelegate);
 
         raftActorRef.tell(GetSnapshot.INSTANCE, kit.getRef());
@@ -1173,9 +1134,9 @@ public class RaftActorTest extends AbstractActorTest {
 
         InMemorySnapshotStore.addSnapshotSavedLatch(persistenceId);
 
 
         InMemorySnapshotStore.addSnapshotSavedLatch(persistenceId);
 
-        TestActorRef<MockRaftActor> raftActorRef = factory.createTestActor(MockRaftActor.builder().id(persistenceId).
-                config(config).restoreFromSnapshot(SerializationUtils.serialize(snapshot)).props().
-                    withDispatcher(Dispatchers.DefaultDispatcherId()), persistenceId);
+        TestActorRef<MockRaftActor> raftActorRef = factory.createTestActor(MockRaftActor.builder().id(persistenceId)
+                .config(config).restoreFromSnapshot(SerializationUtils.serialize(snapshot)).props()
+                    .withDispatcher(Dispatchers.DefaultDispatcherId()), persistenceId);
         MockRaftActor mockRaftActor = raftActorRef.underlyingActor();
 
         mockRaftActor.waitForRecoveryComplete();
         MockRaftActor mockRaftActor = raftActorRef.underlyingActor();
 
         mockRaftActor.waitForRecoveryComplete();
@@ -1208,10 +1169,10 @@ public class RaftActorTest extends AbstractActorTest {
 
         persistenceId = factory.generateActorId("test-actor-");
 
 
         persistenceId = factory.generateActorId("test-actor-");
 
-        raftActorRef = factory.createTestActor(MockRaftActor.builder().id(persistenceId).
-                config(config).restoreFromSnapshot(SerializationUtils.serialize(snapshot)).
-                persistent(Optional.of(Boolean.FALSE)).props().
-                    withDispatcher(Dispatchers.DefaultDispatcherId()), persistenceId);
+        raftActorRef = factory.createTestActor(MockRaftActor.builder().id(persistenceId)
+                .config(config).restoreFromSnapshot(SerializationUtils.serialize(snapshot))
+                .persistent(Optional.of(Boolean.FALSE)).props()
+                    .withDispatcher(Dispatchers.DefaultDispatcherId()), persistenceId);
         mockRaftActor = raftActorRef.underlyingActor();
 
         mockRaftActor.waitForRecoveryComplete();
         mockRaftActor = raftActorRef.underlyingActor();
 
         mockRaftActor.waitForRecoveryComplete();
@@ -1240,9 +1201,9 @@ public class RaftActorTest extends AbstractActorTest {
         InMemoryJournal.addEntry(persistenceId, 1, new MockRaftActorContext.MockReplicatedLogEntry(1, 0,
                 new MockRaftActorContext.MockPayload("B")));
 
         InMemoryJournal.addEntry(persistenceId, 1, new MockRaftActorContext.MockReplicatedLogEntry(1, 0,
                 new MockRaftActorContext.MockPayload("B")));
 
-        TestActorRef<MockRaftActor> raftActorRef = factory.createTestActor(MockRaftActor.builder().id(persistenceId).
-                config(config).restoreFromSnapshot(SerializationUtils.serialize(snapshot)).props().
-                    withDispatcher(Dispatchers.DefaultDispatcherId()), persistenceId);
+        TestActorRef<MockRaftActor> raftActorRef = factory.createTestActor(MockRaftActor.builder().id(persistenceId)
+                .config(config).restoreFromSnapshot(SerializationUtils.serialize(snapshot)).props()
+                    .withDispatcher(Dispatchers.DefaultDispatcherId()), persistenceId);
         MockRaftActor mockRaftActor = raftActorRef.underlyingActor();
 
         mockRaftActor.waitForRecoveryComplete();
         MockRaftActor mockRaftActor = raftActorRef.underlyingActor();
 
         mockRaftActor.waitForRecoveryComplete();
@@ -1273,8 +1234,8 @@ public class RaftActorTest extends AbstractActorTest {
         InMemoryJournal.addEntry(persistenceId, 1,  new MockRaftActorContext.MockReplicatedLogEntry(1, 0,
                 new ServerConfigurationPayload(Arrays.asList(new ServerInfo(persistenceId, false)))));
 
         InMemoryJournal.addEntry(persistenceId, 1,  new MockRaftActorContext.MockReplicatedLogEntry(1, 0,
                 new ServerConfigurationPayload(Arrays.asList(new ServerInfo(persistenceId, false)))));
 
-        TestActorRef<MockRaftActor> raftActorRef = factory.createTestActor(MockRaftActor.builder().id(persistenceId).
-                config(config).props().withDispatcher(Dispatchers.DefaultDispatcherId()), persistenceId);
+        TestActorRef<MockRaftActor> raftActorRef = factory.createTestActor(MockRaftActor.builder().id(persistenceId)
+                .config(config).props().withDispatcher(Dispatchers.DefaultDispatcherId()), persistenceId);
         MockRaftActor mockRaftActor = raftActorRef.underlyingActor();
 
         mockRaftActor.waitForInitializeBehaviorComplete();
         MockRaftActor mockRaftActor = raftActorRef.underlyingActor();
 
         mockRaftActor.waitForInitializeBehaviorComplete();
@@ -1299,8 +1260,9 @@ public class RaftActorTest extends AbstractActorTest {
 
         String persistenceId = factory.generateActorId("test-actor-");
 
 
         String persistenceId = factory.generateActorId("test-actor-");
 
-        TestActorRef<MockRaftActor> raftActorRef = factory.createTestActor(MockRaftActor.builder().id(persistenceId).
-                config(config).roleChangeNotifier(notifierActor).props().withDispatcher(Dispatchers.DefaultDispatcherId()), persistenceId);
+        TestActorRef<MockRaftActor> raftActorRef = factory.createTestActor(MockRaftActor.builder().id(persistenceId)
+                .config(config).roleChangeNotifier(notifierActor).props()
+                .withDispatcher(Dispatchers.DefaultDispatcherId()), persistenceId);
         MockRaftActor mockRaftActor = raftActorRef.underlyingActor();
 
         mockRaftActor.waitForInitializeBehaviorComplete();
         MockRaftActor mockRaftActor = raftActorRef.underlyingActor();
 
         mockRaftActor.waitForInitializeBehaviorComplete();
index ac9f8da..d2a0dc8 100644 (file)
@@ -15,7 +15,6 @@ import akka.util.Timeout;
 import com.google.common.util.concurrent.Uninterruptibles;
 import java.util.Optional;
 import java.util.concurrent.TimeUnit;
 import com.google.common.util.concurrent.Uninterruptibles;
 import java.util.Optional;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
 import org.junit.Assert;
 import org.opendaylight.controller.cluster.raft.client.messages.FindLeader;
 import org.opendaylight.controller.cluster.raft.client.messages.FindLeaderReply;
 import org.junit.Assert;
 import org.opendaylight.controller.cluster.raft.client.messages.FindLeader;
 import org.opendaylight.controller.cluster.raft.client.messages.FindLeaderReply;
@@ -42,7 +41,7 @@ public class RaftActorTestKit extends JavaTestKit {
         return raftActor;
     }
 
         return raftActor;
     }
 
-    public boolean waitForLogMessage(final Class<?> logEventClass, String message){
+    public boolean waitForLogMessage(final Class<?> logEventClass, String message) {
         // Wait for a specific log message to show up
         return
             new JavaTestKit.EventFilter<Boolean>(logEventClass
         // Wait for a specific log message to show up
         return
             new JavaTestKit.EventFilter<Boolean>(logEventClass
@@ -58,21 +57,21 @@ public class RaftActorTestKit extends JavaTestKit {
 
     }
 
 
     }
 
-    protected void waitUntilLeader(){
+    protected void waitUntilLeader() {
         waitUntilLeader(raftActor);
     }
 
         waitUntilLeader(raftActor);
     }
 
+    @SuppressWarnings("checkstyle:IllegalCatch")
     public static void waitUntilLeader(ActorRef actorRef) {
         FiniteDuration duration = Duration.create(100, TimeUnit.MILLISECONDS);
     public static void waitUntilLeader(ActorRef actorRef) {
         FiniteDuration duration = Duration.create(100, TimeUnit.MILLISECONDS);
-        for(int i = 0; i < 20 * 5; i++) {
+        for (int i = 0; i < 20 * 5; i++) {
             Future<Object> future = Patterns.ask(actorRef, FindLeader.INSTANCE, new Timeout(duration));
             try {
                 final Optional<String> maybeLeader = ((FindLeaderReply)Await.result(future, duration)).getLeaderActor();
                 if (maybeLeader.isPresent()) {
                     return;
                 }
             Future<Object> future = Patterns.ask(actorRef, FindLeader.INSTANCE, new Timeout(duration));
             try {
                 final Optional<String> maybeLeader = ((FindLeaderReply)Await.result(future, duration)).getLeaderActor();
                 if (maybeLeader.isPresent()) {
                     return;
                 }
-            } catch(TimeoutException e) {
-            } catch(Exception e) {
+            } catch (Exception e) {
                 LOG.error("FindLeader failed", e);
             }
 
                 LOG.error("FindLeader failed", e);
             }
 
@@ -82,4 +81,4 @@ public class RaftActorTestKit extends JavaTestKit {
         Assert.fail("Leader not found for actorRef " + actorRef.path());
     }
 
         Assert.fail("Leader not found for actorRef " + actorRef.path());
     }
 
-}
\ No newline at end of file
+}
index ac46397..657905e 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.controller.cluster.raft;
 
 import static org.junit.Assert.assertEquals;
 package org.opendaylight.controller.cluster.raft;
 
 import static org.junit.Assert.assertEquals;
+
 import akka.actor.ActorRef;
 import akka.persistence.SaveSnapshotSuccess;
 import akka.testkit.TestActorRef;
 import akka.actor.ActorRef;
 import akka.persistence.SaveSnapshotSuccess;
 import akka.testkit.TestActorRef;
@@ -24,7 +25,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
 import org.slf4j.LoggerFactory;
 
 /**
- * Recovery Integration Test for single node
+ * Recovery Integration Test for single node.
  */
 public class RecoveryIntegrationSingleNodeTest extends AbstractRaftActorIntegrationTest {
 
  */
 public class RecoveryIntegrationSingleNodeTest extends AbstractRaftActorIntegrationTest {
 
@@ -40,29 +41,29 @@ public class RecoveryIntegrationSingleNodeTest extends AbstractRaftActorIntegrat
     public void testJournalReplayAfterSnapshotWithSingleNode() throws Exception {
 
         String persistenceId = factory.generateActorId("singleNode");
     public void testJournalReplayAfterSnapshotWithSingleNode() throws Exception {
 
         String persistenceId = factory.generateActorId("singleNode");
-        TestActorRef<AbstractRaftActorIntegrationTest.TestRaftActor> singleNodeActorRef = newTestRaftActor(persistenceId,
-                ImmutableMap.<String, String>builder().build(), leaderConfigParams);
+        TestActorRef<AbstractRaftActorIntegrationTest.TestRaftActor> singleNodeActorRef =
+                newTestRaftActor(persistenceId, ImmutableMap.<String, String>builder().build(), leaderConfigParams);
 
         waitUntilLeader(singleNodeActorRef);
 
         ActorRef singleNodeCollectorActor = singleNodeActorRef.underlyingActor().collectorActor();
 
         waitUntilLeader(singleNodeActorRef);
 
         ActorRef singleNodeCollectorActor = singleNodeActorRef.underlyingActor().collectorActor();
-        RaftActorContext singleNodeContext = singleNodeActorRef.underlyingActor().getRaftActorContext();
+        final RaftActorContext singleNodeContext = singleNodeActorRef.underlyingActor().getRaftActorContext();
 
 
 
 
-        MockRaftActorContext.MockPayload payload0 = sendPayloadData(singleNodeActorRef, "zero");
-        MockRaftActorContext.MockPayload payload1 = sendPayloadData(singleNodeActorRef, "one");
-        MockRaftActorContext.MockPayload payload2 = sendPayloadData(singleNodeActorRef, "two");
+        final MockRaftActorContext.MockPayload payload0 = sendPayloadData(singleNodeActorRef, "zero");
+        final MockRaftActorContext.MockPayload payload1 = sendPayloadData(singleNodeActorRef, "one");
+        final MockRaftActorContext.MockPayload payload2 = sendPayloadData(singleNodeActorRef, "two");
 
         MessageCollectorActor.expectMatching(singleNodeCollectorActor, ApplyJournalEntries.class, 3);
 
         // this should trigger a snapshot
 
         MessageCollectorActor.expectMatching(singleNodeCollectorActor, ApplyJournalEntries.class, 3);
 
         // this should trigger a snapshot
-        MockRaftActorContext.MockPayload payload3 = sendPayloadData(singleNodeActorRef, "three");
+        final MockRaftActorContext.MockPayload payload3 = sendPayloadData(singleNodeActorRef, "three");
 
         MessageCollectorActor.expectMatching(singleNodeCollectorActor, ApplyJournalEntries.class, 4);
 
         //add 2 more
 
         MessageCollectorActor.expectMatching(singleNodeCollectorActor, ApplyJournalEntries.class, 4);
 
         //add 2 more
-        MockRaftActorContext.MockPayload payload4 = sendPayloadData(singleNodeActorRef, "four");
-        MockRaftActorContext.MockPayload payload5 = sendPayloadData(singleNodeActorRef, "five");
+        final MockRaftActorContext.MockPayload payload4 = sendPayloadData(singleNodeActorRef, "four");
+        final MockRaftActorContext.MockPayload payload5 = sendPayloadData(singleNodeActorRef, "five");
 
 
         // Wait for snapshot complete.
 
 
         // Wait for snapshot complete.
@@ -72,8 +73,8 @@ public class RecoveryIntegrationSingleNodeTest extends AbstractRaftActorIntegrat
 
         assertEquals("Last applied", 5, singleNodeContext.getLastApplied());
 
 
         assertEquals("Last applied", 5, singleNodeContext.getLastApplied());
 
-        assertEquals("Incorrect State after snapshot success is received ",
-                Lists.newArrayList(payload0, payload1, payload2, payload3, payload4, payload5), singleNodeActorRef.underlyingActor().getState());
+        assertEquals("Incorrect State after snapshot success is received ", Lists.newArrayList(payload0, payload1,
+                payload2, payload3, payload4, payload5), singleNodeActorRef.underlyingActor().getState());
 
         // we get 2 log entries (4 and 5 indexes) and 3 ApplyJournalEntries (for 3, 4, and 5 indexes)
         assertEquals(5, InMemoryJournal.get(persistenceId).size());
 
         // we get 2 log entries (4 and 5 indexes) and 3 ApplyJournalEntries (for 3, 4, and 5 indexes)
         assertEquals(5, InMemoryJournal.get(persistenceId).size());
@@ -81,8 +82,10 @@ public class RecoveryIntegrationSingleNodeTest extends AbstractRaftActorIntegrat
         List<Snapshot> persistedSnapshots = InMemorySnapshotStore.getSnapshots(persistenceId, Snapshot.class);
         assertEquals(1, persistedSnapshots.size());
 
         List<Snapshot> persistedSnapshots = InMemorySnapshotStore.getSnapshots(persistenceId, Snapshot.class);
         assertEquals(1, persistedSnapshots.size());
 
+        @SuppressWarnings("unchecked")
         List<Object> snapshottedState = (List<Object>)MockRaftActor.toObject(persistedSnapshots.get(0).getState());
         List<Object> snapshottedState = (List<Object>)MockRaftActor.toObject(persistedSnapshots.get(0).getState());
-        assertEquals("Incorrect Snapshot", Lists.newArrayList(payload0, payload1, payload2, payload3), snapshottedState);
+        assertEquals("Incorrect Snapshot", Lists.newArrayList(payload0, payload1, payload2, payload3),
+                snapshottedState);
 
         //recovery logic starts
         killActor(singleNodeActorRef);
 
         //recovery logic starts
         killActor(singleNodeActorRef);
@@ -92,8 +95,8 @@ public class RecoveryIntegrationSingleNodeTest extends AbstractRaftActorIntegrat
 
         singleNodeActorRef.underlyingActor().waitForRecoveryComplete();
 
 
         singleNodeActorRef.underlyingActor().waitForRecoveryComplete();
 
-        assertEquals("Incorrect State after Recovery ",
-                Lists.newArrayList(payload0, payload1, payload2, payload3, payload4, payload5), singleNodeActorRef.underlyingActor().getState());
+        assertEquals("Incorrect State after Recovery ", Lists.newArrayList(payload0, payload1, payload2, payload3,
+                payload4, payload5), singleNodeActorRef.underlyingActor().getState());
 
     }
 }
 
     }
 }
index b18148d..2a881b6 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.controller.cluster.raft;
 
 import static org.junit.Assert.assertEquals;
 package org.opendaylight.controller.cluster.raft;
 
 import static org.junit.Assert.assertEquals;
+
 import akka.actor.ActorRef;
 import akka.persistence.SaveSnapshotSuccess;
 import com.google.common.collect.ImmutableMap;
 import akka.actor.ActorRef;
 import akka.persistence.SaveSnapshotSuccess;
 import com.google.common.collect.ImmutableMap;
@@ -40,12 +41,12 @@ public class RecoveryIntegrationTest extends AbstractRaftActorIntegrationTest {
         follower1Actor = newTestRaftActor(follower1Id, ImmutableMap.of(leaderId, testActorPath(leaderId)),
                 newFollowerConfigParams());
 
         follower1Actor = newTestRaftActor(follower1Id, ImmutableMap.of(leaderId, testActorPath(leaderId)),
                 newFollowerConfigParams());
 
-        Map<String, String> peerAddresses = new HashMap<>();
-        peerAddresses.put(follower1Id, follower1Actor.path().toString());
-        peerAddresses.put(follower2Id, "");
+        Map<String, String> leaderPeerAddresses = new HashMap<>();
+        leaderPeerAddresses.put(follower1Id, follower1Actor.path().toString());
+        leaderPeerAddresses.put(follower2Id, "");
 
         leaderConfigParams = newLeaderConfigParams();
 
         leaderConfigParams = newLeaderConfigParams();
-        leaderActor = newTestRaftActor(leaderId, peerAddresses, leaderConfigParams);
+        leaderActor = newTestRaftActor(leaderId, leaderPeerAddresses, leaderConfigParams);
 
         follower1CollectorActor = follower1Actor.underlyingActor().collectorActor();
         leaderCollectorActor = leaderActor.underlyingActor().collectorActor();
 
         follower1CollectorActor = follower1Actor.underlyingActor().collectorActor();
         leaderCollectorActor = leaderActor.underlyingActor().collectorActor();
@@ -62,15 +63,15 @@ public class RecoveryIntegrationTest extends AbstractRaftActorIntegrationTest {
         leaderActor.underlyingActor().startDropMessages(CaptureSnapshotReply.class);
         follower1Actor.underlyingActor().startDropMessages(AppendEntries.class);
 
         leaderActor.underlyingActor().startDropMessages(CaptureSnapshotReply.class);
         follower1Actor.underlyingActor().startDropMessages(AppendEntries.class);
 
-        MockPayload payload2 = sendPayloadData(leaderActor, "two");
+        final MockPayload payload2 = sendPayloadData(leaderActor, "two");
 
         // This should trigger a snapshot.
 
         // This should trigger a snapshot.
-        MockPayload payload3 = sendPayloadData(leaderActor, "three");
+        final MockPayload payload3 = sendPayloadData(leaderActor, "three");
 
         MessageCollectorActor.expectMatching(follower1CollectorActor, AppendEntries.class, 3);
 
         // Send another payload.
 
         MessageCollectorActor.expectMatching(follower1CollectorActor, AppendEntries.class, 3);
 
         // Send another payload.
-        MockPayload payload4 = sendPayloadData(leaderActor, "four");
+        final MockPayload payload4 = sendPayloadData(leaderActor, "four");
 
         // Now deliver the AppendEntries to the follower
         follower1Actor.underlyingActor().stopDropMessages(AppendEntries.class);
 
         // Now deliver the AppendEntries to the follower
         follower1Actor.underlyingActor().stopDropMessages(AppendEntries.class);
@@ -107,13 +108,13 @@ public class RecoveryIntegrationTest extends AbstractRaftActorIntegrationTest {
         // Block these messages initially so we can control the sequence.
         follower1Actor.underlyingActor().startDropMessages(AppendEntries.class);
 
         // Block these messages initially so we can control the sequence.
         follower1Actor.underlyingActor().startDropMessages(AppendEntries.class);
 
-        MockPayload payload2 = sendPayloadData(leaderActor, "two");
+        final MockPayload payload2 = sendPayloadData(leaderActor, "two");
 
         // This should trigger a snapshot.
 
         // This should trigger a snapshot.
-        MockPayload payload3 = sendPayloadData(leaderActor, "three");
+        final MockPayload payload3 = sendPayloadData(leaderActor, "three");
 
         // Send another payload.
 
         // Send another payload.
-        MockPayload payload4 = sendPayloadData(leaderActor, "four");
+        final MockPayload payload4 = sendPayloadData(leaderActor, "four");
 
         MessageCollectorActor.expectMatching(follower1CollectorActor, AppendEntries.class, 3);
 
 
         MessageCollectorActor.expectMatching(follower1CollectorActor, AppendEntries.class, 3);
 
@@ -151,7 +152,7 @@ public class RecoveryIntegrationTest extends AbstractRaftActorIntegrationTest {
 
         leaderActor.tell(new SetPeerAddress(follower2Id, follower2Actor.path().toString()), ActorRef.noSender());
 
 
         leaderActor.tell(new SetPeerAddress(follower2Id, follower2Actor.path().toString()), ActorRef.noSender());
 
-        MockPayload payload2 = sendPayloadData(leaderActor, "two");
+        final MockPayload payload2 = sendPayloadData(leaderActor, "two");
 
         // Verify the leader applies the 3rd payload state.
         MessageCollectorActor.expectMatching(leaderCollectorActor, ApplyJournalEntries.class, 1);
 
         // Verify the leader applies the 3rd payload state.
         MessageCollectorActor.expectMatching(leaderCollectorActor, ApplyJournalEntries.class, 1);
@@ -181,7 +182,7 @@ public class RecoveryIntegrationTest extends AbstractRaftActorIntegrationTest {
         // Wait for the follower to persist the snapshot.
         MessageCollectorActor.expectFirstMatching(follower2CollectorActor, SaveSnapshotSuccess.class);
 
         // Wait for the follower to persist the snapshot.
         MessageCollectorActor.expectFirstMatching(follower2CollectorActor, SaveSnapshotSuccess.class);
 
-        List<MockPayload> expFollowerState = Arrays.asList(payload0, payload1, payload2);
+        final List<MockPayload> expFollowerState = Arrays.asList(payload0, payload1, payload2);
 
         assertEquals("Follower commit index", 2, follower2Context.getCommitIndex());
         assertEquals("Follower last applied", 2, follower2Context.getLastApplied());
 
         assertEquals("Follower commit index", 2, follower2Context.getCommitIndex());
         assertEquals("Follower last applied", 2, follower2Context.getLastApplied());
index 9ede214..acf3bee 100644 (file)
@@ -28,7 +28,7 @@ public class ReplicatedLogImplEntryTest {
         int expIndex = 1;
         int expTerm = 2;
 
         int expIndex = 1;
         int expTerm = 2;
 
-        try(FileInputStream fis = new FileInputStream("src/test/resources/helium-serialized-ReplicatedLogImplEntry")) {
+        try (FileInputStream fis = new FileInputStream("src/test/resources/helium-serialized-ReplicatedLogImplEntry")) {
             ObjectInputStream ois = new ObjectInputStream(fis);
 
             ReplicatedLogImplEntry entry = (ReplicatedLogImplEntry) ois.readObject();
             ObjectInputStream ois = new ObjectInputStream(fis);
 
             ReplicatedLogImplEntry entry = (ReplicatedLogImplEntry) ois.readObject();
@@ -46,6 +46,7 @@ public class ReplicatedLogImplEntryTest {
      * Use this method to generate a file with a serialized ReplicatedLogImplEntry instance to be
      * used in tests that verify backwards compatible de-serialization.
      */
      * Use this method to generate a file with a serialized ReplicatedLogImplEntry instance to be
      * used in tests that verify backwards compatible de-serialization.
      */
+    @SuppressWarnings("unused")
     private static void generateSerializedFile() throws IOException {
         String expPayloadData = "This is a test";
         int expIndex = 1;
     private static void generateSerializedFile() throws IOException {
         String expPayloadData = "This is a test";
         int expIndex = 1;
index 1caef35..75c0d89 100644 (file)
@@ -13,6 +13,7 @@ import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.reset;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.mockito.Mockito.reset;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyNoMoreInteractions;
+
 import akka.japi.Procedure;
 import java.util.Collections;
 import org.hamcrest.BaseMatcher;
 import akka.japi.Procedure;
 import java.util.Collections;
 import org.hamcrest.BaseMatcher;
@@ -129,8 +130,8 @@ public class ReplicatedLogImplTest {
 
         ReplicatedLog log = ReplicatedLogImpl.newInstance(context);
 
 
         ReplicatedLog log = ReplicatedLogImpl.newInstance(context);
 
-        MockReplicatedLogEntry logEntry1 = new MockReplicatedLogEntry(1, 2, new MockPayload("2"));
-        MockReplicatedLogEntry logEntry2 = new MockReplicatedLogEntry(1, 3, new MockPayload("3"));
+        final MockReplicatedLogEntry logEntry1 = new MockReplicatedLogEntry(1, 2, new MockPayload("2"));
+        final MockReplicatedLogEntry logEntry2 = new MockReplicatedLogEntry(1, 3, new MockPayload("3"));
 
         log.appendAndPersist(logEntry1);
         verifyPersist(logEntry1);
 
         log.appendAndPersist(logEntry1);
         verifyPersist(logEntry1);
@@ -191,11 +192,11 @@ public class ReplicatedLogImplTest {
         verifyNoMoreInteractions(mockPersistence);
     }
 
         verifyNoMoreInteractions(mockPersistence);
     }
 
-    public Matcher<DeleteEntries> match(final DeleteEntries actual){
+    public Matcher<DeleteEntries> match(final DeleteEntries actual) {
         return new BaseMatcher<DeleteEntries>() {
             @Override
         return new BaseMatcher<DeleteEntries>() {
             @Override
-            public boolean matches(Object o) {
-                DeleteEntries other = (DeleteEntries) o;
+            public boolean matches(Object obj) {
+                DeleteEntries other = (DeleteEntries) obj;
                 return actual.getFromIndex() == other.getFromIndex();
             }
 
                 return actual.getFromIndex() == other.getFromIndex();
             }