public abstract class AbstractReplicatedLogImpl extends Object implements ReplicatedLog
NO_MAX_SIZE
Modifier | Constructor and Description |
---|---|
protected |
AbstractReplicatedLogImpl() |
protected |
AbstractReplicatedLogImpl(long snapshotIndex,
long snapshotTerm,
List<ReplicatedLogEntry> unAppliedEntries,
String logContext) |
Modifier and Type | Method and Description |
---|---|
protected int |
adjustedIndex(long logEntryIndex) |
boolean |
append(ReplicatedLogEntry replicatedLogEntry)
Appends an entry to the log.
|
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 logEntryIndex)
Return the replicated log entry at the specified index.
|
List<ReplicatedLogEntry> |
getFrom(long logEntryIndex)
Returns a list of log entries starting from the given index to the end of the log.
|
List<ReplicatedLogEntry> |
getFrom(long logEntryIndex,
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 logEntryIndex)
Checks if the entry is present in a snapshot.
|
boolean |
isPresent(long logEntryIndex)
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 logEntryIndex)
Removes entries from the in-memory 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.
|
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
appendAndPersist, captureSnapshotIfReady, removeFromAndPersist, shouldCaptureSnapshot
protected AbstractReplicatedLogImpl(long snapshotIndex, long snapshotTerm, List<ReplicatedLogEntry> unAppliedEntries, String logContext)
protected AbstractReplicatedLogImpl()
protected int adjustedIndex(long logEntryIndex)
public ReplicatedLogEntry get(long logEntryIndex)
ReplicatedLog
get
in interface ReplicatedLog
logEntryIndex
- the index of the log entrypublic ReplicatedLogEntry last()
ReplicatedLog
last
in interface ReplicatedLog
public long lastIndex()
ReplicatedLog
lastIndex
in interface ReplicatedLog
public long lastTerm()
ReplicatedLog
lastTerm
in interface ReplicatedLog
public long removeFrom(long logEntryIndex)
ReplicatedLog
removeFrom
in interface ReplicatedLog
logEntryIndex
- the index of the first log entry to removepublic boolean append(ReplicatedLogEntry replicatedLogEntry)
ReplicatedLog
append
in interface ReplicatedLog
replicatedLogEntry
- the entry to appendpublic void increaseJournalLogCapacity(int amount)
ReplicatedLog
increaseJournalLogCapacity
in interface ReplicatedLog
amount
- the amount to increase bypublic List<ReplicatedLogEntry> getFrom(long logEntryIndex)
ReplicatedLog
getFrom
in interface ReplicatedLog
logEntryIndex
- the index of the first log entry to get.public List<ReplicatedLogEntry> getFrom(long logEntryIndex, int maxEntries, long maxDataSize)
ReplicatedLog
getFrom
in interface ReplicatedLog
logEntryIndex
- 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 getpublic long size()
ReplicatedLog
size
in interface ReplicatedLog
public int dataSize()
ReplicatedLog
dataSize
in interface ReplicatedLog
public boolean isPresent(long logEntryIndex)
ReplicatedLog
isPresent
in interface ReplicatedLog
logEntryIndex
- the index of the log entrypublic boolean isInSnapshot(long logEntryIndex)
ReplicatedLog
isInSnapshot
in interface ReplicatedLog
logEntryIndex
- the index of the log entrypublic long getSnapshotIndex()
ReplicatedLog
getSnapshotIndex
in interface ReplicatedLog
public long getSnapshotTerm()
ReplicatedLog
getSnapshotTerm
in interface ReplicatedLog
public void setSnapshotIndex(long snapshotIndex)
ReplicatedLog
setSnapshotIndex
in interface ReplicatedLog
snapshotIndex
- the index to setpublic void setSnapshotTerm(long snapshotTerm)
ReplicatedLog
setSnapshotTerm
in interface ReplicatedLog
snapshotTerm
- the term to setpublic void clear(int startIndex, int endIndex)
ReplicatedLog
clear
in interface ReplicatedLog
startIndex
- the start index (inclusive)endIndex
- the end index (exclusive)public void snapshotPreCommit(long snapshotCapturedIndex, long snapshotCapturedTerm)
ReplicatedLog
snapshotPreCommit
in interface ReplicatedLog
snapshotCapturedIndex
- the new snapshot indexsnapshotCapturedTerm
- the new snapshot termpublic void snapshotCommit()
ReplicatedLog
snapshotCommit
in interface ReplicatedLog
public void snapshotRollback()
ReplicatedLog
snapshotRollback
in interface ReplicatedLog
Copyright © 2019 OpenDaylight. All rights reserved.