From: Tom Pantelis Date: Wed, 11 Mar 2015 22:11:33 +0000 (-0400) Subject: Purge in-memory log when install snapshot is done X-Git-Tag: release/lithium~404^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=fba74fb93e947ecde93ef6685ef6303d2a8bb947 Purge in-memory log when install snapshot is done 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 --- diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeader.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeader.java index 890d45e8fb..831f8f9e70 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeader.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeader.java @@ -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);