Don't transfer leadership to a non-voting follower
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / behaviors / Leader.java
index 21aad966cb2b7dd375b6e4667e952ab4b85891a9..c76798f3b276c602c3a0190f8749f3e1aca4de89 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