this.createSnapshotProcedure = createSnapshotProcedure;
}
+ public long getLastSequenceNumber() {
+ return lastSequenceNumber;
+ }
+
@VisibleForTesting
public CaptureSnapshot getCaptureSnapshot() {
return captureSnapshot;
LOG.debug("lastSequenceNumber prior to capture: {}", lastSequenceNumber);
+ SnapshotManager.this.currentState = CREATING;
+
try {
createSnapshotProcedure.apply(null);
} catch (Exception e) {
+ SnapshotManager.this.currentState = IDLE;
LOG.error("Error creating snapshot", e);
return false;
}
- SnapshotManager.this.currentState = CREATING;
return true;
}
@Override
public void commit(long sequenceNumber) {
+ LOG.debug("Snapshot success sequence number:", sequenceNumber);
context.getReplicatedLog().snapshotCommit();
context.getPersistenceProvider().deleteSnapshots(new SnapshotSelectionCriteria(
sequenceNumber - context.getConfigParams().getSnapshotBatchCount(), 43200000));
this.term = -1L;
if (!hasFollowers) {
if(lastLogEntry != null) {
+ // since we have persisted the last-log-entry to persistent journal before the capture,
+ // we would want to snapshot from this entry.
index = lastLogEntry.getIndex();
term = lastLogEntry.getTerm();
}