akka.cluster
Class Cluster

java.lang.Object
  extended by akka.cluster.Cluster
All Implemented Interfaces:
Extension

public class Cluster
extends java.lang.Object
implements Extension

This module is responsible for Gossiping cluster information. The abstraction maintains the list of live and dead members. Periodically i.e. every 1 second this module chooses a random member and initiates a round of Gossip with it.

During each round of gossip exchange it sends Gossip to random node with newer or older state information, if any, based on the current gossip overview, with some probability. Otherwise Gossip to any random live node.

Example:


  if (Cluster(system).isLeader) { ... }
 


Constructor Summary
Cluster(ExtendedActorSystem system)
           
 
Method Summary
 ActorRef clusterCore()
          INTERNAL API
static Cluster createExtension(ExtendedActorSystem system)
           
 void down(Address address)
          Send command to DOWN the node specified by 'address'.
 FailureDetector failureDetector()
           
static Cluster get(ActorSystem system)
           
 boolean isTerminated()
          Returns true if this cluster instance has be shutdown.
 void join(Address address)
          Try to join this cluster node with the node specified by 'address'.
 void leave(Address address)
          Send command to issue state transition to LEAVING for the node specified by 'address'.
static Cluster$ lookup()
           
 void publishCurrentClusterState()
          Publish current (full) state of the cluster to subscribers, that are subscribing to ClusterEvent.ClusterDomainEvent or ClusterEvent.CurrentClusterState.
 akka.cluster.ClusterReadView readView()
           
<T> void
registerOnMemberUp(scala.Function0<T> code)
          The supplied thunk will be run, once, when current cluster member is Up.
 void registerOnMemberUp(java.lang.Runnable callback)
          Java API: The supplied callback will be run, once, when current cluster member is Up.
 Scheduler scheduler()
          INTERNAL API
 Address selfAddress()
           
 void sendCurrentClusterState(ActorRef receiver)
          Publish current (full) state of the cluster to the specified receiver.
 ClusterSettings settings()
           
 void subscribe(ActorRef subscriber, java.lang.Class<?> to)
          Subscribe to cluster domain events.
 ExtendedActorSystem system()
           
 void unsubscribe(ActorRef subscriber)
          Unsubscribe to all cluster domain events.
 void unsubscribe(ActorRef subscriber, java.lang.Class<?> to)
          Unsubscribe to a specific type of cluster domain events, matching previous subscribe registration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Cluster

public Cluster(ExtendedActorSystem system)
Method Detail

get

public static Cluster get(ActorSystem system)

lookup

public static Cluster$ lookup()

createExtension

public static Cluster createExtension(ExtendedActorSystem system)

system

public ExtendedActorSystem system()

settings

public ClusterSettings settings()

selfAddress

public Address selfAddress()

failureDetector

public FailureDetector failureDetector()

scheduler

public Scheduler scheduler()
INTERNAL API


clusterCore

public ActorRef clusterCore()
INTERNAL API


readView

public akka.cluster.ClusterReadView readView()

isTerminated

public boolean isTerminated()
Returns true if this cluster instance has be shutdown.


subscribe

public void subscribe(ActorRef subscriber,
                      java.lang.Class<?> to)
Subscribe to cluster domain events. The to Class can be ClusterEvent.ClusterDomainEvent or subclass.

A snapshot of ClusterEvent.CurrentClusterState will be sent to the subscriber as the first event. When to Class is a ClusterEvent.InstantMemberEvent (or subclass) the snapshot event will instead be a ClusterEvent.InstantClusterState.


unsubscribe

public void unsubscribe(ActorRef subscriber)
Unsubscribe to all cluster domain events.


unsubscribe

public void unsubscribe(ActorRef subscriber,
                        java.lang.Class<?> to)
Unsubscribe to a specific type of cluster domain events, matching previous subscribe registration.


publishCurrentClusterState

public void publishCurrentClusterState()
Publish current (full) state of the cluster to subscribers, that are subscribing to ClusterEvent.ClusterDomainEvent or ClusterEvent.CurrentClusterState. If you want this to happen periodically you need to schedule a call to this method yourself.


sendCurrentClusterState

public void sendCurrentClusterState(ActorRef receiver)
Publish 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.


join

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


leave

public void leave(Address address)
Send command to issue state transition to LEAVING for the node specified by 'address'.


down

public void down(Address address)
Send command to DOWN the node specified by 'address'.


registerOnMemberUp

public <T> void registerOnMemberUp(scala.Function0<T> code)
The supplied thunk will be run, once, when current cluster member is Up. Typically used together with configuration option akka.cluster.min-nr-of-members' to defer some action, such as starting actors, until the cluster has reached a certain size.


registerOnMemberUp

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