public class ReplicatorGroupImpl extends Object implements ReplicatorGroup
Describer.DefaultPrinter, Describer.Printer| Constructor and Description |
|---|
ReplicatorGroupImpl() |
| Modifier and Type | Method and Description |
|---|---|
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|
|
void |
describe(Describer.Printer out) |
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(String groupId,
PeerId peer,
long maxMargin,
long dueTime,
CatchUpClosure done)
Wait the peer catchup.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddReplicator, addReplicatorpublic boolean init(NodeId nodeId, ReplicatorGroupOptions opts)
ReplicatorGroupinit in interface ReplicatorGroupnodeId - node idopts - options of replicator grouppublic void sendHeartbeat(PeerId peer, RpcResponseClosure<RpcRequests.AppendEntriesResponse> closure)
ReplicatorGroupsendHeartbeat in interface ReplicatorGrouppeer - target peerclosure - callbackpublic ThreadId getReplicator(PeerId peer)
ReplicatorGroupgetReplicator in interface ReplicatorGrouppeer - peer of replicatorpublic boolean addReplicator(PeerId peer, ReplicatorType replicatorType, boolean sync)
ReplicatorGroupaddReplicator in interface ReplicatorGrouppeer - target peerreplicatorType - replicator typesync - synchronouspublic void clearFailureReplicators()
ReplicatorGroupclearFailureReplicators in interface ReplicatorGrouppublic boolean waitCaughtUp(String groupId, PeerId peer, long maxMargin, long dueTime, CatchUpClosure done)
ReplicatorGroupwaitCaughtUp in interface ReplicatorGrouppublic long getLastRpcSendTimestamp(PeerId peer)
ReplicatorGroupgetLastRpcSendTimestamp in interface ReplicatorGrouppeer - the peer of replicatorpublic boolean stopAll()
ReplicatorGroupstopAll in interface ReplicatorGrouppublic void checkReplicator(PeerId peer, boolean lockNode)
ReplicatorGroupcheckReplicator in interface ReplicatorGrouppeer - peer of replicatorlockNode - if lock with nodepublic boolean stopReplicator(PeerId peer)
ReplicatorGroupstopReplicator in interface ReplicatorGrouppeer - the peer of replicatorpublic boolean resetTerm(long newTerm)
ReplicatorGroupresetTerm in interface ReplicatorGroupnewTerm - new term numpublic boolean resetHeartbeatInterval(int newIntervalMs)
ReplicatorGroupresetHeartbeatInterval in interface ReplicatorGroupnewIntervalMs - new heartbeat interval millispublic boolean resetElectionTimeoutInterval(int newIntervalMs)
ReplicatorGroupresetElectionTimeoutInterval in interface ReplicatorGroupnewIntervalMs - new election timeout millispublic boolean contains(PeerId peer)
ReplicatorGroupcontains in interface ReplicatorGrouppeer - target peerpublic boolean transferLeadershipTo(PeerId peer, long logIndex)
ReplicatorGrouptransferLeadershipTo in interface ReplicatorGrouppeer - target peerlogIndex - log indexpublic boolean stopTransferLeadership(PeerId peer)
ReplicatorGroupstopTransferLeadership in interface ReplicatorGrouppeer - target peerpublic ThreadId stopAllAndFindTheNextCandidate(ConfigurationEntry conf)
ReplicatorGroupstopAllAndFindTheNextCandidate in interface ReplicatorGroupconf - configuration of all replicatorspublic PeerId findTheNextCandidate(ConfigurationEntry conf)
ReplicatorGroupfindTheNextCandidate in interface ReplicatorGroupconf - configuration of all replicatorspublic List<ThreadId> listReplicators()
ReplicatorGrouplistReplicators in interface ReplicatorGrouppublic void describe(Describer.Printer out)
Copyright © 2024. All rights reserved.