public class AtomixClusterBuilder extends java.lang.Object implements 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).| Modifier and Type | Method and Description |
|---|---|
AtomixCluster |
build() |
AtomixClusterBuilder |
setBroadcastInterval(java.time.Duration interval)
Deprecated.
since 3.0.2
|
AtomixClusterBuilder |
setReachabilityThreshold(int threshold)
Deprecated.
since 3.0.2
|
AtomixClusterBuilder |
withAddress(Address address)
Sets the member address.
|
AtomixClusterBuilder |
withAddress(int port)
Deprecated.
since 3.1. Use
withPort(int) instead |
AtomixClusterBuilder |
withAddress(java.lang.String address)
Deprecated.
since 3.1. Use
withHost(String) and/or withPort(int) instead |
AtomixClusterBuilder |
withAddress(java.lang.String host,
int port)
Deprecated.
since 3.1. Use
withHost(String) and withPort(int) instead |
AtomixClusterBuilder |
withBroadcastInterval(java.time.Duration interval)
Deprecated.
|
AtomixClusterBuilder |
withClusterId(java.lang.String clusterId)
Sets the cluster identifier.
|
AtomixClusterBuilder |
withConnectionPoolSize(int connectionPoolSize)
Sets the messaging connection pool size.
|
AtomixClusterBuilder |
withHost(java.lang.String host)
Sets the member host.
|
AtomixClusterBuilder |
withHostId(java.lang.String hostId)
Sets the host to which the member belongs.
|
AtomixClusterBuilder |
withKeyStore(java.lang.String keyStore)
Sets the key store to use for TLS in the Atomix messaging service.
|
AtomixClusterBuilder |
withKeyStorePassword(java.lang.String keyStorePassword)
Sets the key store password for the Atomix messaging service.
|
AtomixClusterBuilder |
withMemberId(MemberId localMemberId)
Sets the local member identifier.
|
AtomixClusterBuilder |
withMemberId(java.lang.String localMemberId)
Sets the local member identifier.
|
AtomixClusterBuilder |
withMembershipProtocol(GroupMembershipProtocol protocol)
Sets the cluster membership protocol.
|
AtomixClusterBuilder |
withMembershipProvider(NodeDiscoveryProvider locationProvider)
Sets the cluster membership provider.
|
AtomixClusterBuilder |
withMessagingInterface(java.lang.String iface)
Sets the interface to which to bind the instance.
|
AtomixClusterBuilder |
withMessagingInterfaces(java.util.Collection<java.lang.String> ifaces)
Sets the interface(s) to which to bind the instance.
|
AtomixClusterBuilder |
withMessagingInterfaces(java.lang.String... ifaces)
Sets the interface(s) to which to bind the instance.
|
AtomixClusterBuilder |
withMessagingPort(int bindPort)
Sets the local port to which to bind the node.
|
AtomixClusterBuilder |
withMulticastAddress(Address address)
Sets the multicast address.
|
AtomixClusterBuilder |
withMulticastEnabled()
Enables multicast communication.
|
AtomixClusterBuilder |
withMulticastEnabled(boolean multicastEnabled)
Sets whether multicast communication is enabled.
|
AtomixClusterBuilder |
withPort(int port)
Sets the member port.
|
AtomixClusterBuilder |
withProperties(java.util.Properties properties)
Sets the member properties.
|
AtomixClusterBuilder |
withProperty(java.lang.String key,
java.lang.String value)
Sets a property of the member.
|
AtomixClusterBuilder |
withRack(java.lang.String rack)
Deprecated.
since 3.1. Use
withRackId(String) instead |
AtomixClusterBuilder |
withRackId(java.lang.String rackId)
Sets the rack to which the member belongs.
|
AtomixClusterBuilder |
withReachabilityThreshold(int threshold)
Deprecated.
|
AtomixClusterBuilder |
withReachabilityTimeout(java.time.Duration timeout)
Deprecated.
|
AtomixClusterBuilder |
withTlsEnabled()
Enables TLS for the Atomix messaging service.
|
AtomixClusterBuilder |
withTlsEnabled(boolean tlsEnabled)
Sets whether TLS is enabled for the Atomix messaging service.
|
AtomixClusterBuilder |
withTrustStore(java.lang.String trustStore)
Sets the trust store to use for TLS in the Atomix messaging service.
|
AtomixClusterBuilder |
withTrustStorePassword(java.lang.String trustStorePassword)
Sets the trust store password for the Atomix messaging service.
|
AtomixClusterBuilder |
withZone(java.lang.String zone)
Deprecated.
since 3.1. Use
withZoneId(String) instead |
AtomixClusterBuilder |
withZoneId(java.lang.String zoneId)
Sets the zone to which the member belongs.
|
public AtomixClusterBuilder withClusterId(java.lang.String clusterId)
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.
clusterId - the cluster identifierpublic AtomixClusterBuilder withMemberId(java.lang.String localMemberId)
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 UUID based identifier will be generated.
localMemberId - the local member identifierpublic AtomixClusterBuilder withMemberId(MemberId localMemberId)
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 UUID based identifier will be generated.
localMemberId - the local member identifierpublic AtomixClusterBuilder withHost(java.lang.String host)
host - the member hostpublic AtomixClusterBuilder withPort(int port)
port - the member port@Deprecated public AtomixClusterBuilder withAddress(java.lang.String address)
withHost(String) and/or withPort(int) instead
The constructed AtomixCluster will bind to the given address for intra-cluster communication. The format
of the address can be host:port or just host.
address - a host:port tupleMalformedAddressException - if a valid Address cannot be constructed from the arguments@Deprecated public AtomixClusterBuilder withAddress(java.lang.String host, int port)
withHost(String) and withPort(int) instead
The constructed AtomixCluster will bind to the given host/port for intra-cluster communication. The
provided host should be visible to other nodes in the cluster.
host - the host nameport - the port numberMalformedAddressException - if a valid Address cannot be constructed from the arguments@Deprecated public AtomixClusterBuilder withAddress(int port)
withPort(int) instead
The constructed AtomixCluster will bind to the given port for intra-cluster communication.
port - the port numberMalformedAddressException - if a valid Address cannot be constructed from the argumentspublic AtomixClusterBuilder withAddress(Address address)
The constructed AtomixCluster will bind to the given address for intra-cluster communication. The
provided address should be visible to other nodes in the cluster.
address - the member addresspublic AtomixClusterBuilder withZoneId(java.lang.String zoneId)
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.
zoneId - the zone to which the member belongs@Deprecated public AtomixClusterBuilder withZone(java.lang.String zone)
withZoneId(String) insteadThe 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.
zone - the zone to which the member belongspublic AtomixClusterBuilder withRackId(java.lang.String rackId)
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.
rackId - the rack to which the member belongs@Deprecated public AtomixClusterBuilder withRack(java.lang.String rack)
withRackId(String) insteadThe 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.
rack - the rack to which the member belongspublic AtomixClusterBuilder withHostId(java.lang.String hostId)
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.
hostId - the host to which the member belongspublic AtomixClusterBuilder withProperties(java.util.Properties 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.
properties - the member propertiesjava.lang.NullPointerException - if the properties are nullpublic AtomixClusterBuilder withProperty(java.lang.String key, java.lang.String value)
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.
key - the property key to setvalue - the property value to setjava.lang.NullPointerException - if the property is nullpublic AtomixClusterBuilder withMessagingInterface(java.lang.String iface)
iface - the interface to which to bind the instancepublic AtomixClusterBuilder withMessagingInterfaces(java.lang.String... ifaces)
ifaces - the interface(s) to which to bind the instancepublic AtomixClusterBuilder withMessagingInterfaces(java.util.Collection<java.lang.String> ifaces)
ifaces - the interface(s) to which to bind the instancepublic AtomixClusterBuilder withMessagingPort(int bindPort)
bindPort - the local port to which to bind the nodepublic AtomixClusterBuilder withConnectionPoolSize(int connectionPoolSize)
The node will create connectionPoolSize connections 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.
connectionPoolSize - the connection pool sizepublic AtomixClusterBuilder withMulticastEnabled()
Multicast is disabled by default. This method must be called to enable it. Enabling multicast enables the
use of the BroadcastService.
withMulticastAddress(Address)public AtomixClusterBuilder withMulticastEnabled(boolean multicastEnabled)
Multicast is disabled by default. This method must be called to enable it. Enabling multicast enables the
use of the BroadcastService.
multicastEnabled - whether to enable multicastwithMulticastAddress(Address)public AtomixClusterBuilder withMulticastAddress(Address address)
Multicast is disabled by default. To enable multicast, first use withMulticastEnabled().
address - the multicast address@Deprecated public AtomixClusterBuilder setBroadcastInterval(java.time.Duration interval)
The broadcast interval is the interval at which heartbeats are sent to peers in the cluster.
interval - the reachability broadcast interval@Deprecated public AtomixClusterBuilder withBroadcastInterval(java.time.Duration interval)
The broadcast interval is the interval at which heartbeats are sent to peers in the cluster.
interval - the reachability broadcast interval@Deprecated public AtomixClusterBuilder setReachabilityThreshold(int 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.
threshold - the reachability failure detection threshold@Deprecated public AtomixClusterBuilder withReachabilityThreshold(int 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.
threshold - the reachability failure detection threshold@Deprecated public AtomixClusterBuilder withReachabilityTimeout(java.time.Duration timeout)
The reachability timeout determines the maximum time after which a member will be marked unreachable if heartbeats have failed.
timeout - the reachability failure timeoutpublic AtomixClusterBuilder withMembershipProtocol(GroupMembershipProtocol 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.
protocol - the cluster membership protocolHeartbeatMembershipProtocol,
SwimMembershipProtocolpublic AtomixClusterBuilder withMembershipProvider(NodeDiscoveryProvider locationProvider)
The membership provider determines how peers are located and the cluster is bootstrapped.
locationProvider - the membership providerBootstrapDiscoveryProvider,
MulticastDiscoveryProviderpublic AtomixClusterBuilder withTlsEnabled()
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.jks file in the /conf directory unless
a keystore/truststore is provided.
withKeyStore(String),
withTrustStore(String)public AtomixClusterBuilder withTlsEnabled(boolean tlsEnabled)
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.jks file in the /conf directory unless
a keystore/truststore is provided.
withKeyStore(String),
withTrustStore(String)public AtomixClusterBuilder withKeyStore(java.lang.String keyStore)
keyStore - the key store pathpublic AtomixClusterBuilder withKeyStorePassword(java.lang.String keyStorePassword)
keyStorePassword - the key store passwordpublic AtomixClusterBuilder withTrustStore(java.lang.String trustStore)
trustStore - the trust store pathpublic AtomixClusterBuilder withTrustStorePassword(java.lang.String trustStorePassword)
trustStorePassword - the trust store passwordpublic AtomixCluster build()
build in interface Builder<AtomixCluster>Copyright © 2013-2018. All Rights Reserved.