+ public void commit(long sequenceNumber, RaftActorBehavior currentBehavior) {
+ LOG.debug("Snapshot success sequence number:", sequenceNumber);
+
+ if(applySnapshot != null) {
+ try {
+ applySnapshotProcedure.apply(applySnapshot.getState());
+
+ //clears the followers log, sets the snapshot index to ensure adjusted-index works
+ context.setReplicatedLog(ReplicatedLogImpl.newInstance(applySnapshot, context, currentBehavior));
+ context.setLastApplied(applySnapshot.getLastAppliedIndex());
+ context.setCommitIndex(applySnapshot.getLastAppliedIndex());
+ } catch (Exception e) {
+ LOG.error("Error applying snapshot", e);
+ }
+ } else {
+ context.getReplicatedLog().snapshotCommit();
+ }
+