コード例 #1
0
        public void ProbingCompleted(ClusterInfo cluster, IReadOnlyList <DestinationProbingResult> probingResults)
        {
            var threshold = GetFailureThreshold(cluster);
            var changed   = false;

            for (var i = 0; i < probingResults.Count; i++)
            {
                var destination = probingResults[i].Destination;

                var count     = _failureCounters.GetOrCreateValue(destination);
                var newHealth = EvaluateHealthState(threshold, probingResults[i].Response, count);

                var healthState = destination.Health;
                if (newHealth != healthState.Active)
                {
                    healthState.Active = newHealth;
                    changed            = true;
                    if (newHealth == DestinationHealth.Unhealthy)
                    {
                        Log.ActiveDestinationHealthStateIsSetToUnhealthy(_logger, destination.DestinationId, cluster.ClusterId);
                    }
                    else
                    {
                        Log.ActiveDestinationHealthStateIsSet(_logger, destination.DestinationId, cluster.ClusterId, newHealth);
                    }
                }
            }

            if (changed)
            {
                cluster.UpdateDynamicState();
            }
        }
コード例 #2
0
        public void ProbingCompleted(ClusterInfo cluster, IReadOnlyList <DestinationProbingResult> probingResults)
        {
            cluster.PauseHealthyDestinationUpdates();

            try
            {
                var threshold = GetFailureThreshold(cluster);

                for (var i = 0; i < probingResults.Count; i++)
                {
                    var destination = probingResults[i].Destination;

                    var count     = _failureCounters.GetOrCreateValue(destination);
                    var newHealth = EvaluateHealthState(threshold, probingResults[i].Response, count);

                    var state = destination.DynamicState;
                    if (newHealth != state.Health.Active)
                    {
                        destination.DynamicState = new DestinationDynamicState(state.Health.ChangeActive(newHealth));

                        if (newHealth == DestinationHealth.Unhealthy)
                        {
                            Log.ActiveDestinationHealthStateIsSetToUnhealthy(_logger, destination.DestinationId, cluster.ClusterId);
                        }
                        else
                        {
                            Log.ActiveDestinationHealthStateIsSet(_logger, destination.DestinationId, cluster.ClusterId, newHealth);
                        }
                    }
                }
            }
            finally
            {
                cluster.ResumeHealthyDestinationUpdates();
            }
        }