public interface ReplicatedLog
Modifier and Type | Field and Description |
---|---|
static long |
NO_MAX_SIZE |
Modifier and Type | Method and Description |
---|---|
boolean |
append(ReplicatedLogEntry replicatedLogEntry)
Appends an entry to the log.
|
boolean |
appendAndPersist(ReplicatedLogEntry replicatedLogEntry,
akka.japi.Procedure<ReplicatedLogEntry> callback,
boolean doAsync)
Appends an entry to the in-memory log and persists it as well.
|
void |
captureSnapshotIfReady(ReplicatedLogEntry replicatedLogEntry)
Determines if a snapshot needs to be captured based on the count/memory consumed and initiates the capture.
|
void |
clear(int startIndex,
int endIndex)
Clears the journal entries with startIndex (inclusive) and endIndex (exclusive).
|
int |
dataSize()
Returns the size of the data in the log (in bytes).
|
ReplicatedLogEntry |
get(long index)
Return the replicated log entry at the specified index.
|
List<ReplicatedLogEntry> |
getFrom(long index)
Returns a list of log entries starting from the given index to the end of the log.
|
List<ReplicatedLogEntry> |
getFrom(long index,
int maxEntries,
long maxDataSize)
Returns a list of log entries starting from the given index up to the given maximum of entries or
the given maximum accumulated size, whichever comes first.
|
long |
getSnapshotIndex()
Returns the index of the snapshot.
|
long |
getSnapshotTerm()
Returns the term of the snapshot.
|
void |
increaseJournalLogCapacity(int amount)
Optimization method to increase the capacity of the journal log prior to appending entries.
|
boolean |
isInSnapshot(long index)
Checks if the entry is present in a snapshot.
|
boolean |
isPresent(long index)
Checks if the entry at the specified index is present or not.
|
ReplicatedLogEntry |
last()
Return the last replicated log entry in the log or null of not found.
|
long |
lastIndex()
Return the index of the last entry in the log or -1 if the log is empty.
|
long |
lastTerm()
Return the term of the last entry in the log or -1 if the log is empty.
|
long |
removeFrom(long index)
Removes entries from the in-memory log starting at the given index.
|
boolean |
removeFromAndPersist(long index)
Removes entries from the in-memory log and the persisted log starting at the given index.
|
void |
setSnapshotIndex(long snapshotIndex)
Sets the snapshot index in the replicated log.
|
void |
setSnapshotTerm(long snapshotTerm)
Sets snapshot term.
|
boolean |
shouldCaptureSnapshot(long logIndex)
Determines if a snapshot should be captured based on the count/memory consumed.
|
long |
size()
Returns the number of entries in the journal.
|
void |
snapshotCommit()
Sets the Replicated log to state after snapshot success.
|
void |
snapshotPreCommit(long snapshotCapturedIndex,
long snapshotCapturedTerm)
Handles all the bookkeeping in order to perform a rollback in the event of SaveSnapshotFailure.
|
void |
snapshotRollback()
Restores the replicated log to a state in the event of a save snapshot failure.
|
static final long NO_MAX_SIZE
@Nullable ReplicatedLogEntry get(long index)
index
- the index of the log entry@Nullable ReplicatedLogEntry last()
long lastIndex()
long lastTerm()
long removeFrom(long index)
index
- the index of the first log entry to removeboolean removeFromAndPersist(long index)
The persisted information would then be used during recovery to properly reconstruct the state of the in-memory replicated log
index
- the index of the first log entry to removeboolean append(ReplicatedLogEntry replicatedLogEntry)
replicatedLogEntry
- the entry to appendvoid increaseJournalLogCapacity(int amount)
amount
- the amount to increase byboolean appendAndPersist(@Nonnull ReplicatedLogEntry replicatedLogEntry, @Nullable akka.japi.Procedure<ReplicatedLogEntry> callback, boolean doAsync)
replicatedLogEntry
- the entry to appendcallback
- the Procedure to be notified when persistence is complete (optional).doAsync
- if true, the persistent actor can receive subsequent messages to process in between the persist
call and the execution of the associated callback. If false, subsequent messages are stashed and get
delivered after persistence is complete and the associated callback is executed. In either case the
callback is guaranteed to execute in the context of the actor associated with this log.@Nonnull List<ReplicatedLogEntry> getFrom(long index)
index
- the index of the first log entry to get.@Nonnull List<ReplicatedLogEntry> getFrom(long index, int maxEntries, long maxDataSize)
index
- the index of the first log entry to getmaxEntries
- the maximum number of entries to getmaxDataSize
- the maximum accumulated size of the log entries to getlong size()
boolean isPresent(long index)
index
- the index of the log entryboolean isInSnapshot(long index)
index
- the index of the log entrylong getSnapshotIndex()
long getSnapshotTerm()
void setSnapshotIndex(long snapshotIndex)
snapshotIndex
- the index to setvoid setSnapshotTerm(long snapshotTerm)
snapshotTerm
- the term to setvoid clear(int startIndex, int endIndex)
startIndex
- the start index (inclusive)endIndex
- the end index (exclusive)void snapshotPreCommit(long snapshotCapturedIndex, long snapshotCapturedTerm)
snapshotCapturedIndex
- the new snapshot indexsnapshotCapturedTerm
- the new snapshot termvoid snapshotCommit()
void snapshotRollback()
int dataSize()
void captureSnapshotIfReady(ReplicatedLogEntry replicatedLogEntry)
replicatedLogEntry
- the last log entry.boolean shouldCaptureSnapshot(long logIndex)
logIndex
- the log index to use to determine if the log count has exceeded the thresholdCopyright © 2019 OpenDaylight. All rights reserved.