public abstract class StateMachineAdapter extends Object implements StateMachine
StateMachine.onApply(com.alipay.sofa.jraft.Iterator).| 构造器和说明 |
|---|
StateMachineAdapter() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
onConfigurationCommitted(Configuration conf)
Invoked when a configuration has been committed to the group.
|
void |
onError(RaftException e)
This method is called when a critical error was encountered, after this
point, no any further modification is allowed to applied to this node
until the error is fixed and this node restarts.
|
void |
onLeaderStart(long term)
Invoked when the belonging node becomes the leader of the group at |term|
Default: Do nothing
|
void |
onLeaderStop(Status status)
Invoked when this node steps down from the leader of the replication
group and |status| describes detailed information
|
void |
onShutdown()
Invoked once when the raft node was shut down.
|
boolean |
onSnapshotLoad(SnapshotReader reader)
User defined snapshot load function
get and load snapshot
Default: Load nothing and returns error.
|
void |
onSnapshotSave(SnapshotWriter writer,
Closure done)
User defined snapshot generate function, this method will block StateMachine#onApply(Iterator).
|
void |
onStartFollowing(LeaderChangeContext ctx)
This method is called when a follower or candidate starts following a leader and its leaderId
(should be NULL before the method is called) is set to the leader's id,
situations including:
1. a candidate receives appendEntries request from a leader
2. a follower(without leader) receives appendEntries from a leader
the parameter ctx gives the information(leaderId, term and status) about
the very leader whom the follower starts to follow.
|
void |
onStopFollowing(LeaderChangeContext ctx)
This method is called when a follower stops following a leader and its leaderId becomes null,
situations including:
1. handle election timeout and start preVote
2. receive requests with higher term such as VoteRequest from a candidate
or appendEntries request from a new leader
3. receive timeoutNow request from current leader and start request vote.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitonApplypublic void onShutdown()
StateMachineonShutdown 在接口中 StateMachinepublic void onSnapshotSave(SnapshotWriter writer, Closure done)
StateMachineonSnapshotSave 在接口中 StateMachinewriter - snapshot writerdone - callbackpublic boolean onSnapshotLoad(SnapshotReader reader)
StateMachineonSnapshotLoad 在接口中 StateMachinereader - snapshot readerpublic void onLeaderStart(long term)
StateMachineonLeaderStart 在接口中 StateMachineterm - new term numpublic void onLeaderStop(Status status)
StateMachineonLeaderStop 在接口中 StateMachinestatus - status infopublic void onError(RaftException e)
StateMachineonError 在接口中 StateMachinee - raft error messagepublic void onConfigurationCommitted(Configuration conf)
StateMachineonConfigurationCommitted 在接口中 StateMachineconf - committed configurationpublic void onStopFollowing(LeaderChangeContext ctx)
StateMachineonStopFollowing 在接口中 StateMachinectx - context of leader changepublic void onStartFollowing(LeaderChangeContext ctx)
StateMachineonStartFollowing 在接口中 StateMachinectx - context of leader changeCopyright © 2021. All rights reserved.