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



public VmAllocationPolicyBestFit()

Instantiates a 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.

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

See also: VmAllocationPolicy.setFindHostForVmFunction(BiFunction)



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