Turn ElectionTimeout into a proper singleton
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / behaviors / Leader.java
index 21aad966cb2b7dd375b6e4667e952ab4b85891a9..924c30f657b927528a81ac9997564418c8ec2fe5 100644 (file)
@@ -129,11 +129,12 @@ public class Leader extends AbstractLeader {
         }
 
         long lastIndex = context.getReplicatedLog().lastIndex();
+        boolean isVoting = context.getPeerInfo(followerId).isVoting();
 
-        LOG.debug("{}: tryToCompleteLeadershipTransfer: followerId: {}, matchIndex: {}, lastIndex: {}",
-                logName(), followerId, followerInfo.getMatchIndex(), lastIndex);
+        LOG.debug("{}: tryToCompleteLeadershipTransfer: followerId: {}, matchIndex: {}, lastIndex: {}, isVoting: {}",
+                logName(), followerId, followerInfo.getMatchIndex(), lastIndex, isVoting);
 
-        if(followerInfo.getMatchIndex() == lastIndex) {
+        if(isVoting && followerInfo.getMatchIndex() == lastIndex) {
             LOG.debug("{}: Follower's log matches - sending ElectionTimeout", logName());
 
             // We can't be sure if the follower has applied all its log entries to its state so send an
@@ -142,7 +143,7 @@ public class Leader extends AbstractLeader {
 
             // Now send an ElectionTimeout to the matching follower to immediately start an election.
             ActorSelection followerActor = context.getPeerActorSelection(followerId);
-            followerActor.tell(new ElectionTimeout(), context.getActor());
+            followerActor.tell(ElectionTimeout.INSTANCE, context.getActor());
 
             LOG.debug("{}: Leader transfer complete", logName());