akka.cluster
Class ClusterMetricsCollector

java.lang.Object
  extended by akka.cluster.ClusterMetricsCollector
All Implemented Interfaces:
Actor, ActorLogging

public class ClusterMetricsCollector
extends java.lang.Object
implements Actor, ActorLogging

INTERNAL API.

Cluster metrics is primarily for load-balancing of nodes. It controls metrics sampling at a regular frequency, prepares highly variable data for further analysis by other entities, and publishes the latest cluster metrics data around the node ring and local eventStream to assist in determining the need to redirect traffic to the least-loaded nodes.

Metrics sampling is delegated to the MetricsCollector.

Smoothing of the data for each monitored process is delegated to the EWMA for exponential weighted moving average.


Nested Class Summary
 
Nested classes/interfaces inherited from interface akka.actor.Actor
Actor.emptyBehavior$
 
Constructor Summary
ClusterMetricsCollector(ActorRef publisher)
           
 
Method Summary
 void addMember(Member member)
          Adds a member to the node ring.
 Cluster cluster()
           
 void collect()
          Samples the latest metrics for the node, updates metrics statistics in MetricsGossip, and publishes the change to the event bus.
 MetricsCollector collector()
          The metrics collector that samples data on the node.
 void gossip()
          Gossip to peer nodes.
 Cancellable gossipTask()
          Start periodic gossip to random nodes in cluster
 void gossipTo(Address address)
           
 MetricsGossip latestGossip()
          The latest metric values with their statistical data.
 Cancellable metricsTask()
          Start periodic metrics collection
 scala.collection.immutable.SortedSet<Address> nodes()
          The node ring gossipped that contains only members that are Up.
 void postStop()
          User overridable callback.
 void preStart()
          User overridable callback.
 void publish()
          Publishes to the event stream.
 scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive()
          This defines the initial actor behavior, it must return a partial function with the actor logic.
 void receiveGossip(MetricsGossipEnvelope envelope)
          Receives changes from peer nodes, merges remote with local gossip nodes, then publishes changes to the event stream for load balancing router consumption, and gossip back.
 void receiveState(ClusterEvent.CurrentClusterState state)
          Updates the initial node ring for those nodes that are akka.cluster.MemberStatus.Up.
 void removeMember(Member member)
          Removes a member from the member node ring.
 void replyGossipTo(Address address)
           
 scala.Option<Address> selectRandomNode(scala.collection.immutable.IndexedSeq<Address> addresses)
           
 void sendGossip(Address address, MetricsGossipEnvelope envelope)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface akka.actor.Actor
aroundPostRestart, aroundPostStop, aroundPreRestart, aroundPreStart, aroundReceive, context, postRestart, preRestart, self, sender, supervisorStrategy, unhandled
 
Methods inherited from interface akka.actor.ActorLogging
_log, log
 

Constructor Detail

ClusterMetricsCollector

public ClusterMetricsCollector(ActorRef publisher)
Method Detail

cluster

public Cluster cluster()

nodes

public scala.collection.immutable.SortedSet<Address> nodes()
The node ring gossipped that contains only members that are Up.

Returns:
(undocumented)

latestGossip

public MetricsGossip latestGossip()
The latest metric values with their statistical data.

Returns:
(undocumented)

collector

public MetricsCollector collector()
The metrics collector that samples data on the node.

Returns:
(undocumented)

gossipTask

public Cancellable gossipTask()
Start periodic gossip to random nodes in cluster

Returns:
(undocumented)

metricsTask

public Cancellable metricsTask()
Start periodic metrics collection

Returns:
(undocumented)

preStart

public void preStart()
Description copied from interface: Actor
User overridable callback.

Is called when an Actor is started. Actors are automatically started asynchronously when created. Empty default implementation.

Specified by:
preStart in interface Actor

receive

public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive()
Description copied from interface: Actor
This defines the initial actor behavior, it must return a partial function with the actor logic.

Specified by:
receive in interface Actor
Returns:
(undocumented)

postStop

public void postStop()
Description copied from interface: Actor
User overridable callback.

Is called asynchronously after 'actor.stop()' is invoked. Empty default implementation.

Specified by:
postStop in interface Actor

addMember

public void addMember(Member member)
Adds a member to the node ring.

Parameters:
member - (undocumented)

removeMember

public void removeMember(Member member)
Removes a member from the member node ring.

Parameters:
member - (undocumented)

receiveState

public void receiveState(ClusterEvent.CurrentClusterState state)
Updates the initial node ring for those nodes that are akka.cluster.MemberStatus.Up.

Parameters:
state - (undocumented)

collect

public void collect()
Samples the latest metrics for the node, updates metrics statistics in MetricsGossip, and publishes the change to the event bus.

See Also:
akka.cluster.ClusterMetricsCollector.collect( )

receiveGossip

public void receiveGossip(MetricsGossipEnvelope envelope)
Receives changes from peer nodes, merges remote with local gossip nodes, then publishes changes to the event stream for load balancing router consumption, and gossip back.

Parameters:
envelope - (undocumented)

gossip

public void gossip()
Gossip to peer nodes.


gossipTo

public void gossipTo(Address address)

replyGossipTo

public void replyGossipTo(Address address)

sendGossip

public void sendGossip(Address address,
                       MetricsGossipEnvelope envelope)

selectRandomNode

public scala.Option<Address> selectRandomNode(scala.collection.immutable.IndexedSeq<Address> addresses)

publish

public void publish()
Publishes to the event stream.