Interface RaftNode.RaftNodeBuilder
- Enclosing interface:
- RaftNode
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds and returns the RaftNode instance with the given settings.Sets the Clock instance used by parts of the Raft algorithm.setConfig
(RaftConfig config) Sets the Raft config.setExecutor
(RaftNodeExecutor executor) Sets the Raft node executor object to be used for running submitted and scheduled tasks.setGroupId
(Object groupId) Sets the unique ID of the Raft group that this Raft node belongs to.setInitialGroupMembers
(Collection<RaftEndpoint> initialGroupMembers) Sets the initial member list of the Raft group that the Raft node belongs to.setInitialGroupMembers
(Collection<RaftEndpoint> initialGroupMembers, Collection<RaftEndpoint> initialVotingGroupMembers) Sets the initial member list of the Raft group that the Raft node belongs to.setLocalEndpoint
(RaftEndpoint localEndpoint) Sets the endpoint of the Raft node being created.setModelFactory
(RaftModelFactory modelFactory) Sets the Raft model factory object to be used for creating Raft model objects.Sets the Raft node report listener object to be notified about events related to the execution of the Raft consensus algorithm.Sets the Random instance used in parts of the Raft algorithm.setRestoredState
(RestoredRaftState restoredState) Sets theRestoredRaftState
to be used for creating the Raft node instance.setStateMachine
(StateMachine stateMachine) Sets the state machine object to be used for execution of queries and committed operations.Sets the Raft state object to be used for persisting internal Raft state to stable storage.setTransport
(Transport transport) Sets the transport object to be used for communicating with other Raft nodes.
-
Method Details
-
setGroupId
Sets the unique ID of the Raft group that this Raft node belongs to.- Parameters:
groupId
- the group id to create the Raft node with- Returns:
- the builder object for fluent calls
-
setLocalEndpoint
Sets the endpoint of the Raft node being created.This method must be used along with one of the
setInitialGroupMembers(Collection)
overloads when either a new Raft group is bootstrapping for the first time or a new Raft node is being added to a running Raft group.- Parameters:
localEndpoint
- the Raft endpoint to create the Raft node with- Returns:
- the builder object for fluent calls
-
setInitialGroupMembers
@Nonnull RaftNode.RaftNodeBuilder setInitialGroupMembers(@Nonnull Collection<RaftEndpoint> initialGroupMembers) Sets the initial member list of the Raft group that the Raft node belongs to. All members are voting members.On bootstrapping a new Raft group, the initial member list must be decided externally and provided to all Raft nodes. In addition, if a new Raft node is going to be added to a running Raft group, the same initial Raft group member list must be provided to the new Raft node.
This method must be called along with
setLocalEndpoint(RaftEndpoint)
when either a new Raft group is bootstrapping for the first time or a new Raft node is being added to a running Raft group.- Parameters:
initialGroupMembers
- the initial group members of the Raft group which the Raft node belongs to- Returns:
- the builder object for fluent calls
-
setInitialGroupMembers
@Nonnull RaftNode.RaftNodeBuilder setInitialGroupMembers(@Nonnull Collection<RaftEndpoint> initialGroupMembers, @Nonnull Collection<RaftEndpoint> initialVotingGroupMembers) Sets the initial member list of the Raft group that the Raft node belongs to. The initial member list contains voting and non-voting members together. There must be at least one voting member in the initial Raft group member list.On bootstrapping a new Raft group, the initial member list must be decided externally and provided to all Raft nodes. In addition, if a new Raft node is going to be added to a running Raft group, the same initial Raft group member list must be provided to the new Raft node.
This method must be called along with
setLocalEndpoint(RaftEndpoint)
when either a new Raft group is bootstrapping for the first time or a new Raft node is being added to a running Raft group.- Parameters:
initialGroupMembers
- the initial group members of the Raft group which the Raft node belongs toinitialVotingGroupMembers
- the list of voting members in the initial Raft group member list- Returns:
- the builder object for fluent calls
-
setRestoredState
Sets theRestoredRaftState
to be used for creating the Raft node instance.RestoredRaftState
is used in crash-recover scenarios to recover a Raft node after a crash or a restart. Namely, when aRestoredRaftState
is provided, the created Raft node initializes its internal Raft state from this object and continues its operation as if it has not crashed.setLocalEndpoint(RaftEndpoint)
andsetInitialGroupMembers(Collection)
must not be called when aRestoredRaftState
object is provided via this method.- Parameters:
restoredState
- the restored Raft state which will be used while creating the Raft node- Returns:
- the builder object for fluent calls
- See Also:
-
setConfig
Sets the Raft config.If not set,
RaftConfig.DEFAULT_RAFT_CONFIG
is used.- Parameters:
config
- the config object to create the Raft node with- Returns:
- the builder object for fluent calls
- See Also:
-
setExecutor
Sets the Raft node executor object to be used for running submitted and scheduled tasks.If not set,
DefaultRaftNodeExecutor
is used.- Parameters:
executor
- the Raft node executor object to be used for running submitted and scheduled tasks- Returns:
- the builder object for fluent calls
- See Also:
-
RaftNodeExecutor
DefaultRaftNodeExecutor
-
setTransport
Sets the transport object to be used for communicating with other Raft nodes.- Parameters:
transport
- the transport object to be used for communicating with other Raft nodes- Returns:
- the builder object for fluent calls
- See Also:
-
setStateMachine
Sets the state machine object to be used for execution of queries and committed operations.- Parameters:
stateMachine
- the state machine object which will be used for execution of queries and committed operations- Returns:
- the builder object for fluent calls
- See Also:
-
setStore
Sets the Raft state object to be used for persisting internal Raft state to stable storage.If not set,
NopRaftStore
is used which keeps the internal Raft state in memory and disables crash-recover scenarios.- Parameters:
store
- the Raft state object to be used for persisting internal Raft state to stable storage.- Returns:
- the builder object for fluent calls
- See Also:
-
setModelFactory
Sets the Raft model factory object to be used for creating Raft model objects.If not set,
DefaultRaftModelFactory
is used.- Parameters:
modelFactory
- the factory object to be used for creating Raft model objects- Returns:
- the builder object for fluent calls
- See Also:
-
RaftModelFactory
DefaultRaftModelFactory
-
setRaftNodeReportListener
Sets the Raft node report listener object to be notified about events related to the execution of the Raft consensus algorithm.- Parameters:
listener
- the Raft node report listener object to be notified about events related to the execution of the Raft consensus algorithm- Returns:
- the builder object for fluent calls
- See Also:
-
setRandom
Sets the Random instance used in parts of the Raft algorithm.- Parameters:
random
- the Random instance to be used by this RaftNode.- Returns:
- the builder object for fluent calls
-
setClock
Sets the Clock instance used by parts of the Raft algorithm.- Parameters:
clock
- the Clock instance to be used by this RaftNode.- Returns:
- the builder object for fluent calls
-
build
Builds and returns the RaftNode instance with the given settings.- Returns:
- the built RaftNode instance.
-