Class ScalingRule


  • public class ScalingRule
    extends java.lang.Object
    Represents a ScalingRule for a RuleBasedPredictor. 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. The ScalingRule can be tested against a metric value sequence by invoking the isSatisfiedBy(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
      class  ScalingRule.RuleOutcome
      A 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 new ScalingRule.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object obj)  
      Condition getCondition()
      Returns the condition used to compare the aggregated value with the threshold.
      com.elastisys.scale.commons.json.types.TimeInterval getPeriod()
      Returns the evaluation period that the threshold condition must hold true before triggering a resize.
      double getResize()
      Returns the size of the capacity adjustment that is triggered when the threshold condition has been true for sufficiently long.
      int getResizeIncrement​(int machinePoolSize)
      Returns the resize increment that results from applying this ScalingRule to a machine pool of a given size.
      double getThreshold()
      Returns the threshold that, when breached for a sufficiently long time, triggers the resize action.
      ResizeUnit getUnit()
      Returns the unit that the resize increment is specified in.
      int hashCode()  
      ScalingRule.RuleOutcome isSatisfiedBy​(java.util.List<com.elastisys.autoscaler.core.utils.stats.timeseries.DataPoint> metricSequence)
      Evaluates this ScalingRule against a sequence of metric values and returns true if the metric sequence satisfies this ScalingRule (that is, the metric values have satisfied the threshold condition for a sufficiently long time).
      java.lang.String toString()  
      void validate()
      Performs basic validation of this ScalingRule.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ScalingRule

        public ScalingRule​(Condition condition,
                           double threshold,
                           com.elastisys.scale.commons.json.types.TimeInterval period,
                           double resize,
                           ResizeUnit unit)
        Constructs a new ScalingRule.
        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 been true for sufficiently long.
        unit - The unit that the resize increment is specified in.
    • Method Detail

      • validate

        public void validate()
                      throws java.lang.IllegalArgumentException
        Performs basic validation of this ScalingRule.
        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 been true for 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 this ScalingRule against a sequence of metric values and returns true if the metric sequence satisfies this ScalingRule (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 this ScalingRule to 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 ScalingRule to the machine pool.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object