Interface VerticalVmScaling
-
- All Superinterfaces:
VmScaling
- All Known Implementing Classes:
VerticalVmScalingSimple
public interface VerticalVmScaling extends VmScaling
A Vm Vertical Scaling mechanism used by aDatacenterBroker
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 differentVerticalVmScaling
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 ofCloudlet
s. When aVerticalVmScaling
object is attached to aVm
, it's required to define whichresource will be scaled
(Ram
,Bandwidth
, etc) when it'sunder
oroverloaded
.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 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 theUtilizationModel
of some of theseCloudlets
is defined asABSOLUTE
. Defining theUtilizationModel
of allCloudlets
running inside theVm
asPERCENTAGE
causes theseCloudlets
to automatically increase/decrease their resource usage when theVm
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 aVm
to double itsRam
when its usage reaches 50%. TheVm
has 10GB of RAM. AllCloudlets
running inside thisVm
have aUtilizationModel
for their RAM utilization define inPERCENTAGE
. When the RAM utilization of all theseCloudlets
reach the 50% (5GB), theVm
Ram
will be doubled. However, as the RAM usage of the runningCloudlets
is defined in percentage, they will continue to use 50% ofVm
'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
All Methods Instance Methods Abstract Methods 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 Detail
-
NULL
static final VerticalVmScaling NULL
An attribute that implements the Null Object Design Pattern forVerticalVmScaling
objects.
-
-
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 beRam
.class,Bandwidth
.class orPe
.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 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
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 (forPe
scaling) or percentage (for scaling other resources)- See Also:
getUpperThresholdFunction()
-
getResourceUsageThresholdFunction
Function<Vm,Double> 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
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.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
Function<Vm,Double> 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
VerticalVmScaling setUpperThresholdFunction(Function<Vm,Double> upperThresholdFunction)
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
Function<Vm,Double> 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
VerticalVmScaling setLowerThresholdFunction(Function<Vm,Double> lowerThresholdFunction)
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
VerticalVmScaling setResourceScaling(ResourceScaling resourceScaling)
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
-
-