public abstract static class RaftServer.Builder extends java.lang.Object implements 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 |
withElectionTimeout(java.time.Duration electionTimeout)
Sets the Raft election timeout, returning the Raft configuration for method chaining.
|
RaftServer.Builder |
withHeartbeatInterval(java.time.Duration heartbeatInterval)
Sets the Raft heartbeat interval, returning the Raft configuration for method chaining.
|
RaftServer.Builder |
withMembershipService(ClusterMembershipService membershipService)
Sets the cluster membership service.
|
RaftServer.Builder |
withName(java.lang.String name)
Sets the server name.
|
RaftServer.Builder |
withPrimitiveTypes(PrimitiveTypeRegistry primitiveTypes)
Sets the primitive types.
|
RaftServer.Builder |
withProtocol(io.atomix.protocols.raft.protocol.RaftServerProtocol protocol)
Sets the server protocol.
|
RaftServer.Builder |
withSessionTimeout(java.time.Duration sessionTimeout)
Sets the Raft session timeout, returning the Raft configuration for method chaining.
|
RaftServer.Builder |
withStorage(io.atomix.protocols.raft.storage.RaftStorage storage)
Sets the storage module.
|
RaftServer.Builder |
withThreadContextFactory(io.atomix.utils.concurrent.ThreadContextFactory threadContextFactory)
Sets the client thread context factory.
|
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.
|
public RaftServer.Builder withName(java.lang.String name)
The server name is used to
name - The server name.public RaftServer.Builder withMembershipService(ClusterMembershipService membershipService)
membershipService - the cluster membership servicepublic RaftServer.Builder withProtocol(io.atomix.protocols.raft.protocol.RaftServerProtocol protocol)
protocol - The server protocol.public RaftServer.Builder withThreadModel(io.atomix.utils.concurrent.ThreadModel threadModel)
threadModel - the server thread modelpublic RaftServer.Builder withStorage(io.atomix.protocols.raft.storage.RaftStorage storage)
storage - The storage module.java.lang.NullPointerException - if storage is nullpublic RaftServer.Builder withPrimitiveTypes(PrimitiveTypeRegistry primitiveTypes)
primitiveTypes - the primitive typesjava.lang.NullPointerException - if the primitiveTypes argument is nullpublic RaftServer.Builder withElectionTimeout(java.time.Duration electionTimeout)
electionTimeout - The Raft election timeout duration.java.lang.IllegalArgumentException - If the election timeout is not positivejava.lang.NullPointerException - if electionTimeout is nullpublic RaftServer.Builder withHeartbeatInterval(java.time.Duration heartbeatInterval)
heartbeatInterval - The Raft heartbeat interval duration.java.lang.IllegalArgumentException - If the heartbeat interval is not positivejava.lang.NullPointerException - if heartbeatInterval is nullpublic RaftServer.Builder withSessionTimeout(java.time.Duration sessionTimeout)
sessionTimeout - The Raft session timeout duration.java.lang.IllegalArgumentException - If the session timeout is not positivejava.lang.NullPointerException - if sessionTimeout is nullpublic RaftServer.Builder withThreadPoolSize(int threadPoolSize)
threadPoolSize - The server thread pool size.public RaftServer.Builder withThreadContextFactory(io.atomix.utils.concurrent.ThreadContextFactory threadContextFactory)
threadContextFactory - the client thread context factoryjava.lang.NullPointerException - if the factory is nullCopyright © 2013-2019. All Rights Reserved.