Interface SnapshotState
-
- All Known Implementing Classes:
SnapshotManager
public interface SnapshotState
Interface for a snapshot phase state.- Author:
- Moiz Raja, Thomas Pantelis
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
apply(ApplySnapshot snapshot)
Applies a snapshot on a follower that was installed by the leader.boolean
capture(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex)
Initiates a capture snapshot.boolean
captureToInstall(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex, String targetFollower)
Initiates a capture snapshot for the purposing of installing the snapshot on a follower.void
commit(long sequenceNumber, long timeStamp)
Commit the snapshot by trimming the log.boolean
isCapturing()
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 Detail
-
isCapturing
boolean isCapturing()
Returns whether or not a capture is in progress.- Returns:
- true when a snapshot is being captured, false otherwise
-
capture
boolean capture(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex)
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(ReplicatedLogEntry 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
-
apply
void apply(ApplySnapshot snapshot)
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
-
-