Stop scheduling the Install Snapshot check 73/15173/1
authorMoiz Raja <moraja@cisco.com>
Wed, 11 Feb 2015 22:31:38 +0000 (14:31 -0800)
committerMoiz Raja <moraja@cisco.com>
Wed, 11 Feb 2015 22:31:38 +0000 (14:31 -0800)
We only schedule it once and even that is unneccessary
because we check if a snapshot needs to be triggered in
sendUpdatesToFollower and that should be good enough

Change-Id: I4da5d3452dbdb261738587f41201611ef891bec1
Signed-off-by: Moiz Raja <moraja@cisco.com>
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/Leader.java

index fcfaee36033f3eba278f1f351d3c8cb3e974feb1..7a94c0c15849038f35105789856f98cb74580d51 100644 (file)
@@ -12,7 +12,6 @@ import akka.actor.Cancellable;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
 import org.opendaylight.controller.cluster.raft.RaftActorContext;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
 import org.opendaylight.controller.cluster.raft.RaftActorContext;
-import org.opendaylight.controller.cluster.raft.base.messages.InitiateInstallSnapshot;
 import org.opendaylight.controller.cluster.raft.base.messages.IsolatedLeaderCheck;
 import scala.concurrent.duration.FiniteDuration;
 
 import org.opendaylight.controller.cluster.raft.base.messages.IsolatedLeaderCheck;
 import scala.concurrent.duration.FiniteDuration;
 
@@ -45,8 +44,6 @@ public class Leader extends AbstractLeader {
     public Leader(RaftActorContext context) {
         super(context);
 
     public Leader(RaftActorContext context) {
         super(context);
 
-        scheduleInstallSnapshotCheck(context.getConfigParams().getIsolatedCheckInterval());
-
         scheduleIsolatedLeaderCheck(
             new FiniteDuration(context.getConfigParams().getHeartBeatInterval().length() * 10,
                 context.getConfigParams().getHeartBeatInterval().unit()));
         scheduleIsolatedLeaderCheck(
             new FiniteDuration(context.getConfigParams().getHeartBeatInterval().length() * 10,
                 context.getConfigParams().getHeartBeatInterval().unit()));
@@ -66,30 +63,6 @@ public class Leader extends AbstractLeader {
         return super.handleMessage(sender, originalMessage);
     }
 
         return super.handleMessage(sender, originalMessage);
     }
 
-    protected void stopInstallSnapshotSchedule() {
-        if (installSnapshotSchedule != null && !installSnapshotSchedule.isCancelled()) {
-            installSnapshotSchedule.cancel();
-        }
-    }
-
-    protected void scheduleInstallSnapshotCheck(FiniteDuration interval) {
-        if (getFollowerIds().isEmpty()) {
-            // Optimization - do not bother scheduling a heartbeat as there are
-            // no followers
-            return;
-        }
-
-        stopInstallSnapshotSchedule();
-
-        // Schedule a message to send append entries to followers that can
-        // accept an append entries with some data in it
-        installSnapshotSchedule =
-            context.getActorSystem().scheduler().scheduleOnce(
-                interval,
-                context.getActor(), new InitiateInstallSnapshot(),
-                context.getActorSystem().dispatcher(), context.getActor());
-    }
-
     protected void stopIsolatedLeaderCheckSchedule() {
         if (isolatedLeaderCheckSchedule != null && !isolatedLeaderCheckSchedule.isCancelled()) {
             isolatedLeaderCheckSchedule.cancel();
     protected void stopIsolatedLeaderCheckSchedule() {
         if (isolatedLeaderCheckSchedule != null && !isolatedLeaderCheckSchedule.isCancelled()) {
             isolatedLeaderCheckSchedule.cancel();
@@ -104,7 +77,6 @@ public class Leader extends AbstractLeader {
 
     @Override
     public void close() throws Exception {
 
     @Override
     public void close() throws Exception {
-        stopInstallSnapshotSchedule();
         stopIsolatedLeaderCheckSchedule();
         super.close();
     }
         stopIsolatedLeaderCheckSchedule();
         super.close();
     }