BUG 2185 : Introduce RaftPolicy & DefaultRaftPolicy
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / behaviors / Follower.java
index d16ddabddee988df72c90866a05486312ecc48d9..ede0f6af2c9cb11ce005aa76a9a047b97ef5d29c 100644 (file)
@@ -48,10 +48,12 @@ public class Follower extends AbstractRaftActorBehavior {
 
         initialSyncStatusTracker = new InitialSyncStatusTracker(context.getActor());
 
-        if(context.getPeerAddresses().isEmpty()){
-            actor().tell(ELECTION_TIMEOUT, actor());
-        } else {
-            scheduleElection(electionDuration());
+        if(context.getRaftPolicy().automaticElectionsEnabled()) {
+            if (context.getPeerAddresses().isEmpty()) {
+                actor().tell(ELECTION_TIMEOUT, actor());
+            } else {
+                scheduleElection(electionDuration());
+            }
         }
 
     }