public abstract static class RaftServer.Builder extends Object implements io.atomix.utils.Builder<RaftServer>
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();
Each server must be configured with a PrimitiveService. 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();
| Modifier and Type | Method and Description |
|---|---|
RaftServer.Builder |
addPrimitiveType(io.atomix.primitive.PrimitiveType primitiveType)
Adds a primitive type to the registry.
|
RaftServer.Builder |
withClusterService(io.atomix.cluster.ClusterService clusterService)
Sets the cluster service.
|
RaftServer.Builder |
withElectionTimeout(Duration electionTimeout)
Sets the Raft election timeout, returning the Raft configuration for method chaining.
|
RaftServer.Builder |
withHeartbeatInterval(Duration heartbeatInterval)
Sets the Raft heartbeat interval, returning the Raft configuration for method chaining.
|
RaftServer.Builder |
withName(String name)
Sets the server name.
|
RaftServer.Builder |
withPrimitiveTypes(io.atomix.primitive.PrimitiveTypeRegistry primitiveTypes)
Sets the primitive types.
|
RaftServer.Builder |
withProtocol(RaftServerProtocol protocol)
Sets the server protocol.
|
RaftServer.Builder |
withSessionTimeout(Duration sessionTimeout)
Sets the Raft session timeout, returning the Raft configuration for method chaining.
|
RaftServer.Builder |
withStorage(RaftStorage storage)
Sets the storage module.
|
RaftServer.Builder |
withThreadModel(io.atomix.utils.concurrent.ThreadModel threadModel)
Sets the server thread model.
|
RaftServer.Builder |
withThreadPoolSize(int threadPoolSize)
Sets the server thread pool size.
|
RaftServer.Builder |
withType(RaftMember.Type type)
Deprecated.
|
public RaftServer.Builder withName(String name)
The server name is used to
name - The server name.public RaftServer.Builder withClusterService(io.atomix.cluster.ClusterService clusterService)
clusterService - the cluster service@Deprecated public RaftServer.Builder withType(RaftMember.Type type)
type - The initial server member type.public RaftServer.Builder withProtocol(RaftServerProtocol protocol)
protocol - The server protocol.public RaftServer.Builder withThreadModel(io.atomix.utils.concurrent.ThreadModel threadModel)
threadModel - the server thread modelpublic RaftServer.Builder withStorage(RaftStorage storage)
storage - The storage module.NullPointerException - if storage is nullpublic RaftServer.Builder withPrimitiveTypes(io.atomix.primitive.PrimitiveTypeRegistry primitiveTypes)
primitiveTypes - the primitive typesNullPointerException - if the primitiveTypes argument is nullpublic RaftServer.Builder addPrimitiveType(io.atomix.primitive.PrimitiveType primitiveType)
primitiveType - the primitive type to addNullPointerException - if the primitiveType is nullpublic RaftServer.Builder withElectionTimeout(Duration electionTimeout)
electionTimeout - The Raft election timeout duration.IllegalArgumentException - If the election timeout is not positiveNullPointerException - if electionTimeout is nullpublic RaftServer.Builder withHeartbeatInterval(Duration heartbeatInterval)
heartbeatInterval - The Raft heartbeat interval duration.IllegalArgumentException - If the heartbeat interval is not positiveNullPointerException - if heartbeatInterval is nullpublic RaftServer.Builder withSessionTimeout(Duration sessionTimeout)
sessionTimeout - The Raft session timeout duration.IllegalArgumentException - If the session timeout is not positiveNullPointerException - if sessionTimeout is nullpublic RaftServer.Builder withThreadPoolSize(int threadPoolSize)
threadPoolSize - The server thread pool size.Copyright © 2013–2018. All rights reserved.