예제 #1
0
        public override Task ProcessClusterHealthAsync(ClusterEntity cluster)
        {
            ServiceEventSource.Current.Message($"cluster: {cluster}, aggregatedHealth: {cluster.Health.AggregatedHealthState}");

            cluster.Health.HealthEvents
            .ForEachHealthEvent(healthEvent =>
            {
                ServiceEventSource.Current.Message($"cluster: {cluster}, health: {healthEvent}");
            });

            return(this.completedTask);
        }
예제 #2
0
 public abstract Task ProcessClusterHealthAsync(ClusterEntity cluster);
예제 #3
0
        public async Task ReadHealthDataAsync(CancellationToken cancellationToken)
        {
            this.traceWriter.WriteInfo("HealthDataProducer.ReadHealthData: Health data read pass has started.");

            IEntity clusterEntity = new ClusterEntity(this.healthClient, this.consumer, this.traceWriter, this.config, this.filterRepository);

            // We will be performing a depth-first traversal of entities. Push the first entity to stack.
            this.stack.Push(clusterEntity);
            var entityCount = 0;

            this.stopwatch.Restart();

            while (this.stack.Count > 0)
            {
                if (cancellationToken.IsCancellationRequested)
                {
                    this.traceWriter.WriteInfo("HealthDataProducer.ReadHealthDataAsync: Entity processing canceled.");
                    this.stopwatch.Reset();
                    return;
                }

                if (this.stopwatch.Elapsed >= this.config.HealthDataReadTimeout)
                {
                    this.traceWriter.WriteError("HealthDataProducer.ReadHealthDataAsync: Entity processing timed out.");
                    this.stopwatch.Reset();

                    this.healthClient.ReportHealth(
                        HealthState.Error,
                        "ReadHealthData",
                        "Read health data loop timed out. The Monitoring service took more time to process health data than the HealthDataReadTimeoutInSeconds value.");

                    return;
                }

                IEntity entity = this.stack.Pop();
                if (entity == null)
                {
                    continue;
                }

                var resultEntityList = await entity.ProcessAsync(cancellationToken).ConfigureAwait(false);

                entityCount++;

                // If the previous entity had any children we need to process, push them on to stack.
                if (resultEntityList != null && !cancellationToken.IsCancellationRequested)
                {
                    foreach (var entityToProcess in resultEntityList)
                    {
                        this.stack.Push(entityToProcess);
                    }
                }
            }

            this.traceWriter.WriteInfo(
                "HealthDataProducer.ReadHealthData: Read pass completed. Processed {0} entities in {1} millisecond.",
                entityCount,
                this.stopwatch.Elapsed);

            this.stopwatch.Reset();

            this.healthClient.ReportHealth(
                HealthState.Ok,
                "ReadHealthData",
                "Read health data loop completed successfully.");
        }