public class VerticalVmScalingSimple extends VmScalingAbstract implements VerticalVmScaling
VerticalVmScaling
implementation which allows a DatacenterBroker
to perform on demand up or down scaling for some Vm
resource, such as Ram
, Pe
or Bandwidth
.
For each resource that is required to be scaled, a distinct VerticalVmScaling
instance must be assigned to the VM to be scaled.
NULL
Constructor and Description |
---|
VerticalVmScalingSimple(Class<? extends ResourceManageable> resourceClassToScale,
double scalingFactor)
Creates a VerticalVmScalingSimple with a
ResourceScalingGradual scaling type. |
Modifier and Type | Method and Description |
---|---|
long |
getAllocatedResource()
Gets the current amount allocated to the
resource managed by this scaling object. |
Function<Vm,Double> |
getLowerThresholdFunction()
|
Resource |
getResource()
Gets the actual Vm
Resource 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 the
scaling 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 threshold
Function ,
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 the
VerticalVmScaling.getUpperThresholdFunction() . |
boolean |
isVmUnderloaded()
Checks if the Vm is underloaded or not, based on the
VerticalVmScaling.getLowerThresholdFunction() . |
protected boolean |
requestUpScaling(double time)
Performs the actual request to scale the Vm up or down,
depending if it is over or underloaded, respectively.
|
boolean |
requestUpScalingIfPredicateMatches(VmHostEventInfo evt)
Performs the vertical scale if the Vm is overloaded, according to the
VerticalVmScaling.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. |
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 the
ResourceScaling 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)
|
getVm, isTimeToCheckPredicate, setLastProcessingTime, setVm
public VerticalVmScalingSimple(Class<? extends ResourceManageable> resourceClassToScale, double scalingFactor)
ResourceScalingGradual
scaling type.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.VerticalVmScaling.setResourceScaling(ResourceScaling)
public Function<Vm,Double> getUpperThresholdFunction()
VerticalVmScaling
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.
getUpperThresholdFunction
in interface VerticalVmScaling
VerticalVmScaling.setUpperThresholdFunction(Function)
public final VerticalVmScaling setUpperThresholdFunction(Function<Vm,Double> upperThresholdFunction)
VerticalVmScaling
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.
setUpperThresholdFunction
in interface VerticalVmScaling
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
.public Function<Vm,Double> getLowerThresholdFunction()
VerticalVmScaling
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.
getLowerThresholdFunction
in interface VerticalVmScaling
VerticalVmScaling.setLowerThresholdFunction(Function)
public final VerticalVmScaling setLowerThresholdFunction(Function<Vm,Double> lowerThresholdFunction)
VerticalVmScaling
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.
setLowerThresholdFunction
in interface VerticalVmScaling
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
.public final VerticalVmScaling setResourceScaling(ResourceScaling resourceScaling)
ResourceScaling
that defines how the resource has to be resized.
This class's constructors define a ResourceScalingGradual
as the default ResourceScaling
.
setResourceScaling
in interface VerticalVmScaling
resourceScaling
- the ResourceScaling
to setpublic long getAllocatedResource()
VerticalVmScaling
resource
managed by this scaling object.
It is just a shortcut to getVmResourceToScale.getAllocatedResource()
.getAllocatedResource
in interface VerticalVmScaling
public Class<? extends ResourceManageable> getResourceClass()
VerticalVmScaling
Ram
.class, Bandwidth
.class or Pe
.class.getResourceClass
in interface VerticalVmScaling
VerticalVmScaling.getResource()
public final VerticalVmScaling setResourceClass(Class<? extends ResourceManageable> resourceClass)
VerticalVmScaling
Ram
.class, Bandwidth
.class or Pe
.class.setResourceClass
in interface VerticalVmScaling
resourceClass
- the resource class to setpublic double getScalingFactor()
VerticalVmScaling
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.
getScalingFactor
in interface VerticalVmScaling
Pe
scaling)
or percentage (for scaling other resources)VerticalVmScaling.getUpperThresholdFunction()
public final boolean requestUpScalingIfPredicateMatches(VmHostEventInfo evt)
VerticalVmScaling
VerticalVmScaling.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.
requestUpScalingIfPredicateMatches
in interface VerticalVmScaling
requestUpScalingIfPredicateMatches
in interface VmScaling
evt
- current simulation timeVerticalVmScaling.getScalingFactor()
public boolean isVmUnderloaded()
VerticalVmScaling
VerticalVmScaling.getLowerThresholdFunction()
.isVmUnderloaded
in interface VerticalVmScaling
public boolean isVmOverloaded()
VerticalVmScaling
VerticalVmScaling.getUpperThresholdFunction()
.isVmOverloaded
in interface VerticalVmScaling
public Resource getResource()
VerticalVmScaling
Resource
this scaling object is in charge of scaling.
This resource is defined after calling the VerticalVmScaling.setResourceClass(Class)
.getResource
in interface VerticalVmScaling
public double getResourceAmountToScale()
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.
getResourceAmountToScale
in interface VerticalVmScaling
VerticalVmScaling.getResourceClass()
public Function<Vm,Double> getResourceUsageThresholdFunction()
VerticalVmScaling
Function
,
depending if the Vm resource is under or overloaded, respectively.getResourceUsageThresholdFunction
in interface VerticalVmScaling
VerticalVmScaling.getLowerThresholdFunction()
,
VerticalVmScaling.getUpperThresholdFunction()
public final VerticalVmScaling setScalingFactor(double scalingFactor)
VerticalVmScaling
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.
setScalingFactor
in interface VerticalVmScaling
scalingFactor
- the scaling factor to set which may be an absolute value (for Pe
scaling)
or percentage (for scaling other resources)VerticalVmScaling.getUpperThresholdFunction()
protected boolean requestUpScaling(double time)
VmScalingAbstract
VmScaling.requestUpScalingIfPredicateMatches(org.cloudsimplus.listeners.VmHostEventInfo)
when it is verified that the Vm is over or underloaded.requestUpScaling
in class VmScalingAbstract
time
- current simulation timeCopyright © 2015–2019 Systems, Security and Image Communication Lab - Instituto de Telecomunica����es (IT) - Universidade da Beira Interior (UBI) - Instituto Federal de Educa����o Ci��ncia e Tecnologia do Tocantins (IFTO). All rights reserved.