*/
package org.opendaylight.controller.cluster.raft;
-import akka.japi.Procedure;
import java.util.List;
+import java.util.function.Consumer;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
* Appends an entry to the in-memory log and persists it as well.
*
* @param replicatedLogEntry the entry to append
- * @param callback the Procedure to be notified when persistence is complete (optional).
+ * @param callback the callback to be notified when persistence is complete (optional).
* @param doAsync if true, the persistent actor can receive subsequent messages to process in between the persist
* call and the execution of the associated callback. If false, subsequent messages are stashed and get
- * delivered after persistence is complete and the associated callback is executed.
+ * delivered after persistence is complete and the associated callback is executed. In either case the
+ * callback is guaranteed to execute in the context of the actor associated with this log.
* @return true if the entry was successfully appended, false otherwise.
*/
boolean appendAndPersist(@NonNull ReplicatedLogEntry replicatedLogEntry,
- @Nullable Procedure<ReplicatedLogEntry> callback, boolean doAsync);
+ @Nullable Consumer<ReplicatedLogEntry> callback, boolean doAsync);
/**
* Returns a list of log entries starting from the given index to the end of the log.
void snapshotPreCommit(long snapshotCapturedIndex, long snapshotCapturedTerm);
/**
- * Sets the Replicated log to state after snapshot success.
+ * Sets the Replicated log to state after snapshot success. This method is equivalent to
+ * {@code snapshotCommit(true)}.
*/
- void snapshotCommit();
+ default void snapshotCommit() {
+ snapshotCommit(true);
+ }
+
+ /**
+ * Sets the Replicated log to state after snapshot success. Most users will want to use {@link #snapshotCommit()}
+ * instead.
+ *
+ * @param updateDataSize true if {@link #dataSize()} should also be updated
+ */
+ void snapshotCommit(boolean updateDataSize);
/**
* Restores the replicated log to a state in the event of a save snapshot failure.