VerticalVmScalingSimple

public class VerticalVmScalingSimple extends VmScalingAbstract implements VerticalVmScaling

A 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.

Author:Manoel Campos da Silva Filho

Constructors

VerticalVmScalingSimple

public VerticalVmScalingSimple(Class<? extends ResourceManageable> resourceClassToScale, double scalingFactor)

Creates a VerticalVmScalingSimple with a ResourceScalingGradual scaling type.

Parameters:
  • 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.

See also: VerticalVmScaling.setResourceScaling(ResourceScaling)

Methods

getAllocatedResource

public long getAllocatedResource()

getLowerThresholdFunction

public Function<Vm, Double> getLowerThresholdFunction()

getResource

public Resource getResource()

getResourceAmountToScale

public double getResourceAmountToScale()

{@inheritDoc}

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.

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.

Returns:{@inheritDoc}

getResourceClass

public Class<? extends ResourceManageable> getResourceClass()

getResourceUsageThresholdFunction

public Function<Vm, Double> getResourceUsageThresholdFunction()

getScalingFactor

public double getScalingFactor()

getUpperThresholdFunction

public Function<Vm, Double> getUpperThresholdFunction()

isVmOverloaded

public boolean isVmOverloaded()

isVmUnderloaded

public boolean isVmUnderloaded()

requestUpScaling

protected boolean requestUpScaling(double time)

requestUpScalingIfPredicateMatches

public final boolean requestUpScalingIfPredicateMatches(VmHostEventInfo evt)

setLowerThresholdFunction

public final VerticalVmScaling setLowerThresholdFunction(Function<Vm, Double> lowerThresholdFunction)

setResourceClass

public final VerticalVmScaling setResourceClass(Class<? extends ResourceManageable> resourceClass)

setResourceScaling

public final VerticalVmScaling setResourceScaling(ResourceScaling resourceScaling)

{@inheritDoc}

This class’s constructors define a ResourceScalingGradual as the default ResourceScaling.

Parameters:
Returns:

{@inheritDoc}

setScalingFactor

public final VerticalVmScaling setScalingFactor(double scalingFactor)

setUpperThresholdFunction

public final VerticalVmScaling setUpperThresholdFunction(Function<Vm, Double> upperThresholdFunction)