Class VmAllocationPolicyMigrationAbstract
java.lang.Object
org.cloudbus.cloudsim.allocationpolicies.VmAllocationPolicyAbstract
org.cloudbus.cloudsim.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 which selects the Host with most efficient power usage to place a given VM.
Such a behaviour can be overridden by sub-classes.
If you are using any algorithms, policies or workload included in the power package please cite the following paper:
- Since:
- CloudSim Toolkit 3.0
- Author:
- Anton Beloglazov, Manoel Campos da Silva Filho
-
Field Summary
Fields inherited from interface org.cloudbus.cloudsim.allocationpolicies.VmAllocationPolicy
DEF_HOST_COUNT_PARALLEL_SEARCH, LOGGER, NULL
Fields inherited from interface org.cloudbus.cloudsim.allocationpolicies.migration.VmAllocationPolicyMigration
NULL
-
Constructor Summary
ConstructorDescriptionVmAllocationPolicyMigrationAbstract
(VmSelectionPolicy vmSelectionPolicy) Creates a VmAllocationPolicy.VmAllocationPolicyMigrationAbstract
(VmSelectionPolicy vmSelectionPolicy, BiFunction<VmAllocationPolicy, Vm, Optional<Host>> findHostForVmFunction) Creates a new VmAllocationPolicy, changing theFunction
to select a Host for a Vm. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks if there are some Hosts overloaded.boolean
Checks if there are some Hosts underloaded.Provides 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 double
getMaxUtilizationAfterAllocation
(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 double
getPowerAfterAllocation
(Host host, Vm vm) Gets the power consumption of a host after the supposed placement of a candidate VM.protected double
getPowerDifferenceAfterAllocation
(Host host, Vm vm) Gets the power consumption different after the supposed placement of a VM into a given Host and the original Host power consumption.Gets the switched off hosts.double
Gets the percentage of total CPU utilization to indicate that a host is under used and its VMs have to be migrated.protected double
getUtilizationOfCpuMips
(Host host) Gets the utilization of the CPU in MIPS for the current potentially allocated VMs.Gets the the policy that defines how VMs are selected for migration.Gets the VMs to migrate from under utilized host.boolean
isHostOverloaded
(Host host) Checks if host is currently over utilized, according the conditions defined by the Allocation Policy.boolean
isHostUnderloaded
(Host host) Checks if a host is under utilized, based on current CPU usage.final boolean
Checks if VM migrations are supported by this VmAllocationPolicy.void
setDatacenter
(Datacenter datacenter) Sets the Datacenter associated to the Allocation Policyvoid
setUnderUtilizationThreshold
(double underUtilizationThreshold) Sets the percentage of total CPU utilization to indicate that a host is under used and its VMs have to be migrated.final void
setVmSelectionPolicy
(VmSelectionPolicy vmSelectionPolicy) Sets the the policy that defines how VMs are selected for migration.Methods inherited from class org.cloudbus.cloudsim.allocationpolicies.VmAllocationPolicyAbstract
allocateHostForVm, allocateHostForVm, allocateHostForVm, deallocateHostForVm, findHostForVm, getDatacenter, getHostCountForParallelSearch, getHostList, scaleVmVertically, 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, isParallelHostSearchEnabled, scaleVmVertically, setFindHostForVmFunction, setHostCountForParallelSearch
Methods inherited from interface org.cloudbus.cloudsim.allocationpolicies.migration.VmAllocationPolicyMigration
areHostsUnderOrOverloaded, getOverUtilizationThreshold
-
Field Details
-
DEF_UNDERLOAD_THRESHOLD
public static final double DEF_UNDERLOAD_THRESHOLD- See Also:
-
-
Constructor Details
-
VmAllocationPolicyMigrationAbstract
Creates a VmAllocationPolicy. It uses adefault under utilization threshold
.- Parameters:
vmSelectionPolicy
- the policy that defines how VMs are selected for migration
-
VmAllocationPolicyMigrationAbstract
public VmAllocationPolicyMigrationAbstract(VmSelectionPolicy vmSelectionPolicy, BiFunction<VmAllocationPolicy, Vm, Optional<Host>> findHostForVmFunction) Creates a new VmAllocationPolicy, changing theFunction
to select a Host for a Vm. It uses adefault under utilization threshold
.- Parameters:
vmSelectionPolicy
- the policy that defines how VMs are selected for migrationfindHostForVmFunction
- aFunction
to 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 class:VmAllocationPolicyAbstract
Sets the Datacenter associated to the Allocation Policy- Specified by:
setDatacenter
in interfaceVmAllocationPolicy
- Overrides:
setDatacenter
in classVmAllocationPolicyAbstract
- Parameters:
datacenter
- the Datacenter to set
-
getOptimizedAllocationMap
Description copied from interface:VmAllocationPolicy
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.- Specified by:
getOptimizedAllocationMap
in interfaceVmAllocationPolicy
- Overrides:
getOptimizedAllocationMap
in 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
-
getPowerDifferenceAfterAllocation
Gets the power consumption different after the supposed placement of a VM into a given Host and the original Host power consumption.- Parameters:
host
- the host to check the power consumptionvm
- the candidate vm- Returns:
- the host power consumption different after the supposed VM placement or 0 if the power consumption could not be determined
-
isHostOverloaded
Checks if host is currently over utilized, according the conditions defined by the Allocation Policy. It's based on current CPU usage.- Specified by:
isHostOverloaded
in interfaceVmAllocationPolicyMigration
- Parameters:
host
- the host to check- Returns:
- true, if the host is over utilized; false otherwise
-
isHostUnderloaded
Checks if a host is under utilized, based on current CPU usage.- Specified by:
isHostUnderloaded
in interfaceVmAllocationPolicyMigration
- Parameters:
host
- the host- Returns:
- true, if the host is under utilized; false otherwise
-
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:
-
findHostForVmInternal
Applies additional filters to the Hosts Stream and performs the actual Host selection. It can be overridden by sub-classes to change the way to select the Host for a given VM. -
getVmsToMigrateFromUnderUtilizedHost
Gets the VMs to migrate from under utilized host.- Parameters:
host
- the host- Returns:
- the vms to migrate from under utilized host
-
getSwitchedOffHosts
Gets the switched off hosts.- Returns:
- the switched off hosts
-
getPowerAfterAllocation
Gets the power consumption of a host after the supposed placement of a candidate VM. The VM is not in fact placed at the host.- Parameters:
host
- the host to check the power consumptionvm
- the candidate vm- Returns:
- the host power consumption after the supposed VM placement 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
Gets the utilization of the CPU in MIPS for the current potentially allocated VMs.- Parameters:
host
- the host- Returns:
- the utilization of the CPU in MIPS
-
setVmSelectionPolicy
Description copied from interface:VmAllocationPolicyMigration
Sets the the policy that defines how VMs are selected for migration.- Specified by:
setVmSelectionPolicy
in interfaceVmAllocationPolicyMigration
- Parameters:
vmSelectionPolicy
- the new vm selection policy
-
getVmSelectionPolicy
Description copied from interface:VmAllocationPolicyMigration
Gets the the policy that defines how VMs are selected for migration.- Specified by:
getVmSelectionPolicy
in interfaceVmAllocationPolicyMigration
- Returns:
- the
VmSelectionPolicy
.
-
getUnderUtilizationThreshold
public double getUnderUtilizationThreshold()Description copied from interface:VmAllocationPolicyMigration
Gets the percentage of total CPU utilization to indicate that a host is under used and its VMs have to be migrated.- Specified by:
getUnderUtilizationThreshold
in interfaceVmAllocationPolicyMigration
- Returns:
- the under utilization threshold (in scale is from 0 to 1, where 1 is 100%)
-
setUnderUtilizationThreshold
public void setUnderUtilizationThreshold(double underUtilizationThreshold) Description copied from interface:VmAllocationPolicyMigration
Sets the percentage of total CPU utilization to indicate that a host is under used and its VMs have to be migrated.- Specified by:
setUnderUtilizationThreshold
in interfaceVmAllocationPolicyMigration
- Parameters:
underUtilizationThreshold
- the under utilization threshold (in scale is from 0 to 1, where 1 is 100%)
-
isVmMigrationSupported
public final boolean isVmMigrationSupported()Description copied from interface:VmAllocationPolicy
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.- Specified by:
isVmMigrationSupported
in interfaceVmAllocationPolicy
- Overrides:
isVmMigrationSupported
in classVmAllocationPolicyAbstract
- Returns:
- See Also:
-
areHostsUnderloaded
public boolean areHostsUnderloaded()Description copied from interface:VmAllocationPolicyMigration
Checks if there are some Hosts underloaded.- Specified by:
areHostsUnderloaded
in interfaceVmAllocationPolicyMigration
- Returns:
-
areHostsOverloaded
public boolean areHostsOverloaded()Description copied from interface:VmAllocationPolicyMigration
Checks if there are some Hosts overloaded.- Specified by:
areHostsOverloaded
in interfaceVmAllocationPolicyMigration
- Returns:
-