public static class CopycatServer.Builder extends Object implements Builder<CopycatServer>
This builder should be used to programmatically configure and construct a new CopycatServer instance.
The builder provides methods for configuring all aspects of a Copycat server. The CopycatServer.Builder
class cannot be instantiated directly. To create a new builder, use one of the
server builder factory methods.
CopycatServer.Builder builder = CopycatServer.builder(address);
Once the server has been configured, use the build() method to build the server instance:
CopycatServer server = CopycatServer.builder(address)
...
.build();
Each server must be configured with a StateMachine. 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.
CopycatServer server = CopycatServer.builder(address)
.withStateMachine(MyStateMachine::new)
.build();
Similarly critical to the operation of the server are the Transport and Storage layers. By default,
servers are configured with the io.atomix.catalyst.transport.netty.NettyTransport transport if it's available on
the classpath. Users should provide a Storage instance to specify how the server stores state changes.| Modifier and Type | Method and Description |
|---|---|
CopycatServer |
build() |
CopycatServer.Builder |
withClientTransport(Transport transport)
Sets the client transport.
|
CopycatServer.Builder |
withElectionTimeout(Duration electionTimeout)
Sets the Raft election timeout, returning the Raft configuration for method chaining.
|
CopycatServer.Builder |
withGlobalSuspendTimeout(Duration globalSuspendTimeout)
Sets the timeout after which suspended global replication will resume and force a partitioned follower
to truncate its log once the partition heals.
|
CopycatServer.Builder |
withHeartbeatInterval(Duration heartbeatInterval)
Sets the Raft heartbeat interval, returning the Raft configuration for method chaining.
|
CopycatServer.Builder |
withName(String name)
Sets the server name.
|
CopycatServer.Builder |
withSerializer(Serializer serializer)
Sets the Raft serializer.
|
CopycatServer.Builder |
withServerTransport(Transport transport)
Sets the server transport.
|
CopycatServer.Builder |
withSessionTimeout(Duration sessionTimeout)
Sets the Raft session timeout, returning the Raft configuration for method chaining.
|
CopycatServer.Builder |
withStateMachine(Supplier<StateMachine> factory)
Sets the Raft state machine factory.
|
CopycatServer.Builder |
withStorage(Storage storage)
Sets the storage module.
|
CopycatServer.Builder |
withTransport(Transport transport)
Sets the client and server transport.
|
CopycatServer.Builder |
withType(Member.Type type)
Sets the initial server member type.
|
public CopycatServer.Builder withName(String name)
The server name is used to
name - The server name.public CopycatServer.Builder withType(Member.Type type)
type - The initial server member type.public CopycatServer.Builder withTransport(Transport transport)
transport - The client and server transport.NullPointerException - if transport is nullpublic CopycatServer.Builder withClientTransport(Transport transport)
transport - The client transport.NullPointerException - if transport is nullpublic CopycatServer.Builder withServerTransport(Transport transport)
transport - The server transport.NullPointerException - if transport is nullpublic CopycatServer.Builder withSerializer(Serializer serializer)
serializer - The Raft serializer.NullPointerException - if serializer is nullpublic CopycatServer.Builder withStorage(Storage storage)
storage - The storage module.NullPointerException - if storage is nullpublic CopycatServer.Builder withStateMachine(Supplier<StateMachine> factory)
factory - The Raft state machine factory.NullPointerException - if the factory is nullpublic CopycatServer.Builder withElectionTimeout(Duration electionTimeout)
electionTimeout - The Raft election timeout duration.IllegalArgumentException - If the election timeout is not positiveNullPointerException - if electionTimeout is nullpublic CopycatServer.Builder withHeartbeatInterval(Duration heartbeatInterval)
heartbeatInterval - The Raft heartbeat interval duration.IllegalArgumentException - If the heartbeat interval is not positiveNullPointerException - if heartbeatInterval is nullpublic CopycatServer.Builder withSessionTimeout(Duration sessionTimeout)
sessionTimeout - The Raft session timeout duration.IllegalArgumentException - If the session timeout is not positiveNullPointerException - if sessionTimeout is nullpublic CopycatServer.Builder withGlobalSuspendTimeout(Duration globalSuspendTimeout)
globalSuspendTimeout - The timeout after which to resume global replication.public CopycatServer build()
build in interface Builder<CopycatServer>ConfigurationException - if a state machine, members or transport are not configuredCopyright © 2013–2016. All rights reserved.