class Cluster 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 akka.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
.
- Source
- Cluster.scala
- Alphabetic
- By Inheritance
- Cluster
- Extension
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new Cluster(system: ExtendedActorSystem)
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- def +(other: String): String
- def ->[B](y: B): (Cluster, B)
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @HotSpotIntrinsicCandidate() @native()
- val crossDcFailureDetector: FailureDetectorRegistry[Address]
- 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.
- lazy val downingProvider: DowningProvider
- def ensuring(cond: (Cluster) => Boolean, msg: => Any): Cluster
- def ensuring(cond: (Cluster) => Boolean): Cluster
- def ensuring(cond: Boolean, msg: => Any): Cluster
- def ensuring(cond: Boolean): Cluster
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- val failureDetector: FailureDetectorRegistry[Address]
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- def getSelfRoles: Set[String]
Java API: roles that this member has
Java API: roles that this member has
- Annotations
- @nowarn()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isTerminated: Boolean
Returns true if this cluster instance has be shutdown.
- def join(address: Address): Unit
Try to join this cluster node with the node specified by 'address'.
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 akka.actor.ActorSystem must be the same for all members of a cluster.
- 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.
- def joinSeedNodes(seedNodes: Seq[Address]): Unit
Join the specified seed nodes without defining them in config.
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.
- def leave(address: Address): Unit
Send command to issue state transition to LEAVING for the node specified by 'address'.
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 MemberStatusExiting
and finally MemberStatusRemoved
.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.
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- def prepareForFullClusterShutdown(): Unit
Change the state of every member in preparation for a full cluster shutdown.
- def registerOnMemberRemoved(callback: Runnable): Unit
Java API: The supplied thunk will be run, once, when current cluster member is
Removed
.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" asshutdown()
there is a possibility that the the thunk is not invoked. It's often better to use akka.actor.CoordinatedShutdown for this purpose. - def registerOnMemberRemoved[T](code: => T): Unit
The supplied thunk will be run, once, when current cluster member is
Removed
.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" asshutdown()
there is a possibility that the the thunk is not invoked. It's often better to use akka.actor.CoordinatedShutdown for this purpose. - def registerOnMemberUp(callback: Runnable): Unit
Java API: The supplied callback will be run, once, when current cluster member is
Up
.Java API: The supplied callback will be run, once, when current cluster member is
Up
. Typically used together with configuration optionakka.cluster.min-nr-of-members
to defer some action, such as starting actors, until the cluster has reached a certain size. - def registerOnMemberUp[T](code: => T): Unit
The supplied thunk will be run, once, when current cluster member is
Up
.The supplied thunk will be run, once, when current cluster member is
Up
. Typically used together with configuration optionakka.cluster.min-nr-of-members
to defer some action, such as starting actors, until the cluster has reached a certain size. - 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 - def selfAddress: Address
The address of this cluster member.
- def selfDataCenter: DataCenter
Data center to which this node belongs to (defaults to "default" if not configured explicitly)
- def selfMember: Member
Current snapshot of the member itself
- def selfRoles: Set[String]
roles that this member has
- val selfUniqueAddress: UniqueAddress
The address including a
uid
of this cluster member.The address including a
uid
of this cluster member. Theuid
is needed to be able to distinguish different incarnations of a member with same hostname and port. - def sendCurrentClusterState(receiver: ActorRef): Unit
Send current (full) state of the cluster to the specified receiver.
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.
- def setAppVersionLater(appVersion: CompletionStage[util.Version]): Unit
Java API: If the
appVersion
is read from an external system (e.g.Java API: If the
appVersion
is read from an external system (e.g. Kubernetes) it can be defined after system startup but before joining by completing theappVersion
CompletionStage
. In that case,setAppVersionLater
should be called before callingjoin
orjoinSeedNodes
. It's fine to calljoin
orjoinSeedNodes
immediately afterwards (before theCompletionStage
is completed. The join will then wait for theappVersion
to be completed. - def setAppVersionLater(appVersion: Future[util.Version]): Unit
Scala API: If the
appVersion
is read from an external system (e.g.Scala API: If the
appVersion
is read from an external system (e.g. Kubernetes) it can be defined after system startup but before joining by completing theappVersion
Future
. In that case,setAppVersionLater
should be called before callingjoin
orjoinSeedNodes
. It's fine to calljoin
orjoinSeedNodes
immediately afterwards (before theFuture
is completed. The join will then wait for theappVersion
to be completed. - val settings: ClusterSettings
- def state: CurrentClusterState
Current snapshot state of the cluster.
- def subscribe(subscriber: ActorRef, initialStateMode: SubscriptionInitialStateMode, to: Class[_]*): Unit
Subscribe to one or more cluster domain events.
Subscribe to one or more cluster domain events. The
to
classes can be akka.cluster.ClusterEvent.ClusterDomainEvent or subclasses.If
initialStateMode
isClusterEvent.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
isClusterEvent.InitialStateAsSnapshot
a snapshot of akka.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
.- Annotations
- @varargs()
- def subscribe(subscriber: ActorRef, to: Class[_]*): Unit
Subscribe to one or more cluster domain events.
Subscribe to one or more cluster domain events. The
to
classes can be akka.cluster.ClusterEvent.ClusterDomainEvent or subclasses.A snapshot of akka.cluster.ClusterEvent.CurrentClusterState will be sent to the subscriber as the first message.
- Annotations
- @varargs()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- val system: ExtendedActorSystem
- def toString(): String
- Definition Classes
- AnyRef → Any
- def unsubscribe(subscriber: ActorRef, to: Class[_]): Unit
Unsubscribe to a specific type of cluster domain events, matching previous
subscribe
registration. - def unsubscribe(subscriber: ActorRef): Unit
Unsubscribe to all cluster domain events.
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
(Since version 9)
- def formatted(fmtstr: String): String
- Implicit
- This member is added by an implicit conversion from Cluster toStringFormat[Cluster] performed by method StringFormat in scala.Predef.
- Definition Classes
- StringFormat
- Annotations
- @deprecated @inline()
- Deprecated
(Since version 2.12.16) Use
formatString.format(value)
instead ofvalue.formatted(formatString)
, or use thef""
string interpolator. In Java 15 and later,formatted
resolves to the new method in String which has reversed parameters.
- def →[B](y: B): (Cluster, B)
- Implicit
- This member is added by an implicit conversion from Cluster toArrowAssoc[Cluster] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @deprecated
- Deprecated
(Since version 2.13.0) Use
->
instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.