public class SnapshotManager extends Object implements SnapshotState
| Constructor and Description |
|---|
SnapshotManager(RaftActorContext context,
org.slf4j.Logger logger)
Constructs an instance.
|
| Modifier and Type | Method and 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.
|
Snapshot.State |
convertSnapshot(com.google.common.io.ByteSource snapshotBytes) |
CaptureSnapshot |
getCaptureSnapshot() |
long |
getLastSequenceNumber() |
boolean |
isApplying() |
boolean |
isCapturing()
Returns whether or not a capture is in progress.
|
CaptureSnapshot |
newCaptureSnapshot(ReplicatedLogEntry lastLogEntry,
long replicatedToAllIndex)
Constructs a CaptureSnapshot instance.
|
void |
persist(Snapshot.State state,
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.
|
public SnapshotManager(RaftActorContext context, org.slf4j.Logger logger)
context - the RaftActorContextlogger - the Loggerpublic boolean isApplying()
public boolean isCapturing()
SnapshotStateisCapturing in interface SnapshotStatepublic boolean captureToInstall(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex, String targetFollower)
SnapshotStatecaptureToInstall in interface SnapshotStatelastLogEntry - the last entry in the replicated logreplicatedToAllIndex - the current replicatedToAllIndextargetFollower - the id of the follower on which to installpublic boolean capture(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex)
SnapshotStatecapture in interface SnapshotStatelastLogEntry - the last entry in the replicated logreplicatedToAllIndex - the current replicatedToAllIndexpublic void apply(ApplySnapshot snapshot)
SnapshotStateapply in interface SnapshotStatesnapshot - the Snapshot to apply.public void persist(Snapshot.State state, Optional<OutputStream> installSnapshotStream, long totalMemory)
SnapshotStatepersist in interface SnapshotStatestate - the snapshot StateinstallSnapshotStream - Optional OutputStream that is present if the snapshot is to also be installed
on a follower.totalMemory - the total memory thresholdpublic void commit(long sequenceNumber,
long timeStamp)
SnapshotStatecommit in interface SnapshotStatesequenceNumber - the sequence number of the persisted snapshottimeStamp - the time stamp of the persisted snapshotpublic void rollback()
SnapshotStaterollback in interface SnapshotStatepublic long trimLog(long desiredTrimIndex)
SnapshotStatetrimLog in interface SnapshotStatedesiredTrimIndex - the desired index to trim from@Nonnull public Snapshot.State convertSnapshot(com.google.common.io.ByteSource snapshotBytes) throws IOException
IOExceptionpublic long getLastSequenceNumber()
public CaptureSnapshot getCaptureSnapshot()
public CaptureSnapshot newCaptureSnapshot(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex)
lastLogEntry - the last log entry for the snapshot.replicatedToAllIndex - the index of the last entry replicated to all followers.Copyright © 2019 OpenDaylight. All rights reserved.