Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 3
0
        /// <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));
        }
Exemplo n.º 4
0
 /// <summary>
 /// Returns the more severe of the two impact categories (like Math.Max for ImpactCategory).
 /// </summary>
 /// <returns></returns>
 private static ImpactCategory EscalateImpactCategory(ImpactCategory oldCategory, ImpactCategory newCategory)
 {
     if (oldCategory < newCategory)
     {
         return(newCategory);
     }
     else
     {
         return(oldCategory);
     }
 }
Exemplo n.º 5
0
        private static NodeTask TranslateImpactCategoryToNodeTask(ImpactCategory category)
        {
            switch (category)
            {
            case ImpactCategory.NoImpact:
            case ImpactCategory.Freeze:
                return(NodeTask.Invalid);

            case ImpactCategory.Restart:
                return(NodeTask.Restart);

            case ImpactCategory.DataDestructive:
                return(NodeTask.Relocate);
            }

            throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, "Unknown impact category: {0}", category));
        }
Exemplo n.º 6
0
        private static NodeImpactLevel TranslateImpactCategoryToNodeImpactLevel(ImpactCategory category)
        {
            switch (category)
            {
            case ImpactCategory.NoImpact:
            case ImpactCategory.Freeze:
                return(NodeImpactLevel.None);

            case ImpactCategory.Restart:
                return(NodeImpactLevel.Restart);

            case ImpactCategory.DataDestructive:
                return(NodeImpactLevel.RemoveData);

            case ImpactCategory.Decommission:
                return(NodeImpactLevel.RemoveNode);
            }

            throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, "Unknown impact category: {0}", category));
        }
Exemplo n.º 7
0
        /// <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);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Escalates the impact category based on the impact to a particular resource type.
        /// </summary>
        /// <param name="oldCategory">The current impact category.</param>
        /// <param name="resourceType">The resource type name.</param>
        /// <param name="impact">The impact to the given resource.</param>
        /// <returns>The new impact category.</returns>
        private ImpactCategory ApplyResourceImpact(
            ImpactCategory oldCategory,
            string resourceType,
            ResourceImpactEnum impact)
        {
            ImpactCategory newCategory = TranslateResourceImpactToCategory(resourceType, impact);

            newCategory = EscalateImpactCategory(oldCategory, newCategory);

            if (oldCategory != newCategory)
            {
                Tracer.WriteNoise(
                    "Overall impact changed from {0} to {1} due to resource impact {2}={3}",
                    oldCategory,
                    newCategory,
                    resourceType,
                    impact);
            }

            return(newCategory);
        }