Interface VerticalVmScaling

  • All Superinterfaces:
    VmScaling
    All Known Implementing Classes:
    VerticalVmScalingSimple

    public interface VerticalVmScaling
    extends VmScaling
    A Vm Vertical Scaling mechanism used by a DatacenterBroker to request the dynamic scale of VM resources up or down, according to the current resource usage. For each resource supposed to be scaled, a different VerticalVmScaling instance should be provided. If a scaling object is going to be set to a Vm, it has to be exclusive of that Vm. Different Vms must have different instances of a scaling object.

    A Vm runs a set of Cloudlets. When a VerticalVmScaling object is attached to a Vm, it's required to define which resource will be scaled (Ram, Bandwidth, etc) when it's under or overloaded.

    The scaling request follows this path:

    • a Vm that has a VerticalVmScaling object set monitors its own resource usage using an EventListener, to check if an under or overload condition is met;
    • if any of these conditions is met, the Vm uses the VerticalVmScaling to send a scaling request to its DatacenterBroker;
    • the DatacenterBroker fowards the request to the Datacenter where the Vm is hosted;
    • the Datacenter delegates the task to its VmAllocationPolicy;
    • the VmAllocationPolicy checks if there is resource availability and then finally scale the Vm.

    WARNING


    Make sure that the UtilizationModel of some of these Cloudlets is defined as ABSOLUTE. Defining the UtilizationModel of all Cloudlets running inside the Vm as PERCENTAGE causes these Cloudlets to automatically increase/decrease their resource usage when the Vm resource is vertically scaled. This is not a CloudSim Plus issue, but the natural and maybe surprising effect that may trap researchers trying to implement and assess VM scaling policies.

    Consider the following example: a VerticalVmScaling is attached to a Vm to double its Ram when its usage reaches 50%. The Vm has 10GB of RAM. All Cloudlets running inside this Vm have a UtilizationModel for their RAM utilization define in PERCENTAGE. When the RAM utilization of all these Cloudlets reach the 50% (5GB), the Vm Ram will be doubled. However, as the RAM usage of the running Cloudlets is defined in percentage, they will continue to use 50% of Vm's RAM, that now represents 10GB from the 20GB capacity. This way, the vertical scaling will have no real benefit.

    Since:
    CloudSim Plus 1.1.0
    Author:
    Manoel Campos da Silva Filho
    • Method Detail

      • getResourceClass

        Class<? extends ResourceManageable> getResourceClass()
        Gets the class of Vm resource this scaling object will request up or down scaling. Such a class can be Ram.class, Bandwidth.class or Pe.class.
        Returns:
        See Also:
        getResource()
      • setResourceClass

        VerticalVmScaling setResourceClass​(Class<? extends ResourceManageable> resourceClass)
        Sets the class of Vm resource that this scaling object will request up or down scaling. Such a class can be Ram.class, Bandwidth.class or Pe.class.
        Parameters:
        resourceClass - the resource class to set
        Returns:
      • getScalingFactor

        double getScalingFactor()
        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.

        Returns:
        the scaling factor to set which may be an absolute value (for Pe scaling) or percentage (for scaling other resources)
        See Also:
        getUpperThresholdFunction()
      • setScalingFactor

        VerticalVmScaling setScalingFactor​(double scalingFactor)
        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.

        Parameters:
        scalingFactor - the scaling factor to set which may be an absolute value (for Pe scaling) or percentage (for scaling other resources)
        See Also:
        getUpperThresholdFunction()
      • getResourceUsageThresholdFunction

        Function<Vm,​Double> getResourceUsageThresholdFunction()
        Gets the lower or upper resource utilization threshold Function, depending if the Vm resource is under or overloaded, respectively.
        Returns:
        the lower resource utilization threshold function if the Vm resource is underloaded, upper resource utilization threshold function if the Vm resource is overloaded, or a function that always returns 0 if the Vm isn't in any of these conditions.
        See Also:
        getLowerThresholdFunction(), getUpperThresholdFunction()
      • isVmUnderloaded

        boolean isVmUnderloaded()
        Checks if the Vm is underloaded or not, based on the getLowerThresholdFunction().
        Returns:
        true if the Vm is underloaded, false otherwise
      • isVmOverloaded

        boolean isVmOverloaded()
        Checks if the Vm is overloaded or not, based on the getUpperThresholdFunction().
        Returns:
        true if the Vm is overloaded, false otherwise
      • getResourceAmountToScale

        double getResourceAmountToScale()
        Gets the absolute amount of the Vm resource which has to be scaled up or down, based on the scaling factor.
        Returns:
        the absolute amount of the Vm resource to scale
        See Also:
        getResourceClass()
      • requestUpScalingIfPredicateMatches

        boolean requestUpScalingIfPredicateMatches​(VmHostEventInfo evt)
        Performs the vertical scale if the Vm is overloaded, according to the getUpperThresholdFunction() predicate, increasing the Vm resource to which the scaling object is linked to (that may be RAM, CPU, BW, etc), by the factor defined a scaling factor.

        The time interval in which it will be checked if the Vm is overloaded depends on the Datacenter.getSchedulingInterval() value. Make sure to set such a value to enable the periodic overload verification.

        Specified by:
        requestUpScalingIfPredicateMatches in interface VmScaling
        Parameters:
        evt - current simulation time
        Returns:
        true if the Vm is over or underloaded and up or down scaling request was sent to the broker, false otherwise
        See Also:
        getScalingFactor()
      • getUpperThresholdFunction

        Function<Vm,​Double> getUpperThresholdFunction()
        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.

        Returns:
        See Also:
        setUpperThresholdFunction(Function)
      • setUpperThresholdFunction

        VerticalVmScaling setUpperThresholdFunction​(Function<Vm,​Double> upperThresholdFunction)
        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.

        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

        Function<Vm,​Double> getLowerThresholdFunction()
        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.

        Returns:
        See Also:
        setLowerThresholdFunction(Function)
      • setLowerThresholdFunction

        VerticalVmScaling setLowerThresholdFunction​(Function<Vm,​Double> lowerThresholdFunction)
        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.

        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

        long getAllocatedResource()
        Gets the current amount allocated to the resource managed by this scaling object. It is just a shortcut to getVmResourceToScale.getAllocatedResource().
        Returns:
        the amount of allocated resource