Class VmAllocationPolicyMigrationAbstract
java.lang.Object
org.cloudsimplus.allocationpolicies.VmAllocationPolicyAbstract
org.cloudsimplus.allocationpolicies.migration.VmAllocationPolicyMigrationAbstract
- All Implemented Interfaces:
VmAllocationPolicyMigration,VmAllocationPolicy
- Direct Known Subclasses:
VmAllocationPolicyMigrationDynamicUpperThresholdFirstFit,VmAllocationPolicyMigrationStaticThreshold
public abstract class VmAllocationPolicyMigrationAbstract
extends VmAllocationPolicyAbstract
implements VmAllocationPolicyMigration
An abstract VM allocation policy that dynamically optimizes the
VM allocation (placement) using migration.
It's a Best Fit policy that selects the Host with most efficient power usage to place a given VM.
Such a behaviour can be overridden by subclasses.
Any VmAllocationPolicyMigration implementation must be based on this class.
- Since:
- CloudSim Toolkit 3.0
- Author:
- Anton Beloglazov, Manoel Campos da Silva Filho
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleDefault CPU utilization percentage ([0..1]) that indicates a Host is underloaded.Fields inherited from interface org.cloudsimplus.allocationpolicies.VmAllocationPolicy
DEF_HOST_COUNT_PARALLEL_SEARCH, LOGGER, NULLFields inherited from interface org.cloudsimplus.allocationpolicies.migration.VmAllocationPolicyMigration
NULL -
Constructor Summary
ConstructorsConstructorDescriptionVmAllocationPolicyMigrationAbstract(VmSelectionPolicy vmSelectionPolicy) Creates a VmAllocationPolicy using adefault under utilization threshold.VmAllocationPolicyMigrationAbstract(VmSelectionPolicy vmSelectionPolicy, BiFunction<VmAllocationPolicy, Vm, Optional<Host>> findHostForVmFunction) Creates a new VmAllocationPolicy, changing theFunctionto select a Host for a Vm. -
Method Summary
Modifier and TypeMethodDescriptionProvides the default implementation of the policy to find a suitable Host for a given VM.findHostForVmInternal(Vm vm, Predicate<Host> predicate) Applies additional filters to the Hosts Stream and performs the actual Host selection.protected doublegetMaxUtilizationAfterAllocation(Host host, Vm vm) Gets the max power consumption of a host after placement of a candidate VM.getOptimizedAllocationMap(List<? extends Vm> vmList) Gets a map of optimized allocation for VMs, according to current utilization and Hosts under and overloaded conditions.protected doublegetPowerAfterAllocation(Host host, Vm vm) Returns the power consumption of a host after the supposed placement of a candidate VM, or 0 if the power consumption could not be determined.Returns hosts that are switched off.protected doublegetUtilizationOfCpuMips(Host host) Returns the utilization of the CPU in MIPS for the current potentially allocated VMs in a given host.Gets the VMs to migrate from an under-utilized host.booleanisOverloaded(Host host) Checks if a host is currently over-utilized, according to the conditions defined by the Allocation Policy.booleanisUnderloaded(Host host) Checks if a host is under-utilized, based on current CPU usage.final booleanChecks if VM migrations are supported by this VmAllocationPolicy.protected doublepowerDiffAfterAllocation(Host host, Vm vm) Gets the difference between the power consumption after and before the supposed placement of a VM into a given Host.setDatacenter(Datacenter datacenter) Sets the Datacenter associated to the VmAllocationPolicyvoidsetUnderUtilizationThreshold(double underUtilizationThreshold) Sets the percentage of total Host CPU utilization to indicate when a host is under used, so that its VMs can be migrated elsewhere.Methods inherited from class org.cloudsimplus.allocationpolicies.VmAllocationPolicyAbstract
allocateHostForVm, allocateHostForVm, allocateHostForVm, allocateHostForVmInternal, deallocateHostForVm, findHostForVm, getHostList, scaleVmVertically, setFindHostForVmFunctionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.cloudsimplus.allocationpolicies.VmAllocationPolicy
allocateHostForVm, allocateHostForVm, allocateHostForVm, deallocateHostForVm, findHostForVm, getDatacenter, getHostCountForParallelSearch, getHostList, isParallelHostSearchEnabled, scaleVmVertically, setFindHostForVmFunction, setHostCountForParallelSearchMethods inherited from interface org.cloudsimplus.allocationpolicies.migration.VmAllocationPolicyMigration
getOverUtilizationThreshold, getUnderUtilizationThreshold, getVmSelectionPolicy, isOverloaded, isUnderloaded, isUnderOrOverloaded, setVmSelectionPolicy
-
Field Details
-
DEF_UNDER_UTILIZATION_THRESHOLD
public static final double DEF_UNDER_UTILIZATION_THRESHOLDDefault CPU utilization percentage ([0..1]) that indicates a Host is underloaded.- See Also:
-
-
Constructor Details
-
VmAllocationPolicyMigrationAbstract
Creates a VmAllocationPolicy using adefault under utilization threshold.- Parameters:
vmSelectionPolicy- thepolicythat defines how VMs are selected for migration
-
VmAllocationPolicyMigrationAbstract
public VmAllocationPolicyMigrationAbstract(VmSelectionPolicy vmSelectionPolicy, BiFunction<VmAllocationPolicy, Vm, Optional<Host>> findHostForVmFunction) Creates a new VmAllocationPolicy, changing theFunctionto select a Host for a Vm. It uses adefault under utilization threshold.- Parameters:
vmSelectionPolicy- thepolicythat defines how VMs are selected for migrationfindHostForVmFunction- aFunctionto select a Host for a given Vm. Passing null makes the Function to be set as the defaultVmAllocationPolicyAbstract.findHostForVm(Vm).- See Also:
-
-
Method Details
-
setDatacenter
Description copied from interface:VmAllocationPolicySets the Datacenter associated to the VmAllocationPolicy- Specified by:
setDatacenterin interfaceVmAllocationPolicy- Parameters:
datacenter- the Datacenter to set- Returns:
- this VmAllocationPolicy
-
getOptimizedAllocationMap
Description copied from interface:VmAllocationPolicyGets 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.- Specified by:
getOptimizedAllocationMapin interfaceVmAllocationPolicy- Overrides:
getOptimizedAllocationMapin classVmAllocationPolicyAbstract- 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
-
powerDiffAfterAllocation
Gets the difference between the power consumption after and before the supposed placement of a VM into a given Host.- Parameters:
host- the host to check the power consumptionvm- the candidate vm- Returns:
- the host power consumption difference (in Watts) after the supposed VM placement; or 0 if the power consumption could not be determined
-
isOverloaded
Checks if a host is currently over-utilized, according to the conditions defined by the Allocation Policy. It's based on the current CPU usage.- Specified by:
isOverloadedin interfaceVmAllocationPolicyMigration- Parameters:
host- the host to check- Returns:
- true if the host is overloaded, false otherwise
-
isUnderloaded
Checks if a host is under-utilized, based on current CPU usage.- Specified by:
isUnderloadedin interfaceVmAllocationPolicyMigration- Parameters:
host- the host to check- Returns:
- true, if the host is underloaded; false otherwise
-
defaultFindHostForVm
Description copied from class:VmAllocationPolicyAbstractProvides the default implementation of the policy to find a suitable Host for a given VM.- Specified by:
defaultFindHostForVmin classVmAllocationPolicyAbstract- Parameters:
vm- the VM to find a suitable Host to- Returns:
- an
Optionalcontaining a suitable Host to place the VM; or an emptyOptionalif no suitable Host was found - See Also:
-
findHostForVmInternal
Applies additional filters to the Hosts Stream and performs the actual Host selection. It can be overridden by subclasses to change the way to select the Host for a given VM. -
getVmsToMigrateFromUnderUtilizedHost
-
getSwitchedOffHosts
-
getPowerAfterAllocation
Returns the power consumption of a host after the supposed placement of a candidate VM, or 0 if the power consumption could not be determined. The VM is not in fact placed at the host.- Parameters:
host- the host to check the power consumptionvm- the candidate vm- Returns:
- the power consumption of a host after the supposed placement of a candidate VM, or 0 if the power consumption could not be determined
-
getMaxUtilizationAfterAllocation
Gets the max power consumption of a host after placement of a candidate VM. The VM is not in fact placed at the host. We assume that load is balanced between PEs. The only restriction is: VM's max MIPS less than PE's MIPS- Parameters:
host- the hostvm- the vm- Returns:
- the power after allocation
-
getUtilizationOfCpuMips
Returns the utilization of the CPU in MIPS for the current potentially allocated VMs in a given host.- Parameters:
host- the host to get the utilization of CPU MIPS- Returns:
- the utilization of the CPU in MIPS for the current potentially allocated VMs in a given host
-
setUnderUtilizationThreshold
public void setUnderUtilizationThreshold(double underUtilizationThreshold) Description copied from interface:VmAllocationPolicyMigrationSets the percentage of total Host CPU utilization to indicate when a host is under used, so that its VMs can be migrated elsewhere.- Specified by:
setUnderUtilizationThresholdin interfaceVmAllocationPolicyMigration- Parameters:
underUtilizationThreshold- the under utilization threshold (a percentage value from 0 to 1)
-
isVmMigrationSupported
public final boolean isVmMigrationSupported()Description copied from interface:VmAllocationPolicyChecks 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.- Specified by:
isVmMigrationSupportedin interfaceVmAllocationPolicy- Overrides:
isVmMigrationSupportedin classVmAllocationPolicyAbstract- Returns:
- true if VM migration is supported; false otherwise.
- See Also:
-