package org.opendaylight.controller.cluster.raft;
-import akka.japi.Procedure;
import akka.persistence.SnapshotSelectionCriteria;
import com.google.common.annotations.VisibleForTesting;
import java.util.List;
+import java.util.function.Consumer;
import org.opendaylight.controller.cluster.raft.base.messages.ApplySnapshot;
import org.opendaylight.controller.cluster.raft.base.messages.CaptureSnapshot;
import org.opendaylight.controller.cluster.raft.base.messages.SendInstallSnapshot;
private CaptureSnapshot captureSnapshot;
private long lastSequenceNumber = -1;
- private Procedure<Void> createSnapshotProcedure;
+ private Runnable createSnapshotProcedure;
private ApplySnapshot applySnapshot;
- private Procedure<byte[]> applySnapshotProcedure;
+ private Consumer<byte[]> applySnapshotProcedure;
public SnapshotManager(RaftActorContext context, Logger logger) {
this.context = context;
return currentState.trimLog(desiredTrimIndex);
}
- public void setCreateSnapshotCallable(Procedure<Void> createSnapshotProcedure) {
+ public void setCreateSnapshotRunnable(Runnable createSnapshotProcedure) {
this.createSnapshotProcedure = createSnapshotProcedure;
}
- public void setApplySnapshotProcedure(Procedure<byte[]> applySnapshotProcedure) {
+ public void setApplySnapshotConsumer(Consumer<byte[]> applySnapshotProcedure) {
this.applySnapshotProcedure = applySnapshotProcedure;
}
SnapshotManager.this.currentState = CREATING;
try {
- createSnapshotProcedure.apply(null);
+ createSnapshotProcedure.run();
} catch (Exception e) {
SnapshotManager.this.currentState = IDLE;
LOG.error("Error creating snapshot", e);
context.getTermInformation().update(snapshot.getElectionTerm(), snapshot.getElectionVotedFor());
if(snapshot.getState().length > 0 ) {
- applySnapshotProcedure.apply(snapshot.getState());
+ applySnapshotProcedure.accept(snapshot.getState());
}
applySnapshot.getCallback().onSuccess();