public interface ReplicatorGroup extends Describer
Describer.DefaultPrinter, Describer.Printer| 限定符和类型 | 方法和说明 |
|---|---|
default boolean |
addReplicator(PeerId peer)
Adds a replicator for follower(
ReplicatorType.Follower). |
default boolean |
addReplicator(PeerId peer,
ReplicatorType replicatorType)
Add a replicator attached with |peer|
will be a notification when the replicator catches up according to the
arguments.
|
boolean |
addReplicator(PeerId peer,
ReplicatorType replicatorType,
boolean sync)
Try to add a replicator attached with |peer|
will be a notification when the replicator catches up according to the
arguments.
|
void |
checkReplicator(PeerId peer,
boolean lockNode)
Check replicator state, if it's not started, start it;
if it is blocked, unblock it.
|
void |
clearFailureReplicators()
Clear failure to start replicators
|
boolean |
contains(PeerId peer)
Returns true if the there's a replicator attached to the given |peer|
|
PeerId |
findTheNextCandidate(ConfigurationEntry conf)
Find the follower with the most log entries in this group, which is
likely becomes the leader according to the election algorithm of raft.
|
long |
getLastRpcSendTimestamp(PeerId peer)
Get peer's last rpc send timestamp (monotonic time in milliseconds).
|
ThreadId |
getReplicator(PeerId peer)
Get replicator id by peer, null if not found.
|
boolean |
init(NodeId nodeId,
ReplicatorGroupOptions opts)
Init the replicator group.
|
List<ThreadId> |
listReplicators()
Returns all replicators.
|
boolean |
resetElectionTimeoutInterval(int newIntervalMs)
Reset the interval of electionTimeout for replicator.
|
boolean |
resetHeartbeatInterval(int newIntervalMs)
Reset the interval of heartbeat,
This method is supposed to be called when the very candidate becomes the
leader, so we suppose that there are no running replicators.
|
boolean |
resetTerm(long newTerm)
Reset the term of all to-add replicators.
|
void |
sendHeartbeat(PeerId peer,
RpcResponseClosure<RpcRequests.AppendEntriesResponse> closure)
Send heartbeat to a peer.
|
boolean |
stopAll()
Stop all replicators.
|
ThreadId |
stopAllAndFindTheNextCandidate(ConfigurationEntry conf)
Stop all the replicators except for the one that we think can be the
candidate of the next leader, which has the largest `last_log_id' among
peers in |current_conf|.
|
boolean |
stopReplicator(PeerId peer)
Stop replicator for the peer.
|
boolean |
stopTransferLeadership(PeerId peer)
Stop transferring leadership to the given |peer|
|
boolean |
transferLeadershipTo(PeerId peer,
long logIndex)
Transfer leadership to the given |peer|
|
boolean |
waitCaughtUp(PeerId peer,
long maxMargin,
long dueTime,
CatchUpClosure done)
Wait the peer catchup.
|
boolean init(NodeId nodeId, ReplicatorGroupOptions opts)
nodeId - node idopts - options of replicator gropdefault boolean addReplicator(PeerId peer)
ReplicatorType.Follower).peer - target peeraddReplicator(PeerId, ReplicatorType)default boolean addReplicator(PeerId peer, ReplicatorType replicatorType)
peer - target peerreplicatorType - replicator typeboolean addReplicator(PeerId peer, ReplicatorType replicatorType, boolean sync)
peer - target peerreplicatorType - replicator typesync - synchronousvoid sendHeartbeat(PeerId peer, RpcResponseClosure<RpcRequests.AppendEntriesResponse> closure)
peer - target peerclosure - callbackThreadId getReplicator(PeerId peer)
peer - peer of replicatorvoid checkReplicator(PeerId peer, boolean lockNode)
peer - peer of replicatorlockNode - if lock with nodevoid clearFailureReplicators()
boolean waitCaughtUp(PeerId peer, long maxMargin, long dueTime, CatchUpClosure done)
long getLastRpcSendTimestamp(PeerId peer)
peer - the peer of replicatorboolean stopAll()
boolean stopReplicator(PeerId peer)
peer - the peer of replicatorboolean resetTerm(long newTerm)
newTerm - new term numboolean resetHeartbeatInterval(int newIntervalMs)
newIntervalMs - new heartbeat interval millisboolean resetElectionTimeoutInterval(int newIntervalMs)
newIntervalMs - new election timeout millisboolean contains(PeerId peer)
peer - target peerboolean transferLeadershipTo(PeerId peer, long logIndex)
peer - target peerlogIndex - log indexboolean stopTransferLeadership(PeerId peer)
peer - target peerThreadId stopAllAndFindTheNextCandidate(ConfigurationEntry conf)
conf - configuration of all replicatorsPeerId findTheNextCandidate(ConfigurationEntry conf)
conf - configuration of all replicatorsCopyright © 2021. All rights reserved.