public class LogIndex extends ObjectId
For any two LogIndex instances, A
is an ancestor of C
reachable through parent edges in the graph if A.index < C.index
.
LogIndex provides a performance optimization for Ketch, the same information
can be obtained from RevWalk
.
Index values are only valid within a single
KetchLeader
instance after it has won
an election. By restricting scope to a single leader new leaders do not need
to traverse the entire history to determine the next index
for new
proposals. This differs from Raft, where leader election uses the log index
and the term number to determine which replica holds a sufficiently
up-to-date log. Since Ketch uses Git objects for storage of its replicated
log, it keeps the term number as Raft does but uses standard Git operations
to imply the log index.
Round.runAsync(AnyObjectId)
bumps the
index as each new round is constructed.
Modifier and Type | Field and Description |
---|---|
private long |
index |
Modifier | Constructor and Description |
---|---|
private |
LogIndex(AnyObjectId id,
long index) |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
describeForLog()
Create string suitable for debug logging containing the log index and
abbreviated ObjectId.
|
long |
getIndex()
Get index provided by the current leader instance.
|
(package private) boolean |
isBefore(LogIndex c)
Check if this log position committed before another log position.
|
(package private) LogIndex |
nextIndex(AnyObjectId id) |
java.lang.String |
toString() |
(package private) static LogIndex |
unknown(AnyObjectId id) |
equals, fromRaw, fromRaw, fromRaw, fromRaw, fromString, fromString, isId, toObjectId, toString, zeroId
private LogIndex(AnyObjectId id, long index)
static LogIndex unknown(AnyObjectId id)
LogIndex nextIndex(AnyObjectId id)
public long getIndex()
boolean isBefore(LogIndex c)
Only valid for log positions in memory for the current leader.
c
- other (more recent) log position.c
or equal to c and
therefore any agreement of c
implies agreement on this
log position.public java.lang.String describeForLog()
public java.lang.String toString()
toString
in class AnyObjectId