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).| Modifier and Type | Method and Description |
|---|---|
AtomixCluster |
build() |
AtomixClusterBuilder |
setBroadcastInterval(Duration interval)
Sets the reachability broadcast interval.
|
AtomixClusterBuilder |
setReachabilityThreshold(int threshold)
Sets the reachability failure detection threshold.
|
AtomixClusterBuilder |
withAddress(io.atomix.utils.net.Address address)
Sets the member address.
|
AtomixClusterBuilder |
withAddress(int port)
Sets the member address using local host.
|
AtomixClusterBuilder |
withAddress(String address)
Sets the member address.
|
AtomixClusterBuilder |
withAddress(String host,
int port)
Sets the member host/port.
|
AtomixClusterBuilder |
withClusterId(String clusterId)
Sets the cluster identifier.
|
AtomixClusterBuilder |
withHost(String host)
Sets the host to which the member belongs.
|
AtomixClusterBuilder |
withMemberId(MemberId localMemberId)
Sets the local member identifier.
|
AtomixClusterBuilder |
withMemberId(String localMemberId)
Sets the local member identifier.
|
AtomixClusterBuilder |
withMembershipProvider(NodeDiscoveryProvider locationProvider)
Sets the cluster membership provider.
|
AtomixClusterBuilder |
withMulticastAddress(io.atomix.utils.net.Address address)
Sets the multicast address.
|
AtomixClusterBuilder |
withMulticastEnabled()
Enables multicast communication.
|
AtomixClusterBuilder |
withMulticastEnabled(boolean multicastEnabled)
Sets whether multicast communication is enabled.
|
AtomixClusterBuilder |
withProperties(Properties properties)
Sets the member properties.
|
AtomixClusterBuilder |
withProperty(String key,
String value)
Sets a property of the member.
|
AtomixClusterBuilder |
withRack(String rack)
Sets the rack to which the member belongs.
|
AtomixClusterBuilder |
withReachabilityTimeout(Duration timeout)
Sets the reachability failure timeout.
|
AtomixClusterBuilder |
withZone(String zone)
Sets the zone to which the member belongs.
|
public AtomixClusterBuilder withClusterId(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(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 withAddress(String address)
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 tupleio.atomix.utils.net.MalformedAddressException - if a valid Address cannot be constructed from the argumentspublic AtomixClusterBuilder withAddress(String host, int port)
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 numberio.atomix.utils.net.MalformedAddressException - if a valid Address cannot be constructed from the argumentspublic AtomixClusterBuilder withAddress(int port)
The constructed AtomixCluster will bind to the given port for intra-cluster communication.
port - the port numberio.atomix.utils.net.MalformedAddressException - if a valid Address cannot be constructed from the argumentspublic AtomixClusterBuilder withAddress(io.atomix.utils.net.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 withZone(String zone)
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.
zone - the zone to which the member belongspublic AtomixClusterBuilder withRack(String rack)
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.
rack - the rack to which the member belongspublic AtomixClusterBuilder withHost(String host)
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.
host - the host to which the member belongspublic AtomixClusterBuilder withProperties(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 propertiesNullPointerException - if the properties are nullpublic AtomixClusterBuilder withProperty(String key, 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 setNullPointerException - if the property is nullpublic 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(io.atomix.utils.net.Address address)
Multicast is disabled by default. To enable multicast, first use withMulticastEnabled().
address - the multicast addresspublic AtomixClusterBuilder setBroadcastInterval(Duration interval)
The broadcast interval is the interval at which heartbeats are sent to peers in the cluster.
interval - the reachability broadcast intervalpublic 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 thresholdpublic AtomixClusterBuilder withReachabilityTimeout(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 withMembershipProvider(NodeDiscoveryProvider locationProvider)
The membership provider determines how peers are located and the cluster is bootstrapped.
locationProvider - the membership providerBootstrapDiscoveryProvider,
MulticastDiscoveryProviderpublic AtomixCluster build()
build in interface io.atomix.utils.Builder<AtomixCluster>Copyright © 2013–2018. All rights reserved.