X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-akka-raft%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fraft%2FReplicatedLog.java;h=71576f6d21b71fd02704e50d74e431f16a641f50;hp=73ab6ea66cfcbd04e835edf18f7e2210c5795b65;hb=1b0f84c4957e464bad6f7cb7350a8171c3d1621b;hpb=b0f8283587b5cc8573d29f66219cbe7f70e21e1b diff --git a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ReplicatedLog.java b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ReplicatedLog.java index 73ab6ea66c..71576f6d21 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ReplicatedLog.java +++ b/opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/ReplicatedLog.java @@ -61,7 +61,8 @@ public interface ReplicatedLog { /** * Removes entries from the in-memory log and the persisted log starting at the given index. - *

+ * + *

* The persisted information would then be used during recovery to properly * reconstruct the state of the in-memory replicated log * @@ -90,16 +91,14 @@ public interface ReplicatedLog { * 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 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. + * @return true if the entry was successfully appended, false otherwise. */ - void appendAndPersist(final ReplicatedLogEntry replicatedLogEntry); - - /** - * 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. - */ - void appendAndPersist(ReplicatedLogEntry replicatedLogEntry, Procedure callback); + boolean appendAndPersist(@Nonnull ReplicatedLogEntry replicatedLogEntry, + @Nullable Procedure callback, boolean doAsync); /** * Returns a list of log entries starting from the given index to the end of the log. @@ -206,9 +205,17 @@ public interface ReplicatedLog { int dataSize(); /** - * Determines if a snapshot need to be captured based on the count/memory consumed. + * Determines if a snapshot needs to be captured based on the count/memory consumed and initiates the capture. * * @param replicatedLogEntry the last log entry. */ void captureSnapshotIfReady(ReplicatedLogEntry replicatedLogEntry); + + /** + * Determines if a snapshot should be captured based on the count/memory consumed. + * + * @param logIndex the log index to use to determine if the log count has exceeded the threshold + * @return true if a snapshot should be captured, false otherwise + */ + boolean shouldCaptureSnapshot(long logIndex); }