コード例 #1
0
 private static void AreEqual(ScaleAction exp, ScaleAction act)
 {
     if (exp != null)
     {
         Assert.Equal(exp.Cooldown, act.Cooldown);
         Assert.Equal(exp.Direction, act.Direction);
         Assert.Equal(exp.Type, act.Type);
         Assert.Equal(exp.Value, act.Value);
     }
 }
コード例 #2
0
        /// <summary>
        /// Create an Autoscale setting rule based on the properties of the object
        /// </summary>
        /// <returns>A ScaleRule created based on the properties of the object</returns>
        public ScaleRule CreateSettingRule()
        {
            if (this.TimeWindow != default(TimeSpan) && this.TimeWindow < MinimumTimeWindow)
            {
                throw new ArgumentOutOfRangeException("TimeWindow", this.TimeWindow, ResourcesForAutoscaleCmdlets.MinimumTimeWindow5min);
            }

            if (this.TimeGrain < MinimumTimeGrain)
            {
                throw new ArgumentOutOfRangeException("TimeGrain", this.TimeGrain, ResourcesForAutoscaleCmdlets.MinimumTimeGrain1min);
            }

            MetricTrigger trigger = new MetricTrigger()
            {
                MetricName = this.MetricName,
                MetricResourceUri = this.MetricResourceId,
                Operator = this.Operator,
                Statistic = this.MetricStatistic,
                Threshold = this.Threshold,
                TimeAggregation = this.TimeAggregationOperator,
                TimeGrain = this.TimeGrain,
                TimeWindow = this.TimeWindow == default(TimeSpan) ? MinimumTimeWindow : this.TimeWindow,
            };

            ScaleAction action = new ScaleAction()
            {
                Cooldown = this.ScaleActionCooldown,
                Direction = this.ScaleActionDirection,
                Type = this.ScaleActionScaleType,
                Value = this.ScaleActionValue,
            };

            return new ScaleRule()
            {
                MetricTrigger = trigger,
                ScaleAction = action,
            };
        }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the ScaleRule class.
 /// </summary>
 /// <param name="metricTrigger">the trigger that results in a scaling
 /// action.</param>
 /// <param name="scaleAction">the parameters for the scaling
 /// action.</param>
 public ScaleRule(MetricTrigger metricTrigger, ScaleAction scaleAction)
 {
     MetricTrigger = metricTrigger;
     ScaleAction   = scaleAction;
 }