Interface RaftNode.RaftNodeBuilder
-
- Enclosing interface:
- RaftNode
public static interface RaftNode.RaftNodeBuilder
The builder interface for configuring and creating Raft node instances.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description RaftNode
build()
Builds and returns the RaftNode instance with the given settings.RaftNode.RaftNodeBuilder
setClock(Clock clock)
Sets the Clock instance used by parts of the Raft algorithm.RaftNode.RaftNodeBuilder
setConfig(RaftConfig config)
Sets the Raft config.RaftNode.RaftNodeBuilder
setExecutor(RaftNodeExecutor executor)
Sets the Raft node executor object to be used for running submitted and scheduled tasks.RaftNode.RaftNodeBuilder
setGroupId(Object groupId)
Sets the unique ID of the Raft group that this Raft node belongs to.RaftNode.RaftNodeBuilder
setInitialGroupMembers(Collection<RaftEndpoint> initialGroupMembers)
Sets the initial member list of the Raft group that the Raft node belongs to.RaftNode.RaftNodeBuilder
setInitialGroupMembers(Collection<RaftEndpoint> initialGroupMembers, Collection<RaftEndpoint> initialVotingGroupMembers)
Sets the initial member list of the Raft group that the Raft node belongs to.RaftNode.RaftNodeBuilder
setLocalEndpoint(RaftEndpoint localEndpoint)
Sets the endpoint of the Raft node being created.RaftNode.RaftNodeBuilder
setModelFactory(RaftModelFactory modelFactory)
Sets the Raft model factory object to be used for creating Raft model objects.RaftNode.RaftNodeBuilder
setRaftNodeReportListener(RaftNodeReportListener listener)
Sets the Raft node report listener object to be notified about events related to the execution of the Raft consensus algorithm.RaftNode.RaftNodeBuilder
setRandom(Random random)
Sets the Random instance used in parts of the Raft algorithm.RaftNode.RaftNodeBuilder
setRestoredState(RestoredRaftState restoredState)
Sets theRestoredRaftState
to be used for creating the Raft node instance.RaftNode.RaftNodeBuilder
setStateMachine(StateMachine stateMachine)
Sets the state machine object to be used for execution of queries and committed operations.RaftNode.RaftNodeBuilder
setStore(RaftStore store)
Sets the Raft state object to be used for persisting internal Raft state to stable storage.RaftNode.RaftNodeBuilder
setTransport(Transport transport)
Sets the transport object to be used for communicating with other Raft nodes.
-
-
-
Method Detail
-
setGroupId
@Nonnull RaftNode.RaftNodeBuilder setGroupId(@Nonnull Object groupId)
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
@Nonnull RaftNode.RaftNodeBuilder setLocalEndpoint(@Nonnull RaftEndpoint localEndpoint)
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
@Nonnull RaftNode.RaftNodeBuilder setRestoredState(@Nonnull RestoredRaftState restoredState)
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:
RestoredRaftState
-
setConfig
@Nonnull RaftNode.RaftNodeBuilder setConfig(@Nonnull RaftConfig config)
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:
RaftConfig
-
setExecutor
@Nonnull RaftNode.RaftNodeBuilder setExecutor(@Nonnull RaftNodeExecutor executor)
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
@Nonnull RaftNode.RaftNodeBuilder setTransport(@Nonnull Transport transport)
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:
Transport
-
setStateMachine
@Nonnull RaftNode.RaftNodeBuilder setStateMachine(@Nonnull StateMachine stateMachine)
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:
StateMachine
-
setStore
@Nonnull RaftNode.RaftNodeBuilder setStore(@Nonnull RaftStore store)
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:
RaftStore
-
setModelFactory
@Nonnull RaftNode.RaftNodeBuilder setModelFactory(@Nonnull RaftModelFactory modelFactory)
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
RaftNode.RaftNodeBuilder setRaftNodeReportListener(@Nonnull RaftNodeReportListener listener)
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:
RaftNodeReportListener
-
setRandom
RaftNode.RaftNodeBuilder setRandom(Random random)
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
RaftNode.RaftNodeBuilder setClock(Clock clock)
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
@Nonnull RaftNode build()
Builds and returns the RaftNode instance with the given settings.- Returns:
- the built RaftNode instance.
-
-