Fixup comparison formatting
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / SnapshotState.java
index e423737706bc0d42055d388bb72b7f4a7890256b..acb6e01230ecd64b8b6625f3f1c54eae227bd629 100644 (file)
@@ -8,7 +8,10 @@
 
 package org.opendaylight.controller.cluster.raft;
 
+import java.io.OutputStream;
+import java.util.Optional;
 import org.opendaylight.controller.cluster.raft.base.messages.ApplySnapshot;
+import org.opendaylight.controller.cluster.raft.persisted.Snapshot;
 
 /**
  * Interface for a snapshot phase state.
@@ -43,6 +46,14 @@ public interface SnapshotState {
      */
     boolean captureToInstall(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex, String targetFollower);
 
+    /**
+     * Initiates a capture snapshot, while enforcing trimming of the log up to lastAppliedIndex.
+     * @param lastLogEntry the last entry in the replicated log
+     * @param replicatedToAllIndex the current replicatedToAllIndex
+     * @return true if capture was started
+     */
+    boolean captureWithForcedTrim(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex);
+
     /**
      * Applies a snapshot on a follower that was installed by the leader.
      *
@@ -53,10 +64,12 @@ public interface SnapshotState {
     /**
      * Persists a snapshot.
      *
-     * @param snapshotBytes the snapshot bytes
+     * @param snapshotState the snapshot State
+     * @param installSnapshotStream Optional OutputStream that is present if the snapshot is to also be installed
+     *        on a follower.
      * @param totalMemory the total memory threshold
      */
-    void persist(byte[] snapshotBytes, long totalMemory);
+    void persist(Snapshot.State snapshotState, Optional<OutputStream> installSnapshotStream, long totalMemory);
 
     /**
      * Commit the snapshot by trimming the log.