Class AtomixClusterBuilder
- All Implemented Interfaces:
io.atomix.utils.Builder<AtomixCluster>
public class AtomixClusterBuilder extends Object implements io.atomix.utils.Builder<AtomixCluster>
AtomixCluster instance.
This builder is used to configure an AtomixCluster instance programmatically. To create a new builder, use
one of the AtomixCluster.builder() static methods.
AtomixClusterBuilder builder = AtomixCluster.builder();
The instance is configured by calling the with* methods on this builder. Once the instance has been
configured, call build() to build the instance:
AtomixCluster cluster = AtomixCluster.builder()
.withMemberId("member-1")
.withAddress("localhost", 5000)
.build();
Backing the builder is an ClusterConfig which is loaded when the builder is initially constructed. To load
a configuration from a file, use AtomixCluster.builder(String).-
Method Summary
Modifier and Type Method Description AtomixClusterbuild()AtomixClusterBuildersetBroadcastInterval(java.time.Duration interval)Deprecated.since 3.0.2AtomixClusterBuildersetReachabilityThreshold(int threshold)Deprecated.since 3.0.2AtomixClusterBuilderwithAddress(int port)Deprecated.since 3.1.AtomixClusterBuilderwithAddress(io.atomix.utils.net.Address address)Sets the member address.AtomixClusterBuilderwithAddress(String address)Deprecated.since 3.1.AtomixClusterBuilderwithAddress(String host, int port)Deprecated.since 3.1.AtomixClusterBuilderwithBroadcastInterval(java.time.Duration interval)Deprecated.AtomixClusterBuilderwithClusterId(String clusterId)Sets the cluster identifier.AtomixClusterBuilderwithConnectionPoolSize(int connectionPoolSize)Sets the messaging connection pool size.AtomixClusterBuilderwithHost(String host)Sets the member host.AtomixClusterBuilderwithHostId(String hostId)Sets the host to which the member belongs.AtomixClusterBuilderwithKeyStore(String keyStore)Sets the key store to use for TLS in the Atomix messaging service.AtomixClusterBuilderwithKeyStorePassword(String keyStorePassword)Sets the key store password for the Atomix messaging service.AtomixClusterBuilderwithMemberId(MemberId localMemberId)Sets the local member identifier.AtomixClusterBuilderwithMemberId(String localMemberId)Sets the local member identifier.AtomixClusterBuilderwithMembershipProtocol(GroupMembershipProtocol protocol)Sets the cluster membership protocol.AtomixClusterBuilderwithMembershipProvider(NodeDiscoveryProvider locationProvider)Sets the cluster membership provider.AtomixClusterBuilderwithMessagingInterface(String iface)Sets the interface to which to bind the instance.AtomixClusterBuilderwithMessagingInterfaces(String... ifaces)Sets the interface(s) to which to bind the instance.AtomixClusterBuilderwithMessagingInterfaces(Collection<String> ifaces)Sets the interface(s) to which to bind the instance.AtomixClusterBuilderwithMessagingPort(int bindPort)Sets the local port to which to bind the node.AtomixClusterBuilderwithMulticastAddress(io.atomix.utils.net.Address address)Sets the multicast address.AtomixClusterBuilderwithMulticastEnabled()Enables multicast communication.AtomixClusterBuilderwithMulticastEnabled(boolean multicastEnabled)Sets whether multicast communication is enabled.AtomixClusterBuilderwithPort(int port)Sets the member port.AtomixClusterBuilderwithProperties(Properties properties)Sets the member properties.AtomixClusterBuilderwithProperty(String key, String value)Sets a property of the member.AtomixClusterBuilderwithRack(String rack)Deprecated.since 3.1.AtomixClusterBuilderwithRackId(String rackId)Sets the rack to which the member belongs.AtomixClusterBuilderwithReachabilityThreshold(int threshold)Deprecated.AtomixClusterBuilderwithReachabilityTimeout(java.time.Duration timeout)Deprecated.AtomixClusterBuilderwithTlsEnabled()Enables TLS for the Atomix messaging service.AtomixClusterBuilderwithTlsEnabled(boolean tlsEnabled)Sets whether TLS is enabled for the Atomix messaging service.AtomixClusterBuilderwithTrustStore(String trustStore)Sets the trust store to use for TLS in the Atomix messaging service.AtomixClusterBuilderwithTrustStorePassword(String trustStorePassword)Sets the trust store password for the Atomix messaging service.AtomixClusterBuilderwithZone(String zone)Deprecated.since 3.1.AtomixClusterBuilderwithZoneId(String zoneId)Sets the zone to which the member belongs.
-
Method Details
-
withClusterId
Sets the cluster identifier.The cluster identifier is used to verify intra-cluster communication is taking place between nodes that are intended to be part of the same cluster, e.g. if multicast discovery is used. It only needs to be configured if multiple Atomix clusters are running within the same network.
- Parameters:
clusterId- the cluster identifier- Returns:
- the cluster builder
-
withMemberId
Sets the local member identifier.The member identifier is an optional attribute that can be used to identify and send messages directly to this node. If no member identifier is provided, a
UUIDbased identifier will be generated.- Parameters:
localMemberId- the local member identifier- Returns:
- the cluster builder
-
withMemberId
Sets the local member identifier.The member identifier is an optional attribute that can be used to identify and send messages directly to this node. If no member identifier is provided, a
UUIDbased identifier will be generated.- Parameters:
localMemberId- the local member identifier- Returns:
- the cluster builder
-
withHost
Sets the member host.- Parameters:
host- the member host- Returns:
- the cluster builder
-
withPort
Sets the member port.- Parameters:
port- the member port- Returns:
- the cluster builder
-
withAddress
Deprecated.since 3.1. UsewithHost(String)and/orwithPort(int)insteadSets the member address.The constructed
AtomixClusterwill bind to the given address for intra-cluster communication. The format of the address can behost:portor justhost.- Parameters:
address- a host:port tuple- Returns:
- the cluster builder
- Throws:
io.atomix.utils.net.MalformedAddressException- if a validAddresscannot be constructed from the arguments
-
withAddress
Deprecated.since 3.1. UsewithHost(String)andwithPort(int)insteadSets the member host/port.The constructed
AtomixClusterwill bind to the given host/port for intra-cluster communication. The provided host should be visible to other nodes in the cluster.- Parameters:
host- the host nameport- the port number- Returns:
- the cluster builder
- Throws:
io.atomix.utils.net.MalformedAddressException- if a validAddresscannot be constructed from the arguments
-
withAddress
Deprecated.since 3.1. UsewithPort(int)insteadSets the member address using local host.The constructed
AtomixClusterwill bind to the given port for intra-cluster communication.- Parameters:
port- the port number- Returns:
- the cluster builder
- Throws:
io.atomix.utils.net.MalformedAddressException- if a validAddresscannot be constructed from the arguments
-
withAddress
Sets the member address.The constructed
AtomixClusterwill bind to the given address for intra-cluster communication. The provided address should be visible to other nodes in the cluster.- Parameters:
address- the member address- Returns:
- the cluster builder
-
withZoneId
Sets the zone to which the member belongs.The zone attribute can be used to enable zone-awareness in replication for certain primitive protocols. It is an arbitrary string that should be used to group multiple nodes together by their physical location.
- Parameters:
zoneId- the zone to which the member belongs- Returns:
- the cluster builder
-
withZone
Deprecated.since 3.1. UsewithZoneId(String)insteadSets the zone to which the member belongs.The zone attribute can be used to enable zone-awareness in replication for certain primitive protocols. It is an arbitrary string that should be used to group multiple nodes together by their physical location.
- Parameters:
zone- the zone to which the member belongs- Returns:
- the cluster builder
-
withRackId
Sets the rack to which the member belongs.The rack attribute can be used to enable rack-awareness in replication for certain primitive protocols. It is an arbitrary string that should be used to group multiple nodes together by their physical location.
- Parameters:
rackId- the rack to which the member belongs- Returns:
- the cluster builder
-
withRack
Deprecated.since 3.1. UsewithRackId(String)insteadSets the rack to which the member belongs.The rack attribute can be used to enable rack-awareness in replication for certain primitive protocols. It is an arbitrary string that should be used to group multiple nodes together by their physical location.
- Parameters:
rack- the rack to which the member belongs- Returns:
- the cluster builder
-
withHostId
Sets the host to which the member belongs.The host attribute can be used to enable host-awareness in replication for certain primitive protocols. It is an arbitrary string that should be used to group multiple nodes together by their physical location. Typically this attribute only applies to containerized clusters.
- Parameters:
hostId- the host to which the member belongs- Returns:
- the cluster builder
-
withProperties
Sets the member properties.The properties are arbitrary settings that will be replicated along with this node's member information. Properties can be used to enable other nodes to determine metadata about this node.
- Parameters:
properties- the member properties- Returns:
- the cluster builder
- Throws:
NullPointerException- if the properties are null
-
withProperty
Sets a property of the member.The properties are arbitrary settings that will be replicated along with this node's member information. Properties can be used to enable other nodes to determine metadata about this node.
- Parameters:
key- the property key to setvalue- the property value to set- Returns:
- the cluster builder
- Throws:
NullPointerException- if the property is null
-
withMessagingInterface
Sets the interface to which to bind the instance.- Parameters:
iface- the interface to which to bind the instance- Returns:
- the cluster builder
-
withMessagingInterfaces
Sets the interface(s) to which to bind the instance.- Parameters:
ifaces- the interface(s) to which to bind the instance- Returns:
- the cluster builder
-
withMessagingInterfaces
Sets the interface(s) to which to bind the instance.- Parameters:
ifaces- the interface(s) to which to bind the instance- Returns:
- the cluster builder
-
withMessagingPort
Sets the local port to which to bind the node.- Parameters:
bindPort- the local port to which to bind the node- Returns:
- the cluster builder
-
withConnectionPoolSize
Sets the messaging connection pool size.The node will create
connectionPoolSizeconnections to each peer with which it regularly communicates over TCP. Periodic heartbeats from cluster membership protocols will not consume pool connections. Thus, if a node does not communicate with one of its peers for replication or application communication, the pool for that peer should remain empty.- Parameters:
connectionPoolSize- the connection pool size- Returns:
- the cluster builder
-
withMulticastEnabled
Enables multicast communication.Multicast is disabled by default. This method must be called to enable it. Enabling multicast enables the use of the
BroadcastService.- Returns:
- the cluster builder
- See Also:
withMulticastAddress(Address)
-
withMulticastEnabled
Sets whether multicast communication is enabled.Multicast is disabled by default. This method must be called to enable it. Enabling multicast enables the use of the
BroadcastService.- Parameters:
multicastEnabled- whether to enable multicast- Returns:
- the cluster builder
- See Also:
withMulticastAddress(Address)
-
withMulticastAddress
Sets the multicast address.Multicast is disabled by default. To enable multicast, first use
withMulticastEnabled().- Parameters:
address- the multicast address- Returns:
- the cluster builder
-
setBroadcastInterval
Deprecated.since 3.0.2Sets the reachability broadcast interval.The broadcast interval is the interval at which heartbeats are sent to peers in the cluster.
- Parameters:
interval- the reachability broadcast interval- Returns:
- the cluster builder
-
withBroadcastInterval
Deprecated.Sets the reachability broadcast interval.The broadcast interval is the interval at which heartbeats are sent to peers in the cluster.
- Parameters:
interval- the reachability broadcast interval- Returns:
- the cluster builder
-
setReachabilityThreshold
Deprecated.since 3.0.2Sets the reachability failure detection threshold.Reachability of cluster members is determined using a phi-accrual failure detector. The reachability threshold is the phi threshold after which a peer will be determined to be unreachable.
- Parameters:
threshold- the reachability failure detection threshold- Returns:
- the cluster builder
-
withReachabilityThreshold
Deprecated.Sets the reachability failure detection threshold.Reachability of cluster members is determined using a phi-accrual failure detector. The reachability threshold is the phi threshold after which a peer will be determined to be unreachable.
- Parameters:
threshold- the reachability failure detection threshold- Returns:
- the cluster builder
-
withReachabilityTimeout
Deprecated.Sets the reachability failure timeout.The reachability timeout determines the maximum time after which a member will be marked unreachable if heartbeats have failed.
- Parameters:
timeout- the reachability failure timeout- Returns:
- the cluster builder
-
withMembershipProtocol
Sets the cluster membership protocol.The membership protocol is responsible for determining the active set of members in the cluster, replicating member metadata, and detecting failures. The default is
HeartbeatMembershipProtocol.- Parameters:
protocol- the cluster membership protocol- Returns:
- the cluster builder
- See Also:
HeartbeatMembershipProtocol,SwimMembershipProtocol
-
withMembershipProvider
Sets the cluster membership provider.The membership provider determines how peers are located and the cluster is bootstrapped.
- Parameters:
locationProvider- the membership provider- Returns:
- the cluster builder
- See Also:
BootstrapDiscoveryProvider,MulticastDiscoveryProvider
-
withTlsEnabled
Enables TLS for the Atomix messaging service.The messaging service is the service through which all Atomix protocols communicate with their peers. Enabling TLS for the messaging service enables TLS for all internal Atomix communication. When TLS is enabled, Atomix will look for an
atomix.jksfile in the/confdirectory unless a keystore/truststore is provided.- Returns:
- the cluster builder
- See Also:
withKeyStore(String),withTrustStore(String)
-
withTlsEnabled
Sets whether TLS is enabled for the Atomix messaging service.The messaging service is the service through which all Atomix protocols communicate with their peers. Enabling TLS for the messaging service enables TLS for all internal Atomix communication. When TLS is enabled, Atomix will look for an
atomix.jksfile in the/confdirectory unless a keystore/truststore is provided.- Returns:
- the cluster builder
- See Also:
withKeyStore(String),withTrustStore(String)
-
withKeyStore
Sets the key store to use for TLS in the Atomix messaging service.- Parameters:
keyStore- the key store path- Returns:
- the cluster builder
-
withKeyStorePassword
Sets the key store password for the Atomix messaging service.- Parameters:
keyStorePassword- the key store password- Returns:
- the cluster builder
-
withTrustStore
Sets the trust store to use for TLS in the Atomix messaging service.- Parameters:
trustStore- the trust store path- Returns:
- the cluster builder
-
withTrustStorePassword
Sets the trust store password for the Atomix messaging service.- Parameters:
trustStorePassword- the trust store password- Returns:
- the cluster builder
-
build
- Specified by:
buildin interfaceio.atomix.utils.Builder<AtomixCluster>
-