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 and Description |
|---|
AtomixCluster(ClusterConfig config) |
AtomixCluster(File configFile) |
AtomixCluster(String configFile) |
| Modifier and Type | Method and Description |
|---|---|
static AtomixClusterBuilder |
builder()
Returns a new Atomix builder.
|
static AtomixClusterBuilder |
builder(ClassLoader classLoader)
Returns a new Atomix builder.
|
static AtomixClusterBuilder |
builder(ClusterConfig config)
Returns a new Atomix builder.
|
static AtomixClusterBuilder |
builder(String config)
Returns a new Atomix builder.
|
static AtomixClusterBuilder |
builder(String config,
ClassLoader classLoader)
Returns a new Atomix builder.
|
BroadcastService |
getBroadcastService()
Returns the cluster broadcast service.
|
ClusterCommunicationService |
getCommunicationService()
Returns the cluster communication service.
|
ClusterEventService |
getEventService()
Returns the cluster event service.
|
ClusterMembershipService |
getMembershipService()
Returns the cluster membership service.
|
MessagingService |
getMessagingService()
Returns the cluster messaging service.
|
boolean |
isRunning() |
CompletableFuture<Void> |
start() |
CompletableFuture<Void> |
stop() |
String |
toString() |
public AtomixCluster(String configFile)
public AtomixCluster(File configFile)
public AtomixCluster(ClusterConfig config)
public static AtomixClusterBuilder builder()
public static AtomixClusterBuilder builder(ClassLoader classLoader)
classLoader - the class loaderpublic static AtomixClusterBuilder builder(String config)
config - the Atomix configurationpublic static AtomixClusterBuilder builder(String config, ClassLoader classLoader)
config - the Atomix configurationclassLoader - the class loaderpublic static AtomixClusterBuilder builder(ClusterConfig config)
config - the Atomix configurationpublic BroadcastService getBroadcastService()
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.
getBroadcastService in interface BootstrapServicepublic MessagingService getMessagingService()
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 the
communication service or event service.
getMessagingService in interface BootstrapServicepublic ClusterMembershipService getMembershipService()
The membership service manages cluster membership information and failure detection.
public ClusterCommunicationService getCommunicationService()
The cluster communication service is used for high-level unicast, multicast, broadcast, and request-reply messaging.
public ClusterEventService getEventService()
The cluster event service is used for high-level publish-subscribe messaging.
public CompletableFuture<Void> start()
start in interface io.atomix.utils.Managed<Void>public boolean isRunning()
isRunning in interface io.atomix.utils.Managed<Void>public CompletableFuture<Void> stop()
stop in interface io.atomix.utils.Managed<Void>Copyright © 2013–2018. All rights reserved.