Interface VerticalVmScaling
- All Superinterfaces:
VmScaling
- All Known Implementing Classes:
VerticalVmScalingSimple
public interface VerticalVmScaling extends VmScaling
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 Cloudlet
s. 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 aVerticalVmScaling
object set monitors its own resource usage using anEventListener
, to check if anunder
oroverload
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 forwards 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
-
Field Summary
Fields Modifier and Type Field Description static VerticalVmScaling
NULL
An attribute that implements the Null Object Design Pattern forVerticalVmScaling
objects. -
Method Summary
Modifier and Type Method Description long
getAllocatedResource()
Gets the current amount allocated to theresource
managed by this scaling object.Function<Vm,Double>
getLowerThresholdFunction()
Resource
getResource()
Gets the actual VmResource
this scaling object is in charge of scaling.double
getResourceAmountToScale()
Gets the absolute amount of the Vm resource which has to be scaled up or down, based on thescaling factor
.Class<? extends ResourceManageable>
getResourceClass()
Gets the class of Vm resource this scaling object will request up or down scaling.Function<Vm,Double>
getResourceUsageThresholdFunction()
Gets the lower or upper resource utilization thresholdFunction
, depending if the Vm resource is under or overloaded, respectively.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.Function<Vm,Double>
getUpperThresholdFunction()
boolean
isVmOverloaded()
Checks if the Vm is overloaded or not, based on thegetUpperThresholdFunction()
.boolean
isVmUnderloaded()
Checks if the Vm is underloaded or not, based on thegetLowerThresholdFunction()
.boolean
requestUpScalingIfPredicateMatches(VmHostEventInfo evt)
Performs the vertical scale if the Vm is overloaded, according to thegetUpperThresholdFunction()
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.VerticalVmScaling
setLowerThresholdFunction(Function<Vm,Double> lowerThresholdFunction)
VerticalVmScaling
setResourceClass(Class<? extends ResourceManageable> resourceClass)
Sets the class of Vm resource that this scaling object will request up or down scaling.VerticalVmScaling
setResourceScaling(ResourceScaling resourceScaling)
Sets theResourceScaling
that defines how the resource has to be resized.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.VerticalVmScaling
setUpperThresholdFunction(Function<Vm,Double> upperThresholdFunction)
-
Field Details
-
NULL
An attribute that implements the Null Object Design Pattern forVerticalVmScaling
objects.
-
-
Method Details
-
getResourceClass
Class<? extends ResourceManageable> getResourceClass()Gets the class of Vm resource this scaling object will request up or down scaling. Such a class can beRam
.class,Bandwidth
.class orPe
.class.- Returns:
- See Also:
getResource()
-
setResourceClass
Sets the class of Vm resource that this scaling object will request up or down scaling. Such a class can beRam
.class,Bandwidth
.class orPe
.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
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 (forPe
scaling) or percentage (for scaling other resources)- See Also:
getUpperThresholdFunction()
-
getResourceUsageThresholdFunction
Gets the lower or upper resource utilization thresholdFunction
, 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 thegetLowerThresholdFunction()
.- Returns:
- true if the Vm is underloaded, false otherwise
-
isVmOverloaded
boolean isVmOverloaded()Checks if the Vm is overloaded or not, based on thegetUpperThresholdFunction()
.- Returns:
- true if the Vm is overloaded, false otherwise
-
getResource
Resource getResource()Gets the actual VmResource
this scaling object is in charge of scaling. This resource is defined after calling thesetResourceClass(Class)
.- Returns:
-
getResourceAmountToScale
double getResourceAmountToScale()Gets the absolute amount of the Vm resource which has to be scaled up or down, based on thescaling factor
.- Returns:
- the absolute amount of the Vm resource to scale
- See Also:
getResourceClass()
-
requestUpScalingIfPredicateMatches
Performs the vertical scale if the Vm is overloaded, according to thegetUpperThresholdFunction()
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 interfaceVmScaling
- 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
Gets aFunction
that defines the upper utilization threshold for aVm
which indicates if it is overloaded or not. If it is overloaded, the Vm'sDatacenterBroker
will request to up scale the VM. The up scaling is performed by increasing the amount of theresource
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 theResource
this scaling object is related to is higher than the value returned by theFunction
returned by this method.- Returns:
- See Also:
setUpperThresholdFunction(Function)
-
setUpperThresholdFunction
Sets aFunction
that defines the upper utilization threshold for aVm
which indicates if it is overloaded or not. If it is overloaded, the Vm'sDatacenterBroker
will request to up scale the VM. The up scaling is performed by increasing the amount of theresource
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 aDouble
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. -
getLowerThresholdFunction
Gets aFunction
that defines the lower utilization threshold for aVm
which indicates if it is underloaded or not. If it is underloaded, the Vm'sDatacenterBroker
will request to down scale the VM. The down scaling is performed by decreasing the amount of theresource
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 theResource
this scaling object is related to is lower than the value returned by theFunction
returned by this method.- Returns:
- See Also:
setLowerThresholdFunction(Function)
-
setLowerThresholdFunction
Sets aFunction
that defines the lower utilization threshold for aVm
which indicates if it is underloaded or not. If it is underloaded, the Vm'sDatacenterBroker
will request to down scale the VM. The down scaling is performed by decreasing the amount of theresource
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 aDouble
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. -
setResourceScaling
Sets theResourceScaling
that defines how the resource has to be resized.- Parameters:
resourceScaling
- theResourceScaling
to set- Returns:
-
getAllocatedResource
long getAllocatedResource()Gets the current amount allocated to theresource
managed by this scaling object. It is just a shortcut togetVmResourceToScale.getAllocatedResource()
.- Returns:
- the amount of allocated resource
-