Class VmAllocationPolicyFirstFit
java.lang.Object
org.cloudbus.cloudsim.allocationpolicies.VmAllocationPolicyAbstract
org.cloudbus.cloudsim.allocationpolicies.VmAllocationPolicyFirstFit
- All Implemented Interfaces:
VmAllocationPolicy
public class VmAllocationPolicyFirstFit
extends VmAllocationPolicyAbstract
implements VmAllocationPolicy
A First Fit VM allocation policy
which finds the first Host having suitable resources to place a given VM.
This is a high time-efficient policy with a best-case complexity O(1)
and a worst-case complexity O(N), where N is the number of Hosts.
Additionally, such a policy is resource efficient, because it performs
server consolidation by trying to place the maximum number of VMs
into the same Host in order to increase Host's resource usage.
NOTES:
- This policy doesn't perform optimization of VM allocation by means of VM migration.
- It has a low computational complexity but may return and inactive Host that will be activated, while there may be active Hosts suitable for the VM.
- Since:
- CloudSim Plus 1.0.0
- Author:
- Manoel Campos da Silva Filho
- See Also:
-
Field Summary
Fields inherited from interface org.cloudbus.cloudsim.allocationpolicies.VmAllocationPolicy
DEF_HOST_COUNT_PARALLEL_SEARCH, LOGGER, NULL
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionProvides the default implementation of the policy to find a suitable Host for a given VM.protected int
Gets the index of the last host where a VM was placed.protected void
Increment the index to move to the next Host.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
allocateHostForVm, allocateHostForVm, allocateHostForVm, deallocateHostForVm, findHostForVm, getDatacenter, getHostCountForParallelSearch, getHostList, getOptimizedAllocationMap, isParallelHostSearchEnabled, isVmMigrationSupported, scaleVmVertically, setDatacenter, setFindHostForVmFunction, setHostCountForParallelSearch
-
Constructor Details
-
VmAllocationPolicyFirstFit
public VmAllocationPolicyFirstFit()
-
-
Method Details
-
defaultFindHostForVm
Description copied from class:VmAllocationPolicyAbstract
Provides the default implementation of the policy to find a suitable Host for a given VM.- 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 no suitable Host was found - See Also:
-
getLastHostIndex
protected int getLastHostIndex()Gets the index of the last host where a VM was placed. -
incLastHostIndex
protected void incLastHostIndex()Increment the index to move to the next Host. If the end of the Host list is reached, starts from the beginning.
-