Class ScalingRule
- java.lang.Object
-
- com.elastisys.autoscaler.predictors.rulebased.rule.ScalingRule
-
public class ScalingRule extends java.lang.ObjectRepresents aScalingRulefor aRuleBasedPredictor. A scaling rule triggers a scaling action when the watched metric value has satisfied a condition for a sufficient amount of time. When the value of a the monitored metric data series has breached a threshold for sufficiently long a scaling action is triggered. TheScalingRulecan be tested against a metric value sequence by invoking theisSatisfiedBy(List)method. The semantics of a scaling rule can be expressed in the following way:when the metric value has been <condition> <threshold> for <period> seconds, adjust the capacity by <resize> <unit>For example:when the metric value has been <ABOVE> <80> for <600> seconds, adjust the capacity by <+10> <PERCENT>- See Also:
RuleBasedPredictor,RuleBasedPredictorParams
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classScalingRule.RuleOutcomeA tuple-like object that returns both the outcome result of the rule constraint checks and also a reason message with details of what caused the result.
-
Constructor Summary
Constructors Constructor Description ScalingRule(Condition condition, double threshold, com.elastisys.scale.commons.json.types.TimeInterval period, double resize, ResizeUnit unit)Constructs a newScalingRule.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)ConditiongetCondition()Returns the condition used to compare the aggregated value with the threshold.com.elastisys.scale.commons.json.types.TimeIntervalgetPeriod()Returns the evaluation period that the threshold condition must hold true before triggering a resize.doublegetResize()Returns the size of the capacity adjustment that is triggered when the threshold condition has beentruefor sufficiently long.intgetResizeIncrement(int machinePoolSize)Returns the resize increment that results from applying thisScalingRuleto a machine pool of a given size.doublegetThreshold()Returns the threshold that, when breached for a sufficiently long time, triggers the resize action.ResizeUnitgetUnit()Returns the unit that the resize increment is specified in.inthashCode()ScalingRule.RuleOutcomeisSatisfiedBy(java.util.List<com.elastisys.autoscaler.core.utils.stats.timeseries.DataPoint> metricSequence)Evaluates thisScalingRuleagainst a sequence of metric values and returnstrueif the metric sequence satisfies thisScalingRule(that is, the metric values have satisfied the threshold condition for a sufficiently long time).java.lang.StringtoString()voidvalidate()Performs basic validation of thisScalingRule.
-
-
-
Constructor Detail
-
ScalingRule
public ScalingRule(Condition condition, double threshold, com.elastisys.scale.commons.json.types.TimeInterval period, double resize, ResizeUnit unit)
Constructs a newScalingRule.- Parameters:
condition- The condition used to compare the aggregated value with the threshold.threshold- The threshold that, when breached for a sufficiently long time, triggers the resize action.period- The evaluation period that the threshold condition must hold true before triggering a resize.resize- The size of the capacity adjustment that is triggered when the threshold condition has beentruefor sufficiently long.unit- The unit that the resize increment is specified in.
-
-
Method Detail
-
validate
public void validate() throws java.lang.IllegalArgumentExceptionPerforms basic validation of thisScalingRule.- Throws:
java.lang.IllegalArgumentException- if validation fails.
-
getCondition
public Condition getCondition()
Returns the condition used to compare the aggregated value with the threshold.- Returns:
-
getThreshold
public double getThreshold()
Returns the threshold that, when breached for a sufficiently long time, triggers the resize action.- Returns:
-
getPeriod
public com.elastisys.scale.commons.json.types.TimeInterval getPeriod()
Returns the evaluation period that the threshold condition must hold true before triggering a resize.- Returns:
-
getResize
public double getResize()
Returns the size of the capacity adjustment that is triggered when the threshold condition has beentruefor sufficiently long.- Returns:
-
getUnit
public ResizeUnit getUnit()
Returns the unit that the resize increment is specified in.- Returns:
-
isSatisfiedBy
public ScalingRule.RuleOutcome isSatisfiedBy(java.util.List<com.elastisys.autoscaler.core.utils.stats.timeseries.DataPoint> metricSequence)
Evaluates thisScalingRuleagainst a sequence of metric values and returnstrueif the metric sequence satisfies thisScalingRule(that is, the metric values have satisfied the threshold condition for a sufficiently long time).- Parameters:
metricSequence- A metric sequence that is assumed to be sorted in order of increasing time (newest metric value last).- Returns:
- RuleOutcome
-
getResizeIncrement
public int getResizeIncrement(int machinePoolSize)
Returns the resize increment that results from applying thisScalingRuleto a machine pool of a given size. Note: the scaling rule will never suggest a (negative) increment that brings the machine pool to a size smaller than one instance.- Parameters:
machinePoolSize- The size of the machine pool to be resized.- Returns:
- The pool resize increment that results from applying this
ScalingRuleto the machine pool.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-