private HealthState GetRoleInstanceHealth( IList <RoleInstance> roleInstances, HealthState inputHealthState, IRoleInstanceHealthPolicyManager manager) { bool enableTracing = this.configSection.ReadConfigValue($"{this.configKeyPrefix}Health.TracingEnabled", false); bool enableReportHealth = this.configSection.ReadConfigValue($"{this.configKeyPrefix}Health.ReportHealthEnabled", true); var serviceHealthState = HealthState.Ok; foreach (RoleInstance roleInstance in roleInstances) { var outputHealthState = inputHealthState; try { outputHealthState = manager.Execute(roleInstance, inputHealthState); } catch (Exception ex) { // no choice but to catch everything since we don't know what to expect from each policy implementation string text = ex.GetMessage(); Trace.WriteWarning( RoleInstanceHealthConstants.TraceType, "Unable to apply health policies on role instance '{0}'. Error(s): {1}", roleInstance.Id, text); outputHealthState = HealthState.Warning; serviceHealthState = HealthState.Warning; } finally { AddReport(roleInstance, outputHealthState, enableTracing, enableReportHealth); } } return(serviceHealthState); }
private HealthState GetRoleInstanceHealth( IList <RoleInstance> roleInstances, HealthState inputHealthState, IRoleInstanceHealthPolicyManager healthPolicyManager) { var serviceHealthState = HealthState.Ok; foreach (RoleInstance roleInstance in roleInstances) { var outputHealthState = inputHealthState; try { outputHealthState = healthPolicyManager.Execute(roleInstance, inputHealthState); } catch (Exception ex) { // no choice but to catch everything since we don't know what to expect from each policy implementation string text = ex.GetMessage(); Trace.WriteWarning( HealthConstants.TraceType, "Unable to apply health policies on role instance '{0}'. Error(s): {1}", roleInstance.Id, text); outputHealthState = HealthState.Warning; serviceHealthState = HealthState.Warning; } finally { AddReport(roleInstance, outputHealthState); } } return(serviceHealthState); }