Class RaftServer.Builder

java.lang.Object
io.atomix.raft.RaftServer.Builder
All Implemented Interfaces:
Builder<RaftServer>
Direct Known Subclasses:
DefaultRaftServer.Builder
Enclosing interface:
RaftServer

public abstract static class RaftServer.Builder extends Object implements Builder<RaftServer>
Builds a single-use Raft server.

This builder should be used to programmatically configure and construct a new RaftServer instance. The builder provides methods for configuring all aspects of a Raft server. The RaftServer.Builder class cannot be instantiated directly. To create a new builder, use one of the server builder factory methods.


 RaftServer.Builder builder = RaftServer.builder(address);

 
Once the server has been configured, use the Builder.build() method to build the server instance:

 RaftServer server = RaftServer.builder(address)
   ...
   .build();

 
The state machine is the component of the server that stores state and reacts to commands and queries submitted by clients to the cluster. State machines are provided to the server in the form of a state machine factory to allow the server to reconstruct its state when necessary.

 RaftServer server = RaftServer.builder(address)
   .withStateMachine(MyStateMachine::new)
   .build();