/// <summary> /// Adds a health report to the Windows Fabric health system. /// </summary> /// <param name="roleInstance">The role instance.</param> /// <param name="healthState">State of the health.</param> private void AddReport(RoleInstance roleInstance, HealthState healthState) { string nodeName = roleInstance.Id.TranslateRoleInstanceToNodeName(); // this one is purely for informational purposes AddReport(nodeName, HealthConstants.HealthReportRoleInstanceLastUpdateTimePropertyName, roleInstance.LastUpdateTime.ToString("o"), HealthState.Ok); AddReport(nodeName, HealthConstants.HealthReportRoleInstanceStatusPropertyName, roleInstance.Status.ToString(), healthState); }
public HealthState Execute(RoleInstance roleInstance, HealthState input) { foreach (var healthPolicy in healthPolicies) { input = healthPolicy.Apply(roleInstance, input); } return(input); }
public override HealthState Apply( RoleInstance roleInstance, HealthState input) { HealthState maxAllowedHealthState; string value = GetConfigValue(maxAllowedKeyName); bool success = Enum.TryParse(value, out maxAllowedHealthState); if (success) { // E.g. if input is Error and maxAllowedHealthState is Warning, then clamp (or restrict the return value to Warning) if (input > maxAllowedHealthState) { Trace.WriteInfo( HealthConstants.TraceType, "Reducing input health state from '{0}' to '{1}' due to setting provided in config key '{2}' of watchdog health config policy '{3}'", input, maxAllowedHealthState, maxAllowedKeyName, Name); input = maxAllowedHealthState; } } else { if (input < HealthState.Warning) { input = HealthState.Warning; Trace.WriteWarning( HealthConstants.TraceType, "Updating health state to '{0}' due to error while getting value '{1}' for config key '{2}' provided to watchdog health config policy '{3}'", input, value, maxAllowedKeyName, Name); } else { Trace.WriteWarning( HealthConstants.TraceType, "Error while getting value '{0}' for config key '{1}' provided to watchdog health config policy '{2}'", value, maxAllowedKeyName, Name); } } return(input); }
/// <summary> /// Adds a health report to the Windows Fabric health system. /// </summary> /// <param name="roleInstance">The role instance.</param> /// <param name="healthState">State of the health.</param> private void AddReport(RoleInstance roleInstance, HealthState healthState, bool enableTracing, bool enableReportHealth) { string nodeName = roleInstance.Id.TranslateRoleInstanceToNodeName(); if (enableReportHealth) { // this one is purely for informational purposes AddReport(nodeName, RoleInstanceHealthConstants.HealthReportRoleInstanceLastUpdateTimePropertyName, roleInstance.LastUpdateTime.ToString("o"), HealthState.Ok); AddReport(nodeName, RoleInstanceHealthConstants.HealthReportRoleInstanceStatusPropertyName, roleInstance.Status.ToString(), healthState); } if (enableTracing && (roleInstance.Status != RoleInstanceState.ReadyRole)) { Trace.WriteInfo( RoleInstanceHealthConstants.TraceType, "Role instance {0}: {1} (last updated at {2:O})", roleInstance.Id, roleInstance.Status, roleInstance.LastUpdateTime); } }
public abstract HealthState Apply( RoleInstance roleInstance, HealthState input);
public override HealthState Apply(RoleInstance roleInstance, HealthState input) { string key = GetFullKeyName(roleInstance.Status); if (!DoesConfigKeyExist(key)) { if (input < HealthState.Warning) { input = HealthState.Warning; Trace.WriteWarning( HealthConstants.TraceType, "Updating health state to '{0}' due to unknown config key '{1}' provided to watchdog health config policy '{2}'", input, key, Name); } else { Trace.WriteWarning( HealthConstants.TraceType, "Unknown config key '{0}' provided in watchdog health config policy '{1}'", key, Name); } return(input); } HealthState output; string value = GetConfigValue(key); bool success = Enum.TryParse(value, true, out output); if (success) { return(output); } // we come here because of an Enum.TryParse error. if (input < HealthState.Warning) { input = HealthState.Warning; Trace.WriteWarning( HealthConstants.TraceType, "Updating health state to '{0}' due to error while getting value '{1}' for config key '{2}' provided to watchdog health config policy '{3}'", input, value, key, Name); } else { Trace.WriteWarning( HealthConstants.TraceType, "Error while getting value '{0}' for config key '{1}' provided to watchdog health config policy '{2}'", value, key, Name); } return(input); }