Class VerticalVmScalingSimple

    • Constructor Detail

      • VerticalVmScalingSimple

        public VerticalVmScalingSimple​(Class<? extends ResourceManageable> resourceClassToScale,
                                       double scalingFactor)
        Creates a VerticalVmScalingSimple with a ResourceScalingGradual scaling type.
        Parameters:
        resourceClassToScale - the class of Vm resource that this scaling object will request up or down scaling (such as Ram.class, Bandwidth.class or Processor.class).
        scalingFactor - the factor (a percentage value in scale from 0 to 1) that will be used to scale a Vm resource up or down, whether such a resource is over or underloaded, according to the defined predicates. In the case of up scaling, the value 1 will scale the resource in 100%, doubling its capacity.
        See Also:
        VerticalVmScaling.setResourceScaling(ResourceScaling)
    • Method Detail

      • getUpperThresholdFunction

        public Function<Vm,​Double> getUpperThresholdFunction()
        Description copied from interface: VerticalVmScaling
        Gets a Function that defines the upper utilization threshold for a Vm which indicates if it is overloaded or not. If it is overloaded, the Vm's DatacenterBroker will request to up scale the VM. The up scaling is performed by increasing the amount of the resource the scaling is associated to.

        This function must receive a Vm and return the upper utilization threshold for it as a percentage value between 0 and 1 (where 1 is 100%). The VM will be defined as overloaded if the utilization of the Resource this scaling object is related to is higher than the value returned by the Function returned by this method.

        Specified by:
        getUpperThresholdFunction in interface VerticalVmScaling
        Returns:
        See Also:
        VerticalVmScaling.setUpperThresholdFunction(Function)
      • setUpperThresholdFunction

        public final VerticalVmScaling setUpperThresholdFunction​(Function<Vm,​Double> upperThresholdFunction)
        Description copied from interface: VerticalVmScaling
        Sets a Function that defines the upper utilization threshold for a Vm which indicates if it is overloaded or not. If it is overloaded, the Vm's DatacenterBroker will request to up scale the VM. The up scaling is performed by increasing the amount of the resource the scaling is associated to.

        This function must receive a Vm and return the upper utilization threshold for it as a percentage value between 0 and 1 (where 1 is 100%).

        By setting the upper threshold as a Function instead of a directly storing a Double value which represent the threshold, it is possible to define the threshold dynamically instead of using a static value. Furthermore, the threshold function can be reused for scaling objects of different VMs.

        Specified by:
        setUpperThresholdFunction in interface VerticalVmScaling
        Parameters:
        upperThresholdFunction - the upper utilization threshold function to set. The VM will be defined as overloaded if the utilization of the Resource this scaling object is related to is higher than the value returned by this Function.
        Returns:
      • getLowerThresholdFunction

        public Function<Vm,​Double> getLowerThresholdFunction()
        Description copied from interface: VerticalVmScaling
        Gets a Function that defines the lower utilization threshold for a Vm which indicates if it is underloaded or not. If it is underloaded, the Vm's DatacenterBroker will request to down scale the VM. The down scaling is performed by decreasing the amount of the resource the scaling is associated to.

        This function must receive a Vm and return the lower utilization threshold for it as a percentage value between 0 and 1 (where 1 is 100%). The VM will be defined as underloaded if the utilization of the Resource this scaling object is related to is lower than the value returned by the Function returned by this method.

        Specified by:
        getLowerThresholdFunction in interface VerticalVmScaling
        Returns:
        See Also:
        VerticalVmScaling.setLowerThresholdFunction(Function)
      • setLowerThresholdFunction

        public final VerticalVmScaling setLowerThresholdFunction​(Function<Vm,​Double> lowerThresholdFunction)
        Description copied from interface: VerticalVmScaling
        Sets a Function that defines the lower utilization threshold for a Vm which indicates if it is underloaded or not. If it is underloaded, the Vm's DatacenterBroker will request to down scale the VM. The down scaling is performed by decreasing the amount of the resource the scaling is associated to.

        This function must receive a Vm and return the lower utilization threshold for it as a percentage value between 0 and 1 (where 1 is 100%).

        By setting the lower threshold as a Function instead of a directly storing a Double value which represent the threshold, it is possible to define the threshold dynamically instead of using a static value. Furthermore, the threshold function can be reused for scaling objects of different VMs.

        Specified by:
        setLowerThresholdFunction in interface VerticalVmScaling
        Parameters:
        lowerThresholdFunction - the lower utilization threshold function to set. The VM will be defined as underloaded if the utilization of the Resource this scaling object is related to is lower than the value returned by this Function.
        Returns:
      • getAllocatedResource

        public long getAllocatedResource()
        Description copied from interface: VerticalVmScaling
        Gets the current amount allocated to the resource managed by this scaling object. It is just a shortcut to getVmResourceToScale.getAllocatedResource().
        Specified by:
        getAllocatedResource in interface VerticalVmScaling
        Returns:
        the amount of allocated resource
      • getScalingFactor

        public double getScalingFactor()
        Description copied from interface: VerticalVmScaling
        Gets the factor that will be used to scale a Vm resource up or down, whether such a resource is over or underloaded, according to the defined predicates.

        If the resource to scale is a Pe, this is the number of PEs to request adding or removing when the VM is over or underloaded, respectively. For any other kind of resource, this is a percentage value in scale from 0 to 1. Every time the VM needs to be scaled up or down, this factor will be applied to increase or reduce a specific VM allocated resource.

        Specified by:
        getScalingFactor in interface VerticalVmScaling
        Returns:
        the scaling factor to set which may be an absolute value (for Pe scaling) or percentage (for scaling other resources)
        See Also:
        VerticalVmScaling.getUpperThresholdFunction()
      • getResourceAmountToScale

        public double getResourceAmountToScale()
        Gets the absolute amount of the Vm resource which has to be scaled up or down, based on the scaling factor.

        If a ResourceScaling implementation such as ResourceScalingGradual or ResourceScalingInstantaneous are used, it will rely on the getScalingFactor() to compute the amount of resource to scale. Other implementations may use the scaling factor by it is up to them.

        NOTE:

        The return of this method is rounded up to avoid values between ]0 and 1[. For instance, up scaling the number of CPUs in 0.5 means that half of a CPU should be added to the VM. Since number of CPUs is an integer value, this 0.5 will be converted to zero, causing no effect. For other resources such as RAM, adding 0.5 MB has not practical advantages either. This way, the value is always rounded up.
        Specified by:
        getResourceAmountToScale in interface VerticalVmScaling
        Returns:
        the absolute amount of the Vm resource to scale
        See Also:
        VerticalVmScaling.getResourceClass()
      • setScalingFactor

        public final VerticalVmScaling setScalingFactor​(double scalingFactor)
        Description copied from interface: VerticalVmScaling
        Sets the factor that will be used to scale a Vm resource up or down, whether such a resource is over or underloaded, according to the defined predicates.

        If the resource to scale is a Pe, this is the number of PEs to request adding or removing when the VM is over or underloaded, respectively. For any other kind of resource, this is a percentage value in scale from 0 to 1. Every time the VM needs to be scaled up or down, this factor will be applied to increase or reduce a specific VM allocated resource.

        Specified by:
        setScalingFactor in interface VerticalVmScaling
        Parameters:
        scalingFactor - the scaling factor to set which may be an absolute value (for Pe scaling) or percentage (for scaling other resources)
        See Also:
        VerticalVmScaling.getUpperThresholdFunction()