Cluster

org.apache.pekko.cluster.Cluster
See theCluster companion object
class Cluster(val system: ExtendedActorSystem) extends Extension

This module is responsible cluster membership information. Changes to the cluster information is retrieved through subscribe. Commands to operate the cluster is available through methods in this class, such as join, down and leave.

Each cluster Member is identified by its pekko.actor.Address, and the cluster address of this actor system is selfAddress. A member also has a status; initially MemberStatus Joining followed by MemberStatus Up.

Attributes

Companion
object
Source
Cluster.scala
Graph
Supertypes
trait Extension
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def down(address: Address): Unit

Send command to DOWN the node specified by 'address'.

Send command to DOWN the node specified by 'address'.

When a member is considered by the failure detector to be unreachable the leader is not allowed to perform its duties, such as changing status of new joining members to 'Up'. The status of the unreachable member must be changed to 'Down', which can be done with this method.

Attributes

Source
Cluster.scala
def getSelfRoles: Set[String]

Java API: roles that this member has

Java API: roles that this member has

Attributes

Source
Cluster.scala

Returns true if this cluster instance has be shutdown.

Returns true if this cluster instance has be shutdown.

Attributes

Source
Cluster.scala
def join(address: Address): Unit

Try to join this cluster node with the node specified by 'address'. A 'Join(selfAddress)' command is sent to the node to join.

Try to join this cluster node with the node specified by 'address'. A 'Join(selfAddress)' command is sent to the node to join.

An actor system can only join a cluster once. Additional attempts will be ignored. When it has successfully joined it must be restarted to be able to join another cluster or to join the same cluster again.

The name of the pekko.actor.ActorSystem must be the same for all members of a cluster.

Attributes

Source
Cluster.scala
def joinSeedNodes(seedNodes: Seq[Address]): Unit

Join the specified seed nodes without defining them in config. Especially useful from tests when Addresses are unknown before startup time.

Join the specified seed nodes without defining them in config. Especially useful from tests when Addresses are unknown before startup time.

An actor system can only join a cluster once. Additional attempts will be ignored. When it has successfully joined it must be restarted to be able to join another cluster or to join the same cluster again.

Attributes

Source
Cluster.scala
def joinSeedNodes(seedNodes: List[Address]): Unit

Java API

Java API

Join the specified seed nodes without defining them in config. Especially useful from tests when Addresses are unknown before startup time.

An actor system can only join a cluster once. Additional attempts will be ignored. When it has successfully joined it must be restarted to be able to join another cluster or to join the same cluster again.

Attributes

Source
Cluster.scala
def leave(address: Address): Unit

Send command to issue state transition to LEAVING for the node specified by 'address'. The member will go through the status changes MemberStatus Leaving (not published to subscribers) followed by MemberStatus Exiting and finally MemberStatus Removed.

Send command to issue state transition to LEAVING for the node specified by 'address'. The member will go through the status changes MemberStatus Leaving (not published to subscribers) followed by MemberStatus Exiting and finally MemberStatus Removed.

Note that this command can be issued to any member in the cluster, not necessarily the one that is leaving. The cluster extension, but not the actor system or JVM, of the leaving member will be shutdown after the leader has changed status of the member to Exiting. Thereafter the member will be removed from the cluster. Normally this is handled automatically, but in case of network failures during this process it might still be necessary to set the node’s status to Down in order to complete the removal.

Attributes

Source
Cluster.scala

Change the state of every member in preparation for a full cluster shutdown.

Change the state of every member in preparation for a full cluster shutdown.

Attributes

Source
Cluster.scala
def registerOnMemberRemoved[T](code: => T): Unit

The supplied thunk will be run, once, when current cluster member is Removed. If the cluster has already been shutdown the thunk will run on the caller thread immediately. If this is called "at the same time" as shutdown() there is a possibility that the the thunk is not invoked. It's often better to use pekko.actor.CoordinatedShutdown for this purpose.

The supplied thunk will be run, once, when current cluster member is Removed. If the cluster has already been shutdown the thunk will run on the caller thread immediately. If this is called "at the same time" as shutdown() there is a possibility that the the thunk is not invoked. It's often better to use pekko.actor.CoordinatedShutdown for this purpose.

Attributes

Source
Cluster.scala
def registerOnMemberRemoved(callback: Runnable): Unit

Java API: The supplied thunk will be run, once, when current cluster member is Removed. If the cluster has already been shutdown the thunk will run on the caller thread immediately. If this is called "at the same time" as shutdown() there is a possibility that the the thunk is not invoked. It's often better to use pekko.actor.CoordinatedShutdown for this purpose.

