Interface VmAllocationPolicy
- All Known Subinterfaces:
VmAllocationPolicyMigration,VmAllocationPolicyMigrationDynamicUpperThreshold
- All Known Implementing Classes:
VmAllocationPolicyAbstract,VmAllocationPolicyBatchPlacementUnderloadedHosts,VmAllocationPolicyBestFit,VmAllocationPolicyFirstFit,VmAllocationPolicyMigrationAbstract,VmAllocationPolicyMigrationBestFitStaticThreshold,VmAllocationPolicyMigrationDynamicUpperThresholdFirstFit,VmAllocationPolicyMigrationFirstFitStaticThreshold,VmAllocationPolicyMigrationStaticThreshold,VmAllocationPolicyMigrationWorstFitStaticThreshold,VmAllocationPolicyRandom,VmAllocationPolicyRoundRobin,VmAllocationPolicySimple
public interface VmAllocationPolicy
An interface to be implemented by each class that represents a policy, used by
a
Datacenter, to choose a Host to place or migrate a
given Vm or VmGroup.
The VmAllocationPolicy uses Java 8+ Functional Programming
to enable changing, at runtime, the policy used
to select a Host for a given Vm or VmGroup.
- Since:
- CloudSim Plus 1.0
- Author:
- Rodrigo N. Calheiros, Anton Beloglazov, Manoel Campos da Silva Filho
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault minimum number of Hosts to start using parallel search.static final org.slf4j.Loggerstatic final VmAllocationPolicyA property that implements the Null Object Design Pattern forVmAllocationPolicyobjects. -
Method Summary
Modifier and TypeMethodDescriptionallocateHostForVm(List<Vm> vmList) allocateHostForVm(Vm vm) allocateHostForVm(Vm vm, Host host) voidReleases the host used by a VM.findHostForVm(Vm vm) Finds a suitable Host that has enough resources to place a given VM.Returns the Datacenter associated to the VmAllocationPolicy.intReturns the minimum number of Hosts to start using parallel search.Gets the list of Hosts available in theDatacenterlinked to this VmAllocationPolicy, which will be used to place VMs.getOptimizedAllocationMap(List<? extends Vm> vmList) Gets a map of optimized allocation for VMs, according to current utilization and Hosts under and overloaded conditions.default booleanChecks if Host's parallel search is enabled or not.booleanChecks if VM migrations are supported by this VmAllocationPolicy.booleanscaleVmVertically(VerticalVmScaling scaling) Try to scale some Vm's resource vertically up or down, respectively if: the Vm is overloaded and the Host where the Vm is placed has enough capacity the Vm is underloaded The resource to be scaled is defined by the givenVerticalVmScalingobject.setDatacenter(Datacenter datacenter) Sets the Datacenter associated to the VmAllocationPolicysetFindHostForVmFunction(BiFunction<VmAllocationPolicy, Vm, Optional<Host>> findHostForVmFunction) Sets aBiFunctionthat selects a Host for a given Vm.setHostCountForParallelSearch(int hostCountForParallelSearch) Sets the minimum number of Hosts to start using parallel search.
-
Field Details
-
LOGGER
static final org.slf4j.Logger LOGGER -
DEF_HOST_COUNT_PARALLEL_SEARCH
static final int DEF_HOST_COUNT_PARALLEL_SEARCHDefault minimum number of Hosts to start using parallel search.- See Also:
-
NULL
A property that implements the Null Object Design Pattern forVmAllocationPolicyobjects.
-
-
Method Details
-
getDatacenter
Datacenter getDatacenter()Returns the Datacenter associated to the VmAllocationPolicy.- Returns:
- the Datacenter associated to the VmAllocationPolicy
-
setDatacenter
Sets the Datacenter associated to the VmAllocationPolicy- Parameters:
datacenter- the Datacenter to set- Returns:
- this VmAllocationPolicy
-
allocateHostForVm
- Parameters:
vm- theVmorVmGroupto allocate a host to- Returns:
- a
HostSuitabilityto indicate if the Vm was placed into the host or not (if the Host doesn't have enough resources to allocate the Vm) - See Also:
-
allocateHostForVm
Tries to allocate a host for a eachVmorVmGroupinto a given List. The method should define how it will find asuitable Hostfor each Vm and then callallocateHostForVm(Vm, Host)to actually create the VM inside the selected Host.- Parameters:
vmList- the List ofVms orVmGroups to allocate a host to- Returns:
- a Set of
HostSuitabilityto indicate if a Vm was placed into the host or not, containing a HostSuitability object for the last Host where each VM was tried to be created; or an empty set if the Datacenter has no hosts. - See Also:
-
allocateHostForVm
- Parameters:
vm- theVmorVmGroupto allocate a host tohost- the host to allocate to the givenVmorVmGroup- Returns:
- a
HostSuitabilityto indicate if the Vm was placed into the host or not (if the Host doesn't have enough resources to allocate the Vm) - See Also:
-
scaleVmVertically
Try to scale some Vm's resource vertically up or down, respectively if:- the Vm is overloaded and the Host where the Vm is placed has enough capacity
- the Vm is underloaded
VerticalVmScalingobject.- Parameters:
scaling- theVerticalVmScalingobject with information of which resource is being requested to be scaled- Returns:
- true if the requested resource was scaled, false otherwise
-
deallocateHostForVm
Releases the host used by a VM.- Parameters:
vm- the vm to get its host released
-
setFindHostForVmFunction
VmAllocationPolicy setFindHostForVmFunction(BiFunction<VmAllocationPolicy, Vm, Optional<Host>> findHostForVmFunction) Sets aBiFunctionthat selects a Host for a given Vm. This Function receives the current VmAllocationPolicy and theVmrequesting to be placed. It then returns anOptional<Host>that may contain a suitable Host for that Vm or not.If no Function is set, the default VM selection method provided by implementing classes will be used instead.
- Parameters:
findHostForVmFunction- theBiFunctionto set
-
getHostList
Gets the list of Hosts available in theDatacenterlinked to this VmAllocationPolicy, which will be used to place VMs.- Type Parameters:
T- the host type- Returns:
- datacenter the host list
-
getOptimizedAllocationMap
Gets a map of optimized allocation for VMs, according to current utilization and Hosts under and overloaded conditions. The conditions that will make a new VM placement map to be proposed and returned is defined by each implementing class.- Parameters:
vmList- the list of VMs to be reallocated- Returns:
- the new vm placement map, where each key is a VM and each value is the host where such a Vm has to be placed
-
findHostForVm
Finds a suitable Host that has enough resources to place a given VM. Internally it may use a default implementation or oneset in runtime. -
isVmMigrationSupported
boolean isVmMigrationSupported()Checks if VM migrations are supported by this VmAllocationPolicy. Realize that even if the policy allows VM migration, such operations can be dynamically enabled/disabled by the Datacenter.- Returns:
- true if VM migration is supported; false otherwise.
- See Also:
-
isParallelHostSearchEnabled
default boolean isParallelHostSearchEnabled()Checks if Host's parallel search is enabled or not.- Returns:
- true if host search for VM placement must be performed in parallel; false if it's to be performed sequentially
- See Also:
-
getHostCountForParallelSearch
int getHostCountForParallelSearch()Returns the minimum number of Hosts to start using parallel search.- Returns:
- the minimum number of Hosts to start using parallel search
- See Also:
-
setHostCountForParallelSearch
Sets the minimum number of Hosts to start using parallel search.- Parameters:
hostCountForParallelSearch- the value to set (useInteger.MAX_VALUEto disable parallel search)- Returns:
- this VmAllocationPolicy
-