private final SyncStatusTracker initialSyncStatusTracker;
- private final Procedure<ReplicatedLogEntry> appendAndPersistCallback = new Procedure<ReplicatedLogEntry>() {
- @Override
- public void apply(ReplicatedLogEntry logEntry) {
- context.getReplicatedLog().captureSnapshotIfReady(logEntry);
- }
- };
+ private final Procedure<ReplicatedLogEntry> appendAndPersistCallback =
+ logEntry -> context.getReplicatedLog().captureSnapshotIfReady(logEntry);
private final Stopwatch lastLeaderMessageTimer = Stopwatch.createStarted();
private SnapshotTracker snapshotTracker = null;
// to make it easier to read. Before refactoring ensure tests
// cover the code properly
+ if (snapshotTracker != null && !snapshotTracker.getLeaderId().equals(appendEntries.getLeaderId())) {
+ LOG.debug("{}: snapshot install is in progress but the prior snapshot leaderId {} does not match the " +
+ "AppendEntries leaderId {}", logName(), snapshotTracker.getLeaderId(), appendEntries.getLeaderId());
+ snapshotTracker = null;
+ }
+
if (snapshotTracker != null || context.getSnapshotManager().isApplying()) {
// if snapshot install is in progress, follower should just acknowledge append entries with a reply.
AppendEntriesReply reply = new AppendEntriesReply(context.getId(), currentTerm(), true,
leaderId = installSnapshot.getLeaderId();
if(snapshotTracker == null){
- snapshotTracker = new SnapshotTracker(LOG, installSnapshot.getTotalChunks());
+ snapshotTracker = new SnapshotTracker(LOG, installSnapshot.getTotalChunks(), installSnapshot.getLeaderId());
}
updateInitialSyncStatus(installSnapshot.getLastIncludedIndex(), installSnapshot.getLeaderId());