Class VerticalVmScalingAbstract
- All Implemented Interfaces:
VerticalVmScaling
,VmScaling
- Direct Known Subclasses:
VerticalVmScalingSimple
VerticalVmScaling
.- Since:
- CloudSim Plus 7.0.4
- Author:
- Manoel Campos da Silva Filho
-
Field Summary
Fields inherited from interface org.cloudsimplus.autoscaling.VerticalVmScaling
NULL
-
Constructor Summary
ConstructorDescriptionVerticalVmScalingAbstract
(Class<? extends ResourceManageable> resourceClassToScale, ResourceScaling resourceScaling, double scalingFactor) Creates a VerticalVmScalingAbstract. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Tries to allocate more resources for a VM, if there is availability.long
Gets the current amount allocated to theresource
managed by this scaling object.Gets the actual VmResource
this scaling object is in charge of scaling.double
Gets the absolute amount of the Vm resource which has to be scaled up or down, based on thescaling factor
.Class<? extends ResourceManageable>
Gets the class of Vm resource this scaling object will request up or down scaling.Gets the lower or upper resource utilization thresholdFunction
, depending if the Vm resource is under or overloaded, respectively.double
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.boolean
void
protected boolean
requestUpScaling
(double time) Performs the actual request to scale the Vm up or down, depending on whether it is over or underloaded, respectively.final boolean
Performs the vertical scale if the Vm is overloaded, according to theVerticalVmScaling.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.final VerticalVmScaling
setLowerThresholdFunction
(Function<Vm, Double> lowerThresholdFunction) final VerticalVmScaling
setResourceScaling
(ResourceScaling resourceScaling) Sets theResourceScaling
that defines how the resource has to be resized.final 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.final VerticalVmScaling
setUpperThresholdFunction
(Function<Vm, Double> upperThresholdFunction) void
Sets aVm
to this Load Balancer.Methods inherited from class org.cloudsimplus.autoscaling.VmScalingAbstract
getVm, isTimeToCheckPredicate, setLastProcessingTime
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.cloudsimplus.autoscaling.VerticalVmScaling
isVmOverloaded, isVmUnderloaded
-
Constructor Details
-
VerticalVmScalingAbstract
public VerticalVmScalingAbstract(Class<? extends ResourceManageable> resourceClassToScale, ResourceScaling resourceScaling, double scalingFactor) Creates a VerticalVmScalingAbstract.- Parameters:
resourceClassToScale
- the class of Vm resource that this scaling object will request up or down scaling (such asRam
.class,Bandwidth
.class orProcessor
.class).resourceScaling
-ResourceScaling
that defines how the resource has to be resized.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:
-
-
Method Details
-
getUpperThresholdFunction
Description copied from interface:VerticalVmScaling
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.- Specified by:
getUpperThresholdFunction
in interfaceVerticalVmScaling
- Returns:
- See Also:
-
setUpperThresholdFunction
public final VerticalVmScaling setUpperThresholdFunction(Function<Vm, Double> upperThresholdFunction) Description copied from interface:VerticalVmScaling
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.- Specified by:
setUpperThresholdFunction
in interfaceVerticalVmScaling
- Parameters:
upperThresholdFunction
- the upper utilization threshold function to set. 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 thisFunction
.- Returns:
-
setLowerThresholdFunction
public final VerticalVmScaling setLowerThresholdFunction(Function<Vm, Double> lowerThresholdFunction) Description copied from interface:VerticalVmScaling
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.- Specified by:
setLowerThresholdFunction
in interfaceVerticalVmScaling
- Parameters:
lowerThresholdFunction
- the lower utilization threshold function to set. 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 thisFunction
.- Returns:
-
getLowerThresholdFunction
Description copied from interface:VerticalVmScaling
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.- Specified by:
getLowerThresholdFunction
in interfaceVerticalVmScaling
- Returns:
- See Also:
-
setResourceScaling
Sets theResourceScaling
that defines how the resource has to be resized.This class' constructors define a
ResourceScalingGradual
as the defaultResourceScaling
.- Specified by:
setResourceScaling
in interfaceVerticalVmScaling
- Parameters:
resourceScaling
- theResourceScaling
to set- Returns:
-
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 interfaceVerticalVmScaling
- Returns:
- the scaling factor to set which may be an absolute value (for
Pe
scaling) or percentage (for scaling other resources) - See Also:
-
setScalingFactor
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 interfaceVerticalVmScaling
- Parameters:
scalingFactor
- the scaling factor to set which may be an absolute value (forPe
scaling) or percentage (for scaling other resources)- See Also:
-
getResource
Description copied from interface:VerticalVmScaling
Gets the actual VmResource
this scaling object is in charge of scaling.- Specified by:
getResource
in interfaceVerticalVmScaling
- Returns:
-
requestUpScalingIfPredicateMatches
Description copied from interface:VerticalVmScaling
Performs the vertical scale if the Vm is overloaded, according to theVerticalVmScaling.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 interfaceVerticalVmScaling
- 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:
-
getResourceClass
Description copied from interface:VerticalVmScaling
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.- Specified by:
getResourceClass
in interfaceVerticalVmScaling
- Returns:
- See Also:
-
getAllocatedResource
public long getAllocatedResource()Description copied from interface:VerticalVmScaling
Gets the current amount allocated to theresource
managed by this scaling object. It is just a shortcut togetVmResourceToScale.getAllocatedResource()
.- Specified by:
getAllocatedResource
in interfaceVerticalVmScaling
- Returns:
- the amount of allocated resource
-
getResourceUsageThresholdFunction
Description copied from interface:VerticalVmScaling
Gets the lower or upper resource utilization thresholdFunction
, depending if the Vm resource is under or overloaded, respectively.- Specified by:
getResourceUsageThresholdFunction
in interfaceVerticalVmScaling
- 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:
-
getResourceAmountToScale
public double getResourceAmountToScale()Gets the absolute amount of the Vm resource which has to be scaled up or down, based on thescaling factor
.If a
ResourceScaling
implementation such asResourceScalingGradual
orResourceScalingInstantaneous
are used, it will rely on thegetScalingFactor()
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 interfaceVerticalVmScaling
- Returns:
- the absolute amount of the Vm resource to scale
- See Also:
-
requestUpScaling
protected boolean requestUpScaling(double time) Description copied from class:VmScalingAbstract
Performs the actual request to scale the Vm up or down, depending on whether it is over or underloaded, respectively. This method is automatically called byVmScaling.requestUpScalingIfPredicateMatches(org.cloudsimplus.listeners.VmHostEventInfo)
when it is verified that the Vm is over or underloaded.- Specified by:
requestUpScaling
in classVmScalingAbstract
- Parameters:
time
- current simulation time- Returns:
- true if the request was actually sent, false otherwise
-
setVm
Description copied from interface:VmScaling
Sets aVm
to this Load Balancer. The broker will call this Load Balancer in order to balance load when its Vm is over utilized.When the VmScaling is assigned to a Vm, the Vm sets itself to the VmScaling object, creating an association between the two objects.
- Specified by:
setVm
in interfaceVmScaling
- Overrides:
setVm
in classVmScalingAbstract
- Parameters:
vm
- the Vm to set
-
allocateResourceForVm
public boolean allocateResourceForVm()Description copied from interface:VerticalVmScaling
Tries to allocate more resources for a VM, if there is availability.- Specified by:
allocateResourceForVm
in interfaceVerticalVmScaling
- Returns:
-
isNotHostResourceAvailable
public boolean isNotHostResourceAvailable()
-