Interface RaftNodeApi
- All Known Implementing Classes:
RaftNode
public interface RaftNodeApi
Narrow query/submit interface over a Raft consensus node.
Consumers that only need to query Raft state or submit commands — metrics collectors,
distributed primitives, tracers, handlers — depend on this interface rather than on the
concrete RaftNode. Tests substitute a Mockito mock of this interface; mocking the
concrete RaftNode is forbidden by the project testing policy (see CLAUDE.md
"mocking Raft/Kryo/JPA internals").
Lifecycle management (start/stop, configuration setters, WAL/metadata store wiring,
snapshot application) intentionally does not appear on this interface. Those
operations belong to the owner of the Raft node — CacheNode — which keeps a
concrete RaftNode reference.
-
Method Summary
Modifier and TypeMethodDescriptionlonglongawaitLinearizableReadToken(long timeout, TimeUnit unit) booleanawaitReplicationDrained(long timeout, TimeUnit unit) booleanlonglonglonglonglonglong@Nullable StringlonglonggetState()longlongbooleanisLeader()booleanbooleanisLinearizableReadTokenValid(long readToken) booleanbooleansubmitCommand(byte[] command) submitConfigChange(ConfigChange change)
-
Method Details
-
getNodeId
String getNodeId() -
getGroupName
String getGroupName() -
getState
RaftState getState() -
getCurrentTerm
long getCurrentTerm() -
getCommitIndex
long getCommitIndex() -
getLastApplied
long getLastApplied() -
getLogSize
long getLogSize() -
getLeaderId
@Nullable String getLeaderId() -
isLeader
boolean isLeader() -
isRunning
boolean isRunning() -
isRaftFaulted
boolean isRaftFaulted() -
getClusterMembers
-
getVoters
-
getLearners
-
getTimeSinceLastHeartbeatMs
long getTimeSinceLastHeartbeatMs() -
isLeaseValid
boolean isLeaseValid() -
canServeLocalRead
boolean canServeLocalRead() -
awaitLinearizableReadToken
- Throws:
InterruptedExceptionTimeoutException
-
awaitLinearizableReadToken
long awaitLinearizableReadToken(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException - Throws:
InterruptedExceptionTimeoutException
-
isLinearizableReadTokenValid
boolean isLinearizableReadTokenValid(long readToken) -
submitCommand
-
submitConfigChange
-
awaitReplicationDrained
- Throws:
InterruptedException
-
getReplicationLag
long getReplicationLag() -
getFollowerLagMetrics
-
getFollowerMatchIndexMetrics
-
getElectionsStarted
long getElectionsStarted() -
getCommandsSubmitted
long getCommandsSubmitted() -
getCommandsCommitted
long getCommandsCommitted() -
getStateApplyErrors
long getStateApplyErrors() -
getRaftLog
RaftLog getRaftLog()
-