Class AtomixCluster
- All Implemented Interfaces:
BootstrapService,io.atomix.utils.Managed<Void>
public class AtomixCluster extends Object implements BootstrapService, io.atomix.utils.Managed<Void>
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() 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). By default, the
MulticastDiscoveryProvider will be used if multicast is enabled,
otherwise the BootstrapDiscoveryProvider will be used if no provider is explicitly provided.
-
Constructor Summary
Constructors Constructor Description AtomixCluster(ClusterConfig config, io.atomix.utils.Version version)AtomixCluster(File configFile)AtomixCluster(String configFile) -
Method Summary
Modifier and Type Method Description static AtomixClusterBuilderbuilder()Returns a new Atomix builder.static AtomixClusterBuilderbuilder(ClusterConfig config)Returns a new Atomix builder.static AtomixClusterBuilderbuilder(ClassLoader classLoader)Returns a new Atomix builder.static AtomixClusterBuilderbuilder(String config)Returns a new Atomix builder.static AtomixClusterBuilderbuilder(String config, ClassLoader classLoader)Returns a new Atomix builder.BroadcastServicegetBroadcastService()Returns the cluster broadcast service.ClusterCommunicationServicegetCommunicationService()Returns the cluster communication service.ClusterEventServicegetEventService()Returns the cluster event service.ClusterMembershipServicegetMembershipService()Returns the cluster membership service.MessagingServicegetMessagingService()Returns the cluster messaging service.UnicastServicegetUnicastService()Returns the cluster unicast service.booleanisRunning()CompletableFuture<Void>start()CompletableFuture<Void>stop()StringtoString()
-
Constructor Details
-
Method Details
-
builder
Returns a new Atomix builder.- Returns:
- a new Atomix builder
-
builder
Returns a new Atomix builder.- Parameters:
classLoader- the class loader- Returns:
- a new Atomix builder
-
builder
Returns a new Atomix builder.- Parameters:
config- the Atomix configuration- Returns:
- a new Atomix builder
-
builder
Returns a new Atomix builder.- Parameters:
config- the Atomix configurationclassLoader- the class loader- Returns:
- a new Atomix builder
-
builder
Returns a new Atomix builder.- Parameters:
config- the Atomix configuration- Returns:
- a new Atomix builder
-
getUnicastService
Returns the cluster unicast service.The unicast service supports unreliable uni-directional messaging via UDP. This is a low-level cluster communication API. For higher level messaging, use the
communication serviceorevent service.- Specified by:
getUnicastServicein interfaceBootstrapService- Returns:
- the cluster unicast service
-
getBroadcastService
Returns the cluster broadcast service.The broadcast service is used to broadcast messages to all nodes in the cluster via multicast. The broadcast service is disabled by default. To enable broadcast, the cluster must be configured with
multicast enabled.- Specified by:
getBroadcastServicein interfaceBootstrapService- Returns:
- the cluster broadcast service
-
getMessagingService
Returns the cluster messaging service.The messaging service is used for direct point-to-point messaging between nodes by
Address. This is a low-level cluster communication API. For higher level messaging, use thecommunication serviceorevent service.- Specified by:
getMessagingServicein interfaceBootstrapService- Returns:
- the cluster messaging service
-
getMembershipService
Returns the cluster membership service.The membership service manages cluster membership information and failure detection.
- Returns:
- the cluster membership service
-
getCommunicationService
Returns the cluster communication service.The cluster communication service is used for high-level unicast, multicast, broadcast, and request-reply messaging.
- Returns:
- the cluster communication service
-
getEventService
Returns the cluster event service.The cluster event service is used for high-level publish-subscribe messaging.
- Returns:
- the cluster event service
-
start
- Specified by:
startin interfaceio.atomix.utils.Managed<Void>
-
isRunning
public boolean isRunning()- Specified by:
isRunningin interfaceio.atomix.utils.Managed<Void>
-
stop
- Specified by:
stopin interfaceio.atomix.utils.Managed<Void>
-
toString
-