public RoleInstanceHealthWatchdog(IConfigSection configSection, string configKeyPrefix, IHealthClient healthClient) { this.configSection = configSection.Validate("configSection"); this.configKeyPrefix = configKeyPrefix.Validate("configKeyPrefix"); this.healthClient = healthClient.Validate("healthClient"); healthPolicyManager = new DynamicRoleInstanceHealthPolicyManager(configSection, configKeyPrefix); }
public RoleInstanceHealthWatchdog(WindowsAzureInfrastructureCoordinator coordinator) { coordinator.ThrowIfNull("coordinator"); this.coordinator = coordinator; healthPolicyManager = new DynamicRoleInstanceHealthPolicyManager(coordinator); }
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); }