internal bool IsComponentsAtleastSameAsSource(AmServerName targetServerName, List <string> failures) { bool result = true; Dictionary <string, ComponentStateWrapper.ConsolidatedHealthState> consolidatedHealthStateMap = this.GetConsolidatedHealthStateMap(this.SourceServerName); if (consolidatedHealthStateMap == null) { return(true); } Dictionary <string, ComponentStateWrapper.ConsolidatedHealthState> consolidatedHealthStateMap2 = this.GetConsolidatedHealthStateMap(targetServerName); if (consolidatedHealthStateMap2 == null) { return(true); } foreach (KeyValuePair <string, ComponentStateWrapper.ConsolidatedHealthState> keyValuePair in consolidatedHealthStateMap) { string key = keyValuePair.Key; ComponentStateWrapper.ConsolidatedHealthState value = keyValuePair.Value; ComponentStateWrapper.ConsolidatedHealthState consolidatedHealthState = null; if (consolidatedHealthStateMap2.TryGetValue(key, out consolidatedHealthState) && consolidatedHealthState != null && consolidatedHealthState.Priority <= 60 && consolidatedHealthState.HealthStatus != 1 && consolidatedHealthState.HealthStatus > value.HealthStatus) { failures.Add(string.Format("Component {0} is not in a same or better state than source on target server (SrcHealth={1} TargetHealth={2}\n", key, value.HealthStatus, consolidatedHealthState.HealthStatus)); result = false; break; } } return(result); }
private ComponentStateWrapper.ConsolidatedHealthState GetComponentHealthStateInTarget(AmServerName targetServerName, string componentName) { ComponentStateWrapper.ConsolidatedHealthState result = null; Dictionary <string, ComponentStateWrapper.ConsolidatedHealthState> consolidatedHealthStateMap = this.GetConsolidatedHealthStateMap(targetServerName); if (consolidatedHealthStateMap != null) { consolidatedHealthStateMap.TryGetValue(componentName, out result); } return(result); }
private void Initialize(string componentName, AmServerName sourceServerName, AmDbActionCode actionCode, Dictionary <AmServerName, RpcHealthStateInfo[]> stateInfoMap) { if (!string.IsNullOrEmpty(componentName)) { this.InitiatingComponent = new Component(componentName); } this.SourceServerName = sourceServerName; this.ActionCode = actionCode; this.StateInfoMap = stateInfoMap; this.consolidatedHealthTable = new Dictionary <AmServerName, Dictionary <string, ComponentStateWrapper.ConsolidatedHealthState> >(); if (stateInfoMap != null) { foreach (KeyValuePair <AmServerName, RpcHealthStateInfo[]> keyValuePair in stateInfoMap) { AmServerName key = keyValuePair.Key; RpcHealthStateInfo[] value = keyValuePair.Value; Dictionary <string, ComponentStateWrapper.ConsolidatedHealthState> dictionary = new Dictionary <string, ComponentStateWrapper.ConsolidatedHealthState>(); if (value != null && value.Length > 0) { IOrderedEnumerable <RpcHealthStateInfo> orderedEnumerable = from hs in value where hs != null orderby hs.Priority select hs; foreach (RpcHealthStateInfo rpcHealthStateInfo in orderedEnumerable) { if (rpcHealthStateInfo.DatabaseName == null || string.Equals(this.DatabaseName, rpcHealthStateInfo.DatabaseName, StringComparison.OrdinalIgnoreCase)) { ComponentStateWrapper.ConsolidatedHealthState consolidatedHealthState = null; if (!dictionary.TryGetValue(rpcHealthStateInfo.ComponentName, out consolidatedHealthState)) { consolidatedHealthState = new ComponentStateWrapper.ConsolidatedHealthState(); consolidatedHealthState.ComponentName = rpcHealthStateInfo.ComponentName; consolidatedHealthState.Priority = rpcHealthStateInfo.Priority; dictionary[consolidatedHealthState.ComponentName] = consolidatedHealthState; } if (rpcHealthStateInfo.HealthStatus > consolidatedHealthState.HealthStatus) { consolidatedHealthState.HealthStatus = rpcHealthStateInfo.HealthStatus; } } } } this.consolidatedHealthTable[key] = dictionary; } } this.ReportComponentHealth(); }
internal bool IsInitiatorComponentBetterThanSource(AmServerName targetServerName, List <string> failures) { bool result = true; if (this.ActionCode.IsAutomaticManagedAvailabilityFailover) { ComponentStateWrapper.ConsolidatedHealthState componentHealthStateInTarget = this.GetComponentHealthStateInTarget(this.SourceServerName, this.InitiatingComponentName); if (componentHealthStateInTarget != null) { ComponentStateWrapper.ConsolidatedHealthState componentHealthStateInTarget2 = this.GetComponentHealthStateInTarget(targetServerName, this.InitiatingComponentName); if (componentHealthStateInTarget2 != null && componentHealthStateInTarget2.HealthStatus != 1 && componentHealthStateInTarget2.HealthStatus >= componentHealthStateInTarget.HealthStatus) { result = false; failures.Add(string.Format("Initiating component {0} is not in a better state on target server (SrcHealth={1} TargetHealth={2}\n", this.InitiatingComponentName, componentHealthStateInTarget.HealthStatus, componentHealthStateInTarget2.HealthStatus)); } } } return(result); }
internal bool IsUptoNormalComponentsHealthy(AmServerName targetServerName, List <string> failures) { bool result = true; Dictionary <string, ComponentStateWrapper.ConsolidatedHealthState> consolidatedHealthStateMap = this.GetConsolidatedHealthStateMap(targetServerName); if (consolidatedHealthStateMap != null) { foreach (KeyValuePair <string, ComponentStateWrapper.ConsolidatedHealthState> keyValuePair in consolidatedHealthStateMap) { ComponentStateWrapper.ConsolidatedHealthState value = keyValuePair.Value; if (value.Priority <= 60 && value.HealthStatus != 1) { failures.Add(string.Format("Component {0} is not Healthy on target server (ConsolidatedHealthState={1})", value.ComponentName, value.HealthStatus)); result = false; break; } } } return(result); }