Record Class ConsensusState
java.lang.Object
java.lang.Record
org.j7m.middleware.api.consensus.ConsensusState
- Record Components:
nodeId- node id represented by this snapshotrole- node role observed when the snapshot was builtterm- current durable termvotedFor- voted-for candidate in the current term, if anyleaderId- observed leader id, if anycommitIndex- highest log index known to be committedlastApplied- highest log index applied to the local state machinelastLogIndex- highest log index present in the local loglogEntries- redacted log entry status metadata, ordered by log index
- All Implemented Interfaces:
Serializable
public record ConsensusState(ConsensusNodeId nodeId, ConsensusRole role, ConsensusTerm term, ConsensusNodeId votedFor, ConsensusNodeId leaderId, CommitIndex commitIndex, LogIndex lastApplied, LogIndex lastLogIndex, List<ConsensusLogEntryStatus> logEntries)
extends Record
implements Serializable
Immutable, redacted consensus node state snapshot.
The snapshot is a status value, not a live node object. It is safe to
publish through operator status endpoints because log entries are represented
by ConsensusLogEntryStatus metadata rather than full replicated
commands. Implementations create this value from local durable state and must
preserve the identity and ordering semantics of indexes and terms. The record
is immutable and thread-safe after construction.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConsensusState(ConsensusNodeId nodeId, ConsensusRole role, ConsensusTerm term, ConsensusNodeId votedFor, ConsensusNodeId leaderId, CommitIndex commitIndex, LogIndex lastApplied, LogIndex lastLogIndex, List<ConsensusLogEntryStatus> logEntries) Creates a state snapshot. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecommitIndexrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of thelastAppliedrecord component.Returns the value of thelastLogIndexrecord component.leaderId()Returns the value of theleaderIdrecord component.Returns the value of thelogEntriesrecord component.nodeId()Returns the value of thenodeIdrecord component.role()Returns the value of therolerecord component.term()Returns the value of thetermrecord component.final StringtoString()Returns a string representation of this record class.votedFor()Returns the value of thevotedForrecord component.
-
Constructor Details
-
ConsensusState
public ConsensusState(ConsensusNodeId nodeId, ConsensusRole role, ConsensusTerm term, ConsensusNodeId votedFor, ConsensusNodeId leaderId, CommitIndex commitIndex, LogIndex lastApplied, LogIndex lastLogIndex, List<ConsensusLogEntryStatus> logEntries) Creates a state snapshot.Required identity, term, role, and index fields must be present. Log-entry metadata is defensively copied. Equality is value based and is suitable for comparing deterministic simulation snapshots.
- Throws:
IllegalArgumentException- when a required state field is missing
-
-
Method Details
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
nodeId
-
role
-
term
-
votedFor
-
leaderId
-
commitIndex
Returns the value of thecommitIndexrecord component.- Returns:
- the value of the
commitIndexrecord component
-
lastApplied
Returns the value of thelastAppliedrecord component.- Returns:
- the value of the
lastAppliedrecord component
-
lastLogIndex
Returns the value of thelastLogIndexrecord component.- Returns:
- the value of the
lastLogIndexrecord component
-
logEntries
Returns the value of thelogEntriesrecord component.- Returns:
- the value of the
logEntriesrecord component
-