VmAllocationPolicyBestFit

public class VmAllocationPolicyBestFit extends VmAllocationPolicyAbstract

A VmAllocationPolicy implementation that chooses, as the host for a VM, that one with the most PEs in use. It is therefore a Best Fit policy, allocating each VM into the host with the least available PEs that are enough for the VM.

NOTE: This policy doesn’t perform optimization of VM allocation by means of VM migration.

Author:Manoel Campos da Silva Filho

Constructors

VmAllocationPolicyBestFit

public VmAllocationPolicyBestFit()

Instantiates a VmAllocationPolicyBestFit.

VmAllocationPolicyBestFit

public VmAllocationPolicyBestFit(BiFunction<VmAllocationPolicy, Vm, Optional<Host>> findHostForVmFunction)

Instantiates a VmAllocationPolicyBestFit, changing the Function to select a Host for a Vm in order to define a different policy.

Parameters:
  • findHostForVmFunction – a Function to select a Host for a given Vm.

See also: VmAllocationPolicy.setFindHostForVmFunction(BiFunction)

Methods

findHostForVm

public Optional<Host> findHostForVm(Vm vm)

Gets the first suitable host from the getHostList() that has the most number of used PEs (i.e, lower free PEs).

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