public class ClusterMetricsCollector extends java.lang.Object implements Actor, ActorLogging
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.
Actor.emptyBehavior$, Actor.ignoringBehavior$
Constructor and Description |
---|
ClusterMetricsCollector(ActorRef publisher) |
Modifier and Type | Method and Description |
---|---|
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.
|
ActorContext |
context()
Stores the context for this actor, including self, and sender.
|
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
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) |
ActorRef |
self()
The 'self' field holds the ActorRef for this actor.
|
void |
sendGossip(Address address,
MetricsGossipEnvelope envelope) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
aroundPostRestart, aroundPostStop, aroundPreRestart, aroundPreStart, aroundReceive, postRestart, preRestart, sender, supervisorStrategy, unhandled
log
public ClusterMetricsCollector(ActorRef publisher)
public ActorContext context()
Actor
forward
.
WARNING: Only valid within the Actor itself, so do not close over it and publish it to other threads!
ActorContext
is the Scala API. getContext
returns a
UntypedActorContext
, which is the Java API of the actor
context.
public final ActorRef self()
Actor
self ! message
public Cluster cluster()
public scala.collection.immutable.SortedSet<Address> nodes()
public MetricsGossip latestGossip()
public MetricsCollector collector()
public Cancellable gossipTask()
public Cancellable metricsTask()
public void preStart()
Actor
public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive()
Actor
public void postStop()
Actor
public void addMember(Member member)
member
- (undocumented)public void removeMember(Member member)
member
- (undocumented)public void receiveState(ClusterEvent.CurrentClusterState state)
MemberStatus
Up
.state
- (undocumented)public void collect()
MetricsGossip
, and publishes the change to the event bus.
collect()
public void receiveGossip(MetricsGossipEnvelope envelope)
envelope
- (undocumented)public void gossip()
public void gossipTo(Address address)
public void replyGossipTo(Address address)
public void sendGossip(Address address, MetricsGossipEnvelope envelope)
public scala.Option<Address> selectRandomNode(scala.collection.immutable.IndexedSeq<Address> addresses)
public void publish()