lastLogEntryIndex = lastLogEntry.getIndex();
lastLogEntryTerm = lastLogEntry.getTerm();
} else {
- LOG.warn("Capturing Snapshot : lastLogEntry is null. Using lastAppliedIndex {} and lastAppliedTerm {} instead.",
+ LOG.debug("Capturing Snapshot : lastLogEntry is null. Using lastAppliedIndex {} and lastAppliedTerm {} instead.",
lastAppliedIndex, lastAppliedTerm);
}
captureSnapshot.getLastIndex(), captureSnapshot.getLastTerm(),
captureSnapshot.getLastAppliedIndex(), captureSnapshot.getLastAppliedTerm(),
context.getTermInformation().getCurrentTerm(),
- context.getTermInformation().getVotedFor());
+ context.getTermInformation().getVotedFor(), context.getPeerServerInfo());
context.getPersistenceProvider().saveSnapshot(snapshot);
if(applySnapshot != null) {
try {
Snapshot snapshot = applySnapshot.getSnapshot();
- applySnapshotProcedure.apply(snapshot.getState());
//clears the followers log, sets the snapshot index to ensure adjusted-index works
context.setReplicatedLog(ReplicatedLogImpl.newInstance(snapshot, context, currentBehavior));
context.setLastApplied(snapshot.getLastAppliedIndex());
context.setCommitIndex(snapshot.getLastAppliedIndex());
+ context.getTermInformation().update(snapshot.getElectionTerm(), snapshot.getElectionVotedFor());
+
+ if(snapshot.getState().length > 0 ) {
+ applySnapshotProcedure.apply(snapshot.getState());
+ }
applySnapshot.getCallback().onSuccess();
} catch (Exception e) {