Purge in-memory log when install snapshot is done 64/16364/1
authorTom Pantelis <tpanteli@brocade.com>
Wed, 11 Mar 2015 22:11:33 +0000 (18:11 -0400)
committerTom Pantelis <tpanteli@brocade.com>
Wed, 11 Mar 2015 22:11:33 +0000 (18:11 -0400)
In AbstractLeader#handleInstallSnapshotReply, after the last snapshot
chunk has been sent and acknowledged by the follower and, since install
snapshot *should* only happen for a lagging follower, the follower
is most likely caught up at this point so we can be greedy and try
to trim the log and advance replicatedToAllIndex.

Change-Id: Id22dfbcb6e459e3d3f6801d1c6c850bdd42989fa
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeader.java

index 890d45e8fb664b20a4f27e8996d38b15e27a0120..831f8f9e7088ed2017a81a2ed6911fdfbedb8e5b 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);