Package io.atomix.raft
Class RaftServer.Builder
java.lang.Object
io.atomix.raft.RaftServer.Builder
- All Implemented Interfaces:
Builder<RaftServer>
- Direct Known Subclasses:
DefaultRaftServer.Builder
- Enclosing interface:
- 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();
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected RaftElectionConfigprotected EntryValidatorprotected MemberIdprotected ClusterMembershipServiceprotected Stringprotected RaftPartitionConfigprotected intprotected RaftServerProtocolprotected RaftStorageprotected RaftThreadContextFactory -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionwithElectionConfig(RaftElectionConfig electionConfig) withEntryValidator(EntryValidator entryValidator) withMembershipService(ClusterMembershipService membershipService) Sets the cluster membership service.Sets the server name.withPartitionConfig(RaftPartitionConfig partitionConfig) withPartitionId(int partitionId) withProtocol(RaftServerProtocol protocol) Sets the server protocol.withStorage(RaftStorage storage) Sets the storage module.withThreadContextFactory(RaftThreadContextFactory threadContextFactory) Sets the threadContextFactory used to create raft threadContext
-
Field Details
-
name
-
localMemberId
-
membershipService
-
protocol
-
storage
-
threadContextFactory
-
randomFactory
-
entryValidator
-
electionConfig
-
partitionConfig
-
partitionId
protected int partitionId
-
-
Constructor Details
-
Builder
-
-
Method Details
-
withName
Sets the server name.The server name is used to
- Parameters:
name- The server name.- Returns:
- The server builder.
-
withMembershipService
Sets the cluster membership service.- Parameters:
membershipService- the cluster membership service- Returns:
- the server builder
-
withProtocol
Sets the server protocol.- Parameters:
protocol- The server protocol.- Returns:
- The server builder.
-
withStorage
Sets the storage module.- Parameters:
storage- The storage module.- Returns:
- The Raft server builder.
- Throws:
NullPointerException- ifstorageis null
-
withThreadContextFactory
Sets the threadContextFactory used to create raft threadContext- Parameters:
threadContextFactory- The RaftThreadContextFactory- Returns:
- The Raft server builder.
- Throws:
NullPointerException- ifthreadContextFactoryis null
-
withEntryValidator
-
withElectionConfig
-
withPartitionConfig
-
withPartitionId
-