VmAllocationPolicyMigrationAbstract

public abstract class VmAllocationPolicyMigrationAbstract extends VmAllocationPolicyAbstract implements VmAllocationPolicyMigration

An abstract VM allocation policy that dynamically optimizes the VM allocation (placement) using migration. It’s a Best Fit policy which selects the Host with most efficient power usage to place a given VM. Such a behaviour can be overridden by sub-classes.

If you are using any algorithms, policies or workload included in the power package please cite the following paper:

Author:Anton Beloglazov, Manoel Campos da Silva Filho

Fields

DEF_UNDER_UTILIZATION_THRESHOLD

public static final double DEF_UNDER_UTILIZATION_THRESHOLD

Constructors

VmAllocationPolicyMigrationAbstract

public VmAllocationPolicyMigrationAbstract(VmSelectionPolicy vmSelectionPolicy)

Creates a VmAllocationPolicy. It uses a default under utilization threshold.

Parameters:
  • vmSelectionPolicy – the policy that defines how VMs are selected for migration

VmAllocationPolicyMigrationAbstract

public VmAllocationPolicyMigrationAbstract(VmSelectionPolicy vmSelectionPolicy, BiFunction<VmAllocationPolicy, Vm, Optional<Host>> findHostForVmFunction)

Creates a new VmAllocationPolicy, changing the Function to select a Host for a Vm. It uses a default under utilization threshold.

Parameters:
  • vmSelectionPolicy – the policy that defines how VMs are selected for migration
  • findHostForVmFunction – a Function to select a Host for a given Vm. Passing null makes the Function to be set as the default findHostForVm(Vm).

See also: VmAllocationPolicy.setFindHostForVmFunction(java.util.function.BiFunction), .setUnderUtilizationThreshold(double)

Methods

defaultFindHostForVm

protected Optional<Host> defaultFindHostForVm(Vm vm)

findHostForVmInternal

protected Optional<Host> findHostForVmInternal(Vm vm, Stream<Host> hostStream)

Applies additional filters to the Hosts Stream and performs the actual Host selection. This method is a Stream’s final operation, that it, it closes the Stream and returns an Optional value.

This method can be overridden by sub-classes to change the method used to select the Host for the given VM.

Parameters:
  • vm – the VM to find a Host to be placed into
  • hostStream – a Stream containing the Hosts after passing the basic filtering
Returns:

an Optional containing a suitable Host to place the VM or an empty Optional if not found

See also: .findHostForVm(Vm,Set), .additionalHostFilters(Vm,Stream)

getHostCpuUsageArray

protected double[] getHostCpuUsageArray(Host host)

Gets all CPU utilization values from the Host.getUtilizationHistorySum() as an array.

Parameters:
  • host – the Host to get the CPU utilization values
Returns:

the utilization values array

getMaxUtilizationAfterAllocation

protected double getMaxUtilizationAfterAllocation(Host host, Vm vm)

Gets the max power consumption of a host after placement of a candidate VM. The VM is not in fact placed at the host. We assume that load is balanced between PEs. The only restriction is: VM’s max MIPS less than PE’s MIPS

Parameters:
  • host – the host
  • vm – the vm
Returns:

the power after allocation

getOptimizedAllocationMap

public Map<Vm, Host> getOptimizedAllocationMap(List<? extends Vm> vmList)

getPowerAfterAllocation

protected double getPowerAfterAllocation(Host host, Vm vm)

Gets the power consumption of a host after the supposed placement of a candidate VM. The VM is not in fact placed at the host.

Parameters:
  • host – the host to check the power consumption
  • vm – the candidate vm
Returns:

the host power consumption after the supposed VM placement or 0 if the power consumption could not be determined

getPowerDifferenceAfterAllocation

protected double getPowerDifferenceAfterAllocation(Host host, Vm vm)

Gets the power consumption different after the supposed placement of a VM into a given Host and the original Host power consumption.

Parameters:
  • host – the host to check the power consumption
  • vm – the candidate vm
Returns:

the host power consumption different after the supposed VM placement or 0 if the power consumption could not be determined

getSwitchedOffHosts

protected List<Host> getSwitchedOffHosts()

Gets the switched off hosts.

Returns:the switched off hosts

getUnderUtilizationThreshold

public double getUnderUtilizationThreshold()

getUtilizationOfCpuMips

protected double getUtilizationOfCpuMips(Host host)

Gets the utilization of the CPU in MIPS for the current potentially allocated VMs.

Parameters:
  • host – the host
Returns:

the utilization of the CPU in MIPS

getVmSelectionPolicy

public VmSelectionPolicy getVmSelectionPolicy()

getVmsToMigrateFromUnderUtilizedHost

protected List<? extends Vm> getVmsToMigrateFromUnderUtilizedHost(Host host)

Gets the VMs to migrate from under utilized host.

Parameters:
  • host – the host
Returns:

the vms to migrate from under utilized host

isHostOverloaded

public boolean isHostOverloaded(Host host)

{@inheritDoc} It’s based on current CPU usage.

Parameters:
Returns:

{@inheritDoc}

isHostUnderloaded

public boolean isHostUnderloaded(Host host)

Checks if a host is under utilized, based on current CPU usage.

Parameters:
  • host – the host
Returns:

true, if the host is under utilized; false otherwise

notAllVmsAreMigratingOut

protected boolean notAllVmsAreMigratingOut(Host host)

Checks if all VMs of a Host are NOT migrating out. In this case, the given Host will not be selected as an underloaded Host at the current moment. That is: not all VMs are migrating out if at least one VM isn’t in migration process.

Parameters:
  • host – the host to check
Returns:

true if at least one VM isn’t migrating, false if all VMs are migrating

setUnderUtilizationThreshold

public void setUnderUtilizationThreshold(double underUtilizationThreshold)

setVmSelectionPolicy

public final void setVmSelectionPolicy(VmSelectionPolicy vmSelectionPolicy)