Interface SnapshotState
- All Known Implementing Classes:
SnapshotManager
public interface SnapshotState
Interface for a snapshot phase state.
- Author:
- Moiz Raja, Thomas Pantelis
-
Method Summary
Modifier and TypeMethodDescriptionvoid
apply
(ApplySnapshot snapshot) Applies a snapshot on a follower that was installed by the leader.boolean
capture
(RaftEntryMeta lastLogEntry, long replicatedToAllIndex) Initiates a capture snapshot.boolean
captureToInstall
(RaftEntryMeta lastLogEntry, long replicatedToAllIndex, String targetFollower) Initiates a capture snapshot for the purposing of installing the snapshot on a follower.boolean
captureWithForcedTrim
(RaftEntryMeta lastLogEntry, long replicatedToAllIndex) Initiates a capture snapshot, while enforcing trimming of the log up to lastAppliedIndex.void
commit
(long sequenceNumber, long timeStamp) Commit the snapshot by trimming the log.boolean
Returns whether or not a capture is in progress.void
persist
(Snapshot.State snapshotState, Optional<OutputStream> installSnapshotStream, long totalMemory) Persists a snapshot.void
rollback()
Rolls back the snapshot on failure.long
trimLog
(long desiredTrimIndex) Trims the in-memory log.
-
Method Details
-
isCapturing
boolean isCapturing()Returns whether or not a capture is in progress.- Returns:
- true when a snapshot is being captured, false otherwise
-
capture
Initiates a capture snapshot.- Parameters:
lastLogEntry
- the last entry in the replicated logreplicatedToAllIndex
- the current replicatedToAllIndex- Returns:
- true if capture was started
-
captureToInstall
boolean captureToInstall(RaftEntryMeta lastLogEntry, long replicatedToAllIndex, String targetFollower) Initiates a capture snapshot for the purposing of installing the snapshot on a follower.- Parameters:
lastLogEntry
- the last entry in the replicated logreplicatedToAllIndex
- the current replicatedToAllIndextargetFollower
- the id of the follower on which to install- Returns:
- true if capture was started
-
captureWithForcedTrim
Initiates a capture snapshot, while enforcing trimming of the log up to lastAppliedIndex.- Parameters:
lastLogEntry
- the last entry in the replicated logreplicatedToAllIndex
- the current replicatedToAllIndex- Returns:
- true if capture was started
-
apply
Applies a snapshot on a follower that was installed by the leader.- Parameters:
snapshot
- the Snapshot to apply.
-
persist
void persist(Snapshot.State snapshotState, Optional<OutputStream> installSnapshotStream, long totalMemory) Persists a snapshot.- Parameters:
snapshotState
- the snapshot StateinstallSnapshotStream
- Optional OutputStream that is present if the snapshot is to also be installed on a follower.totalMemory
- the total memory threshold
-
commit
void commit(long sequenceNumber, long timeStamp) Commit the snapshot by trimming the log.- Parameters:
sequenceNumber
- the sequence number of the persisted snapshottimeStamp
- the time stamp of the persisted snapshot
-
rollback
void rollback()Rolls back the snapshot on failure. -
trimLog
long trimLog(long desiredTrimIndex) Trims the in-memory log.- Parameters:
desiredTrimIndex
- the desired index to trim from- Returns:
- the actual trim index
-