Example #1
0
        private async Task <TMonitoringEntityHealth> GetHealthAsync <TEntityHealth, TMonitoringEntityHealth>(
            Func <Task <TEntityHealth> > healthQuery, Func <TEntityHealth, TMonitoringEntityHealth> initializer)
            where TEntityHealth : FabricHealth.EntityHealth
            where TMonitoringEntityHealth : MonitoringHealth.EntityHealth
        {
            try
            {
                var health = await this.DoGetHealthAsync(healthQuery).ConfigureAwait(false);

                return(initializer(health));
            }
            catch (TimeoutException timeoutEx)
            {
                this.traceWriter.Exception(timeoutEx);
            }
            catch (FabricObjectClosedException fabricClientClosedEx)
            {
                this.traceWriter.Exception(fabricClientClosedEx);
                this.healthClient = this.GetNewHealthClientInstance();
            }
            catch (FabricTransientException fabricTransientEx)
            {
                this.traceWriter.Exception(fabricTransientEx);
            }
            catch (FabricException fabricEx)
            {
                this.traceWriter.Exception(fabricEx);
            }

            return(null);
        }
Example #2
0
        private static async Task DumpClusterHealthAsync(FabricClient fc)
        {
            FabricClient.HealthClient hm = fc.HealthManager;

            ClusterHealth clusterHealth = await hm.GetClusterHealthAsync();

            WriteLine($"Cluster: State={clusterHealth.AggregatedHealthState}");
            foreach (HealthEvent healthEvent in clusterHealth.HealthEvents)
            {
                healthEvent.WriteHealth();
            }
            foreach (HealthEvaluation healthEval in clusterHealth.UnhealthyEvaluations)
            {
                WriteLine(healthEval);
            }
            foreach (NodeHealthState nodeHealth in clusterHealth.NodeHealthStates)
            {
                WriteLine($"Node: State={nodeHealth.AggregatedHealthState}, Name={nodeHealth.NodeName}");
            }
            foreach (ApplicationHealthState appHealthState in clusterHealth.ApplicationHealthStates)
            {
                WriteLine($"App: State={appHealthState.AggregatedHealthState}, Name={appHealthState.ApplicationName}");
            }


            //await hm.GetNodeHealthAsync()
            ApplicationHealth appHealth = await hm.GetApplicationHealthAsync(new Uri(@"fabric:/"));

            WriteLine($"App: State={appHealth.AggregatedHealthState}, Name={appHealth.ApplicationName}");
            foreach (HealthEvent healthEvent in appHealth.HealthEvents)
            {
                healthEvent.WriteHealth();
            }
        }
Example #3
0
        public FabricHealthClientWrapper(TraceWriterWrapper trace, string serviceTypeName, Guid partitionId, long replicaId)
        {
            this.traceWriter  = Guard.IsNotNull(trace, nameof(trace));
            this.healthClient = this.GetNewHealthClientInstance();

            this.serviceTypeName = Guard.IsNotNullOrEmpty(serviceTypeName, nameof(serviceTypeName));
            this.partitionId     = partitionId;
            this.replicaId       = replicaId;
        }
 public HealthClientWrapper(IFabricClientWrapper fabricClientWrapper)
 {
     _healthClient = fabricClientWrapper.FabricClient.HealthManager;
 }
Example #5
0
 public MockWatchdog(FabricClient.HealthClient healthManager, string nodeName)
 {
     _healthManager = healthManager;
     NodeName       = nodeName;
 }
 public HealthClientWrapper()
 {
     _healthClient = new FabricClient().HealthManager;
 }