Class VmAllocationPolicyBestFit
java.lang.Object
org.cloudbus.cloudsim.allocationpolicies.VmAllocationPolicyAbstract
org.cloudbus.cloudsim.allocationpolicies.VmAllocationPolicyBestFit
- All Implemented Interfaces:
VmAllocationPolicy
public class VmAllocationPolicyBestFit extends VmAllocationPolicyAbstract
A Best Fit VmAllocationPolicy implementation that chooses, as
the host for a VM, the one with the most number of PEs in use,
which has enough free PEs for a VM.
This is a really computationally complex policy since the worst-case complexity to allocate a Host for a VM is O(N), where N is the number of Hosts. Such an implementation is not appropriate for large scale scenarios.
NOTE: This policy doesn't perform optimization of VM allocation by means of VM migration.
- Since:
- CloudSim Plus 3.0.1
- Author:
- Manoel Campos da Silva Filho
- See Also:
VmAllocationPolicyFirstFit
,VmAllocationPolicyWorstFit
-
Field Summary
Fields inherited from interface org.cloudbus.cloudsim.allocationpolicies.VmAllocationPolicy
DEF_HOST_COUNT_FOR_PARALLEL_SEARCH, LOGGER, NULL
-
Constructor Summary
Constructors Constructor Description VmAllocationPolicyBestFit()
-
Method Summary
Modifier and Type Method Description protected Optional<Host>
defaultFindHostForVm(Vm vm)
Gets the first suitable host from theVmAllocationPolicyAbstract.getHostList()
that has the most number of PEs in use (i.e.Methods inherited from class org.cloudbus.cloudsim.allocationpolicies.VmAllocationPolicyAbstract
allocateHostForVm, allocateHostForVm, allocateHostForVm, deallocateHostForVm, findHostForVm, getDatacenter, getHostCountForParallelSearch, getHostList, getOptimizedAllocationMap, isVmMigrationSupported, scaleVmVertically, setDatacenter, setFindHostForVmFunction, setHostCountForParallelSearch
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.cloudbus.cloudsim.allocationpolicies.VmAllocationPolicy
isParallelHostSearchEnabled
-
Constructor Details
-
VmAllocationPolicyBestFit
public VmAllocationPolicyBestFit()
-
-
Method Details
-
defaultFindHostForVm
Gets the first suitable host from theVmAllocationPolicyAbstract.getHostList()
that has the most number of PEs in use (i.e. the least number of free PEs).- Specified by:
defaultFindHostForVm
in classVmAllocationPolicyAbstract
- Parameters:
vm
- the VM to find a suitable Host to- Returns:
- an
Optional
containing a suitable Host to place the VM or an emptyOptional
if not found - See Also:
VmAllocationPolicyAbstract.setFindHostForVmFunction(BiFunction)
-