Merge "Purge in-memory log when install snapshot is done"
authorMoiz Raja <moraja@cisco.com>
Fri, 13 Mar 2015 10:28:37 +0000 (10:28 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 13 Mar 2015 10:28:37 +0000 (10:28 +0000)
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeader.java

index 890d45e..831f8f9 100644 (file)
@@ -383,7 +383,10 @@ public abstract class AbstractLeader extends AbstractRaftActorBehavior {
                 followerToSnapshot.markSendStatus(false);
             }
 
-            if (!wasLastChunk && followerToSnapshot.canSendNextChunk()) {
+            if (wasLastChunk && !context.isSnapshotCaptureInitiated()) {
+                // Since the follower is now caught up try to purge the log.
+                purgeInMemoryLog();
+            } else if (!wasLastChunk && followerToSnapshot.canSendNextChunk()) {
                 ActorSelection followerActor = context.getPeerActorSelection(followerId);
                 if(followerActor != null) {
                     sendSnapshotChunk(followerActor, followerId);