Class AtomixCluster

java.lang.Object
io.atomix.cluster.AtomixCluster
All Implemented Interfaces:
BootstrapService, Managed<Void>, AutoCloseable

public class AtomixCluster extends Object implements BootstrapService, Managed<Void>
Atomix cluster manager.

The cluster manager is the basis for all cluster management and communication in an Atomix cluster. This class is responsible for bootstrapping new clusters or joining existing ones, establishing communication between nodes, and detecting failures.

The Atomix cluster can be run as a standalone instance for cluster management and communication. To build a cluster instance, use builder(MeterRegistry) to create a new builder.


 AtomixCluster cluster = AtomixCluster.builder()
   .withClusterName("my-cluster")
   .withMemberId("member-1")
   .withAddress("localhost:1234")
   .withMulticastEnabled()
   .build();

 
The instance can be configured with a unique identifier via AtomixClusterBuilder.withMemberId(String). The member ID can be used to lookup the member in the ClusterMembershipService or send messages to this node from other member nodes. The address is the host and port to which the node will bind for intra-cluster communication over TCP.

Once an instance has been configured, the start() method must be called to bootstrap the instance. The start() method returns a CompletableFuture which will be completed once all the services have been bootstrapped.


 cluster.start().join();

 

Cluster membership is determined by a configurable NodeDiscoveryProvider. To configure the membership provider use AtomixClusterBuilder.withMembershipProvider(NodeDiscoveryProvider). The BootstrapDiscoveryProvider will be used if no provider is explicitly provided.