Ejemplo n.º 1
0
        protected override async Task RunAsync(CancellationToken cancellationToken)
        {
            if (this.healthDataService == null)
            {
                // compose the HealthDataService instance with all the dependencies.
                var config           = new ServiceConfiguration(this.serviceContext.CodePackageActivationContext, TraceWriter);
                var filterRepository = new EntityFilterRepository(config);

                var healthClient = new FabricHealthClientWrapper(
                    TraceWriter,
                    this.serviceContext.ServiceTypeName,
                    this.serviceContext.PartitionId,
                    this.serviceContext.ReplicaId);

                var eventWriter    = new MonitoringEventWriter();
                var metricsEmitter = new MetricsEmitter(config, TraceWriter);
                var consumer       = new IfxHealthDataConsumer(eventWriter, metricsEmitter);
                var producer       = new HealthDataProducer(healthClient, consumer, TraceWriter, config, filterRepository);
                this.healthDataService = new HealthDataService(producer, TraceWriter, config, filterRepository);

                this.TraceInfo("Service.RunAsync: Composed new HealthDataService instance");
            }

            this.TraceInfo("Service.RunAsync: Invoking HealthDataService.RunAsync");
            await this.healthDataService.RunAsync(cancellationToken).ConfigureAwait(false);
        }
Ejemplo n.º 2
0
 internal HealthDataService(
     HealthDataProducer producer,
     TraceWriterWrapper traceWriter,
     IServiceConfiguration config,
     EntityFilterRepository filterRepository)
 {
     this.Producer         = Guard.IsNotNull(producer, nameof(producer));
     this.Trace            = Guard.IsNotNull(traceWriter, nameof(traceWriter));
     this.Config           = Guard.IsNotNull(config, nameof(config));
     this.FilterRepository = Guard.IsNotNull(filterRepository, nameof(filterRepository));
 }