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

Constructors

VmAllocationPolicyMigrationAbstract

public VmAllocationPolicyMigrationAbstract(PowerVmSelectionPolicy vmSelectionPolicy)

Creates a VmAllocationPolicyMigrationAbstract.

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

VmAllocationPolicyMigrationAbstract

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

Creates a new VmAllocationPolicy, changing the Function to select a Host for a Vm.

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)

Methods

addHistoryEntryIfAbsent

protected void addHistoryEntryIfAbsent(Host host, double metric)

Adds an entry for each history map of a host if it doesn’t contain an entry for the current simulation time.

Parameters:
  • host – the host to add metric history entries
  • metric – the metric to be added to the metric history map

findHostForVm

public Optional<Host> findHostForVm(Vm vm)

findHostForVm

public Optional<Host> findHostForVm(Vm vm, Set<? extends Host> excludedHosts)

Finds a Host that has enough resources to place a given VM and that will not be overloaded after the placement. The selected Host will be that one with most efficient power usage for the given VM.

This method performs the basic filtering and delegates additional ones and the final selection of the Host to other method.

Parameters:
  • vm – the VM
  • excludedHosts – the excluded hosts
Returns:

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

See also: .findHostForVmInternal(Vm,Stream)

findHostForVm

public Optional<Host> findHostForVm(Vm vm, Set<? extends Host> excludedHosts, Predicate<Host> predicate)

Finds a Host that has enough resources to place a given VM and that will not be overloaded after the placement. The selected Host will be that one with most efficient power usage for the given VM.

This method performs the basic filtering and delegates additional ones and the final selection of the Host to other method.

Parameters:
  • vm – the VM
  • excludedHosts – the excluded hosts
  • predicate – an additional Predicate to be used to filter the Host to place the VM
Returns:

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

See also: .findHostForVmInternal(Vm,Stream)

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)

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 < PE’s MIPS

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

the power after allocation

getMetricHistory

public Map<Host, List<Double>> getMetricHistory()

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

getPowerAfterAllocationDifference

protected double getPowerAfterAllocationDifference(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

getTimeHistory

public Map<Host, List<Double>> getTimeHistory()

getUnderUtilizationThreshold

public double getUnderUtilizationThreshold()

getUtilizationHistory

public Map<Host, List<Double>> getUtilizationHistory()

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

protected PowerVmSelectionPolicy getVmSelectionPolicy()

Gets the vm selection policy.

Returns:the vm selection policy

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

protected final void setVmSelectionPolicy(PowerVmSelectionPolicy vmSelectionPolicy)

Sets the vm selection policy.

Parameters:
  • vmSelectionPolicy – the new vm selection policy