use of org.opendaylight.controller.cluster.raft.FollowerLogInformation in project controller by opendaylight.
the class AbstractLeader method initiateCaptureSnapshot.
/**
* Initiates a snapshot capture to install on a follower.
*
* <p>
* Install Snapshot works as follows
* 1. Leader initiates the capture snapshot by calling createSnapshot on the RaftActor.
* 2. On receipt of the CaptureSnapshotReply message, the RaftActor persists the snapshot and makes a call to
* the Leader's handleMessage with a SendInstallSnapshot message.
* 3. The Leader obtains and stores the Snapshot from the SendInstallSnapshot message and sends it in chunks to
* the Follower via InstallSnapshot messages.
* 4. For each chunk, the Follower sends back an InstallSnapshotReply.
* 5. On receipt of the InstallSnapshotReply for the last chunk, the Leader marks the install complete for that
* follower.
* 6. If another follower requires a snapshot and a snapshot has been collected (via SendInstallSnapshot)
* then send the existing snapshot in chunks to the follower.
*
* @param followerId the id of the follower.
* @return true if capture was initiated, false otherwise.
*/
public boolean initiateCaptureSnapshot(final String followerId) {
FollowerLogInformation followerLogInfo = followerToLog.get(followerId);
if (snapshotHolder.isPresent()) {
// If a snapshot is present in the memory, most likely another install is in progress no need to capture
// snapshot. This could happen if another follower needs an install when one is going on.
final ActorSelection followerActor = context.getPeerActorSelection(followerId);
// Note: sendSnapshotChunk will set the LeaderInstallSnapshotState.
sendSnapshotChunk(followerActor, followerLogInfo);
return true;
}
boolean captureInitiated = context.getSnapshotManager().captureToInstall(context.getReplicatedLog().last(), this.getReplicatedToAllIndex(), followerId);
if (captureInitiated) {
followerLogInfo.setLeaderInstallSnapshotState(new LeaderInstallSnapshotState(context.getConfigParams().getSnapshotChunkSize(), logName()));
}
return captureInitiated;
}
Aggregations