Java API: The supplied thunk will be run, once, when current cluster member is Removed. If the cluster has already been shutdown the thunk will run on the caller thread immediately. If this is called "at the same time" as shutdown() there is a possibility that the the thunk is not invoked. It's often better to use pekko.actor.CoordinatedShutdown for this purpose.

Attributes

Source
Cluster.scala
def registerOnMemberUp[T](code: => T): Unit

The supplied thunk will be run, once, when current cluster member is Up. Typically used together with configuration option pekko.cluster.min-nr-of-members to defer some action, such as starting actors, until the cluster has reached a certain size.

The supplied thunk will be run, once, when current cluster member is Up. Typically used together with configuration option pekko.cluster.min-nr-of-members to defer some action, such as starting actors, until the cluster has reached a certain size.

Attributes

Source
Cluster.scala
def registerOnMemberUp(callback: Runnable): Unit

Java API: The supplied callback will be run, once, when current cluster member is Up. Typically used together with configuration option pekko.cluster.min-nr-of-members to defer some action, such as starting actors, until the cluster has reached a certain size.

Java API: The supplied callback will be run, once, when current cluster member is Up. Typically used together with configuration option pekko.cluster.min-nr-of-members to defer some action, such as starting actors, until the cluster has reached a certain size.

Attributes

Source
Cluster.scala
def remotePathOf(actorRef: ActorRef): ActorPath

Generate the remote actor path by replacing the Address in the RootActor Path for the given ActorRef with the cluster's selfAddress, unless address' host is already defined

Generate the remote actor path by replacing the Address in the RootActor Path for the given ActorRef with the cluster's selfAddress, unless address' host is already defined

Attributes

Source
Cluster.scala

The address of this cluster member.

The address of this cluster member.

Attributes

Source
Cluster.scala

Data center to which this node belongs to (defaults to "default" if not configured explicitly)

Data center to which this node belongs to (defaults to "default" if not configured explicitly)

Attributes

Source
Cluster.scala

Current snapshot of the member itself

Current snapshot of the member itself

Attributes

Source
Cluster.scala

roles that this member has

roles that this member has

Attributes

Source
Cluster.scala

Send current (full) state of the cluster to the specified receiver. If you want this to happen periodically you need to schedule a call to this method yourself. Note that you can also retrieve the current state with state.

Send current (full) state of the cluster to the specified receiver. If you want this to happen periodically you need to schedule a call to this method yourself. Note that you can also retrieve the current state with state.

Attributes

Source
Cluster.scala

Current snapshot state of the cluster.

Current snapshot state of the cluster.

Attributes

Source
Cluster.scala
def subscribe(subscriber: ActorRef, to: Class[_]*): Unit

Subscribe to one or more cluster domain events. The to classes can be pekko.cluster.ClusterEvent.ClusterDomainEvent or subclasses.

Subscribe to one or more cluster domain events. The to classes can be pekko.cluster.ClusterEvent.ClusterDomainEvent or subclasses.

A snapshot of pekko.cluster.ClusterEvent.CurrentClusterState will be sent to the subscriber as the first message.

Attributes

Source
Cluster.scala
def subscribe(subscriber: ActorRef, initialStateMode: SubscriptionInitialStateMode, to: Class[_]*): Unit

Subscribe to one or more cluster domain events. The to classes can be pekko.cluster.ClusterEvent.ClusterDomainEvent or subclasses.

Subscribe to one or more cluster domain events. The to classes can be pekko.cluster.ClusterEvent.ClusterDomainEvent or subclasses.

If initialStateMode is ClusterEvent.InitialStateAsEvents the events corresponding to the current state will be sent to the subscriber to mimic what you would have seen if you were listening to the events when they occurred in the past.

If initialStateMode is ClusterEvent.InitialStateAsSnapshot a snapshot of pekko.cluster.ClusterEvent.CurrentClusterState will be sent to the subscriber as the first message.

Note that for large clusters it is more efficient to use InitialStateAsSnapshot.

Attributes

Source
Cluster.scala
def unsubscribe(subscriber: ActorRef): Unit

Unsubscribe to all cluster domain events.

Unsubscribe to all cluster domain events.

Attributes

Source
Cluster.scala
def unsubscribe(subscriber: ActorRef, to: Class[_]): Unit

Unsubscribe to a specific type of cluster domain events, matching previous subscribe registration.

Unsubscribe to a specific type of cluster domain events, matching previous subscribe registration.

Attributes

Source
Cluster.scala

Concrete fields

Attributes

Source
Cluster.scala

The address including a uid of this cluster member. The uid is needed to be able to distinguish different incarnations of a member with same hostname and port.

The address including a uid of this cluster member. The uid is needed to be able to distinguish different incarnations of a member with same hostname and port.

Attributes

Source
Cluster.scala

Attributes

Source
Cluster.scala

Attributes

Source
Cluster.scala