Class AtomixCluster
- All Implemented Interfaces:
BootstrapService,Managed<Void>,AutoCloseable
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). The BootstrapDiscoveryProvider will be used if no provider is explicitly provided.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CompletableFuture<Void> protected final ManagedClusterCommunicationServiceprotected final NodeDiscoveryProviderprotected final ManagedClusterEventServiceprotected final GroupMembershipProtocolprotected final ManagedClusterMembershipServiceprotected final ManagedMessagingServiceprotected CompletableFuture<Void> protected final ThreadContextprotected final ManagedUnicastService -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAtomixCluster(ClusterConfig config, Version version, ManagedMessagingService messagingService, ManagedUnicastService unicastService, String actorSchedulerName) AtomixCluster(ClusterConfig config, Version version, String actorSchedulerName) -
Method Summary
Modifier and TypeMethodDescriptionprotected static ManagedClusterEventServicebuildClusterEventService(ClusterMembershipService membershipService, MessagingService messagingService) Builds a cluster event service.protected static ManagedClusterMembershipServicebuildClusterMembershipService(ClusterConfig config, BootstrapService bootstrapService, NodeDiscoveryProvider discoveryProvider, GroupMembershipProtocol membershipProtocol, Version version) Builds a cluster service.protected static ManagedClusterCommunicationServicebuildClusterMessagingService(ClusterMembershipService membershipService, MessagingService messagingService, UnicastService unicastService) Builds a cluster messaging service.static AtomixClusterBuilderbuilder()Returns a new Atomix builder.static AtomixClusterBuilderbuilder(ClusterConfig config) Returns a new Atomix builder.protected static NodeDiscoveryProviderbuildLocationProvider(ClusterConfig config) Builds a member location provider.protected static GroupMembershipProtocolbuildMembershipProtocol(ClusterConfig config, String actorSchedulerName) Builds the group membership protocol.protected static ManagedMessagingServicebuildMessagingService(ClusterConfig config, String actorSchedulerName) Builds a default messaging service.protected static ManagedUnicastServicebuildUnicastService(ClusterConfig config, String actorSchedulerName) Builds a default unicast service.protected CompletableFuture<Void> protected CompletableFuture<Void> Returns the cluster communication service.Returns the cluster event service.Returns the cluster membership service.Returns the cluster messaging service.Returns the cluster unicast service.booleanstart()protected CompletableFuture<Void> stop()protected CompletableFuture<Void> toString()
-
Field Details
-
messagingService
-
unicastService
-
discoveryProvider
-
membershipProtocol
-
membershipService
-
communicationService
-
eventService
-
openFuture
-
closeFuture
-
threadContext
-
-
Constructor Details
-
AtomixCluster
-
AtomixCluster
protected AtomixCluster(ClusterConfig config, Version version, ManagedMessagingService messagingService, ManagedUnicastService unicastService, String actorSchedulerName)
-
-
Method Details
-
builder
Returns a new Atomix builder.- Returns:
- a new Atomix builder
-
builder
Returns a new Atomix builder.- Parameters:
config- the Atomix configuration- Returns:
- a new Atomix builder
-
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
-
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
-
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, 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
-
isRunning
public boolean isRunning() -
stop
-
startServices
-
completeStartup
-
stopServices
-
completeShutdown
-
toString
-
buildMessagingService
protected static ManagedMessagingService buildMessagingService(ClusterConfig config, String actorSchedulerName) Builds a default messaging service. -
buildUnicastService
protected static ManagedUnicastService buildUnicastService(ClusterConfig config, String actorSchedulerName) Builds a default unicast service. -
buildLocationProvider
Builds a member location provider. -
buildMembershipProtocol
protected static GroupMembershipProtocol buildMembershipProtocol(ClusterConfig config, String actorSchedulerName) Builds the group membership protocol. -
buildClusterMembershipService
protected static ManagedClusterMembershipService buildClusterMembershipService(ClusterConfig config, BootstrapService bootstrapService, NodeDiscoveryProvider discoveryProvider, GroupMembershipProtocol membershipProtocol, Version version) Builds a cluster service. -
buildClusterMessagingService
protected static ManagedClusterCommunicationService buildClusterMessagingService(ClusterMembershipService membershipService, MessagingService messagingService, UnicastService unicastService) Builds a cluster messaging service. -
buildClusterEventService
protected static ManagedClusterEventService buildClusterEventService(ClusterMembershipService membershipService, MessagingService messagingService) Builds a cluster event service.
-