public interface RaftNode
RaftNode
maintains the state of a member for a specific Raft group
and exposes methods to handle external client requests (such as append
requests, queries and membership changes) and internal Raft RPCs (voting,
append request, snapshot installing etc).Modifier and Type | Method and Description |
---|---|
void |
forceSetTerminatedStatus()
Sets node's status to
RaftNodeStatus.TERMINATED unconditionally
if it's not terminated or stepped down yet. |
Collection<Endpoint> |
getCommittedMembers()
Returns the last committed member list of the raft group this node
belongs to.
|
CPGroupId |
getGroupId()
Returns the groupId which this node belongs to.
|
Collection<Endpoint> |
getInitialMembers()
Returns the initial member list of the Raft group this node belongs to.
|
Endpoint |
getLeader()
Returns the known leader endpoint.
|
Endpoint |
getLocalMember()
Returns the Raft endpoint for this node.
|
RaftNodeStatus |
getStatus()
Returns the current status of this node.
|
void |
handleAppendRequest(AppendRequest request)
Handles
AppendRequest sent by leader. |
void |
handleAppendResponse(AppendFailureResponse response)
Handles
AppendFailureResponse for a previously sent
append request by this node. |
void |
handleAppendResponse(AppendSuccessResponse response)
Handles
AppendSuccessResponse for a previously sent
append request by this node. |
void |
handleInstallSnapshot(InstallSnapshot request)
Handles
InstallSnapshot sent by leader. |
void |
handlePreVoteRequest(PreVoteRequest request)
Handles
PreVoteRequest sent by another follower. |
void |
handlePreVoteResponse(PreVoteResponse response)
Handles
PreVoteResponse for a previously sent request by
this node. |
void |
handleVoteRequest(VoteRequest request)
Handles
VoteRequest sent by a candidate. |
void |
handleVoteResponse(VoteResponse response)
Handles
VoteResponse for a previously sent vote request by
this node. |
boolean |
isTerminatedOrSteppedDown()
Returns true if this node is
RaftNodeStatus.TERMINATED or
RaftNodeStatus.STEPPED_DOWN , false otherwise. |
ICompletableFuture |
query(Object operation,
QueryPolicy queryPolicy)
Executes the given operation on Raft group depending
on the
QueryPolicy |
ICompletableFuture |
replicate(Object operation)
Replicates the given operation to the Raft group.
|
ICompletableFuture |
replicateMembershipChange(Endpoint member,
MembershipChangeMode mode)
Replicates the membership change to the Raft group.
|
ICompletableFuture |
replicateMembershipChange(Endpoint member,
MembershipChangeMode mode,
long groupMembersCommitIndex)
Replicates the membership change to the Raft group, if expected members
commit index is equal to the actual one stored in Raft state.
|
CPGroupId getGroupId()
Endpoint getLocalMember()
Endpoint getLeader()
RaftNodeStatus getStatus()
Collection<Endpoint> getInitialMembers()
Collection<Endpoint> getCommittedMembers()
boolean isTerminatedOrSteppedDown()
RaftNodeStatus.TERMINATED
or
RaftNodeStatus.STEPPED_DOWN
, false otherwise.
This method is essentially same as;
return status == TERMINATED || status == STEPPED_DOWN
void forceSetTerminatedStatus()
RaftNodeStatus.TERMINATED
unconditionally
if it's not terminated or stepped down yet.void handlePreVoteRequest(PreVoteRequest request)
PreVoteRequest
sent by another follower.void handlePreVoteResponse(PreVoteResponse response)
PreVoteResponse
for a previously sent request by
this node.void handleVoteRequest(VoteRequest request)
VoteRequest
sent by a candidate.void handleVoteResponse(VoteResponse response)
VoteResponse
for a previously sent vote request by
this node.void handleAppendRequest(AppendRequest request)
AppendRequest
sent by leader.void handleAppendResponse(AppendSuccessResponse response)
AppendSuccessResponse
for a previously sent
append request by this node.void handleAppendResponse(AppendFailureResponse response)
AppendFailureResponse
for a previously sent
append request by this node.void handleInstallSnapshot(InstallSnapshot request)
InstallSnapshot
sent by leader.ICompletableFuture replicate(Object operation)
Otherwise, if this node is not leader, or the leader is demoted before committing the operation, the returned future is notified with a related exception.
operation
- operation to replicateICompletableFuture replicateMembershipChange(Endpoint member, MembershipChangeMode mode)
If this node is not leader, or the leader is demoted before committing the operation, or membership change is not committed for any reason, then the returned future is notified with a related exception.
member
- member to add or removemode
- type of membership changeICompletableFuture replicateMembershipChange(Endpoint member, MembershipChangeMode mode, long groupMembersCommitIndex)
MismatchingGroupMembersCommitIndexException
.
For more info see replicate(Object)
.
member
- member to add or removemode
- type of membership changegroupMembersCommitIndex
- expected members commit indexICompletableFuture query(Object operation, QueryPolicy queryPolicy)
QueryPolicy
operation
- operation to queryqueryPolicy
- query policy to decide where to execute operationCopyright © 2019 Hazelcast, Inc.. All Rights Reserved.