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()
SnapshotState
isCapturing
in interface SnapshotState
public boolean captureToInstall(ReplicatedLogEntry lastLogEntry, long replicatedToAllIndex, String targetFollower)
SnapshotState
captureToInstall
in interface SnapshotState
lastLogEntry
- 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)
SnapshotState
capture
in interface SnapshotState
lastLogEntry
- the last entry in the replicated logreplicatedToAllIndex
- the current replicatedToAllIndexpublic void apply(ApplySnapshot snapshot)
SnapshotState
apply
in interface SnapshotState
snapshot
- the Snapshot to apply.public void persist(Snapshot.State state, Optional<OutputStream> installSnapshotStream, long totalMemory)
SnapshotState
persist
in interface SnapshotState
state
- 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)
SnapshotState
commit
in interface SnapshotState
sequenceNumber
- the sequence number of the persisted snapshottimeStamp
- the time stamp of the persisted snapshotpublic void rollback()
SnapshotState
rollback
in interface SnapshotState
public long trimLog(long desiredTrimIndex)
SnapshotState
trimLog
in interface SnapshotState
desiredTrimIndex
- the desired index to trim from@Nonnull public Snapshot.State convertSnapshot(com.google.common.io.ByteSource snapshotBytes) throws IOException
IOException
public 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.