예제 #1
0
 private void Start()
 {
     this.Stash.UnstashAll();
     this.Receive <ClusterMetricsChanged>(clusterMetrics => this.lastClusterMetrics = clusterMetrics);
     this.Receive <StartMetricsUpdate>(_ => this.Become(this.MetricsQueryObjectShardRegion));
     this.Receive <RequestStateCommand>(_ => this.RespondState(_.ReplyTo));
     Context.System.Scheduler.ScheduleTellOnce(this.interval, this.Self, new StartMetricsUpdate(), this.Self);
     this.LogClusterMetrics();
 }
예제 #2
0
        public void MetricsChanged(ClusterMetricsChanged @event)
        {
            var oldValue        = _weightedRouteesRef.Value;
            var routees         = oldValue.Item1;
            var weightedRoutees = new WeightedRoutees(routees,
                                                      _cluster.SelfAddress,
                                                      _metricsSelector.Weights(@event.NodeMetrics).ToImmutableDictionary(pair => pair.Key, pair => pair.Value));

            // retry when CAS failure
            if (!_weightedRouteesRef.CompareAndSet(oldValue, Tuple.Create(routees, @event.NodeMetrics, weightedRoutees.AsOption())))
            {
                MetricsChanged(@event);
            }
        }
예제 #3
0
 /// <summary>
 /// Handles
 /// </summary>
 /// <param name="change"></param>
 private void AppendMetricsChange(ClusterMetricsChanged change)
 {
     ClusterMetrics = change.NodeMetrics;
     MetricsHistory = MetricsHistory.Add(change.NodeMetrics);
 }