/// <summary> /// Escalates the impact category if the estimated impact duration equals or exceeds the given threshold. /// </summary> /// <param name="oldCategory">The current impact category.</param> /// <param name="impactDetail">The impact detail.</param> /// <param name="configKeyName">The key of the configuration setting containing the duration threshold value.</param> /// <param name="defaultThresholdInSeconds">The default duration threshold value.</param> /// <param name="escalateToCategory">The category to escalate to if the threshold is exceeded.</param> /// <returns>The new impact category.</returns> private ImpactCategory ApplyImpactDurationThreshold( ImpactCategory oldCategory, IImpactDetail impactDetail, string configKeyName, int defaultThresholdInSeconds, ImpactCategory escalateToCategory) { ImpactCategory newCategory = oldCategory; int thresholdInSeconds = this.configSection.ReadConfigValue(configKeyName, defaultThresholdInSeconds); if (impactDetail.EstimatedImpactDurationInSeconds >= thresholdInSeconds) { newCategory = EscalateImpactCategory(oldCategory, escalateToCategory); if (oldCategory != newCategory) { Tracer.WriteNoise( "Overall impact changed from {0} to {1} due to impact duration of {2} sec (threshold = {3} sec)", oldCategory, newCategory, impactDetail.EstimatedImpactDurationInSeconds, thresholdInSeconds); } } return(newCategory); }
/// <summary> /// Translates IImpactDetail to an ImpactCategory. /// </summary> private ImpactCategory TranslateImpactDetailToCategory(IImpactDetail impactDetail) { ImpactCategory currentCategory = ImpactCategory.NoImpact; // Translate each resource currentCategory = ApplyResourceImpact(currentCategory, "Compute", impactDetail.ComputeImpact); currentCategory = ApplyResourceImpact(currentCategory, "Disk", impactDetail.DiskImpact); currentCategory = ApplyResourceImpact(currentCategory, "Network", impactDetail.NetworkImpact); currentCategory = ApplyResourceImpact(currentCategory, "OS", impactDetail.OsImpact); // Freeze impact of unknown duration should be escalated to a restart currentCategory = ApplyUnknownDurationFreezeRule(currentCategory, impactDetail); // If there is any impact, escalate based on estimated impact duration if (currentCategory != ImpactCategory.NoImpact) { currentCategory = ApplyImpactDurationThreshold( currentCategory, impactDetail, ConfigKeyDataDestructiveDurationThreshold, DefaultDataDestructiveDurationThreshold, ImpactCategory.DataDestructive); currentCategory = ApplyImpactDurationThreshold( currentCategory, impactDetail, ConfigKeyRestartDurationThreshold, DefaultRestartDurationThreshold, ImpactCategory.Restart); } return(currentCategory); }
/// <summary> /// Translates the impact details to a CM node task. /// </summary> /// <param name="impactDetail">The impact details to be translated.</param> /// <returns>The node task to be sent to the CM.</returns> public NodeTask TranslateImpactDetailToNodeTask(IImpactDetail impactDetail) { impactDetail.Validate("impactDetail"); ImpactCategory category = TranslateImpactDetailToCategory(impactDetail); return(TranslateImpactCategoryToNodeTask(category)); }
/// <summary> /// Escalates a freeze of unknown duration, according to configuration. /// </summary> /// <param name="oldCategory">The current impact category.</param> /// <param name="impactDetail">The impact detail.</param> /// <returns>The new impact category.</returns> private ImpactCategory ApplyUnknownDurationFreezeRule( ImpactCategory oldCategory, IImpactDetail impactDetail) { ImpactCategory newCategory = oldCategory; if ((oldCategory == ImpactCategory.Freeze) && (impactDetail.EstimatedImpactDurationInSeconds < 0)) { newCategory = this.configSection.ReadConfigValue(ConfigKeyUnknownDurationFreezeMapping, ImpactCategory.Restart); if (oldCategory != newCategory) { Tracer.WriteNoise( "Overall impact changed from {0} to {1} due to freeze of unknown duration", oldCategory, newCategory); } } return(newCategory); }
private IEnumerable <ImpactedInstance> BuildImpactList() { ManagementJobStep jobStep = this.notification.SourceJobStep; IDictionary <string, ImpactedRoleInstance> jobImpactMap; IDictionary <string, ImpactedRoleInstance> jobStepImpactMap; try { jobImpactMap = jobStep.SourceJob.ListImpactedRoleInstances(); jobStepImpactMap = jobStep.ListImpactedRoleInstances(); } catch (Exception ex) { string message = string.Format( CultureInfo.InvariantCulture, "Error getting impacted role instances from management protocol while building impact list for notification Id: {0}, source job step: {1}, source job: {2}, target UD: {3}", notification.Id, jobStep, jobStep.SourceJob, jobStep.TargetUpdateDomain); Trace.WriteWarning(TraceType, message); throw new ManagementException(message, ex); } List <ImpactedInstance> jobStepImpactList = new List <ImpactedInstance>(jobStepImpactMap.Count); // Extract impact list from the job step, potentially augmented with impact from the job foreach (var impactedInstance in jobStepImpactMap.Values) { string instanceId = impactedInstance.Id; IEnumerable <ImpactReason> jobStepImpact = impactedInstance.ImpactReasons; IImpactDetail jobStepImpactDetail = impactedInstance.ImpactStatement; // Workaround for RDBug#783846: MR platform repair job notifications present no impact reasons for impacted role instances // // If this is a PlatformRepairJob and the job *step* provides no impact reasons, // then merge in the impact reasons given for that role instance in the job. if (this.ActiveJobType == JobType.PlatformRepairJob && !jobStepImpact.Any()) { ImpactedRoleInstance jobImpactedInstance; if (jobImpactMap.TryGetValue(instanceId, out jobImpactedInstance)) { Trace.WriteWarning(TraceType, "Job step impact for {0} is empty; using impact from job ({1})", instanceId, string.Join(",", jobImpactedInstance.ImpactReasons)); jobStepImpact = jobStepImpact.Union(jobImpactedInstance.ImpactReasons); } else { Trace.WriteWarning(TraceType, "Job step impact for {0} is empty, and job provides no impact", instanceId); } } ImpactedInstance element = new ImpactedInstance( instanceId, jobStepImpact.ToArray(), jobStepImpactDetail); jobStepImpactList.Add(element); } return(jobStepImpactList); }
public ImpactedInstance(string id, IEnumerable <ImpactReason> impactReasons, IImpactDetail impactDetail) { this.Id = id; this.ImpactReasons = impactReasons; this.ImpactDetail = impactDetail; }