Class LogIndex
- java.lang.Object
-
- org.eclipse.jgit.lib.AnyObjectId
-
- org.eclipse.jgit.lib.ObjectId
-
- org.eclipse.jgit.internal.ketch.LogIndex
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<AnyObjectId>
public class LogIndex extends ObjectId
An ObjectId for a commit extended with incrementing log index.For any two LogIndex instances,
A
is an ancestor ofC
reachable through parent edges in the graph ifA.index < C.index
. LogIndex provides a performance optimization for Ketch, the same information can be obtained fromRevWalk
.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 nextindex
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.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private long
index
-
Constructor Summary
Constructors Modifier Constructor Description private
LogIndex(AnyObjectId id, long index)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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)
-
Methods inherited from class org.eclipse.jgit.lib.ObjectId
equals, fromRaw, fromRaw, fromRaw, fromRaw, fromString, fromString, isId, toObjectId, toString, zeroId
-
-
-
-
Constructor Detail
-
LogIndex
private LogIndex(AnyObjectId id, long index)
-
-
Method Detail
-
unknown
static LogIndex unknown(AnyObjectId id)
-
nextIndex
LogIndex nextIndex(AnyObjectId id)
-
getIndex
public long getIndex()
Get index provided by the current leader instance.- Returns:
- index provided by the current leader instance.
-
isBefore
boolean isBefore(LogIndex c)
Check if this log position committed before another log position.Only valid for log positions in memory for the current leader.
- Parameters:
c
- other (more recent) log position.- Returns:
- true if this log position was before
c
or equal to c and therefore any agreement ofc
implies agreement on this log position.
-
describeForLog
public java.lang.String describeForLog()
Create string suitable for debug logging containing the log index and abbreviated ObjectId.- Returns:
- string suitable for debug logging containing the log index and abbreviated ObjectId.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classAnyObjectId
-
-