Bug 2187: AddServer unit test and bug fixes
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / behaviors / AbstractLeader.java
index 605a5c21a4a7ecfab4a006d43cacebed088ce00b..3c5ad0428fd90ba59e3aabfea701a46f8a7af6cb 100644 (file)
@@ -135,6 +135,10 @@ public abstract class AbstractLeader extends AbstractRaftActorBehavior {
         FollowerLogInformation followerLogInformation = new FollowerLogInformationImpl(followerId, -1, context);
         followerLogInformation.setFollowerState(followerState);
         followerToLog.put(followerId, followerLogInformation);
+
+        if(heartbeatSchedule == null) {
+            scheduleHeartBeat(context.getConfigParams().getHeartBeatInterval());
+        }
     }
 
     public void removeFollower(String followerId) {
@@ -254,9 +258,10 @@ public abstract class AbstractLeader extends AbstractRaftActorBehavior {
 
             if (replicatedCount >= minReplicationCount) {
                 ReplicatedLogEntry replicatedLogEntry = context.getReplicatedLog().get(N);
-                if (replicatedLogEntry != null &&
-                    replicatedLogEntry.getTerm() == currentTerm()) {
+                if (replicatedLogEntry != null && replicatedLogEntry.getTerm() == currentTerm()) {
                     context.setCommitIndex(N);
+                } else {
+                    break;
                 }
             } else {
                 break;