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 Details

    • DEF_UNDERLOAD_THRESHOLD

      public static final double DEF_UNDERLOAD_THRESHOLD
      See Also:
  • Constructor Details

  • Method Details

    • getOptimizedAllocationMap

      public Map<Vm,Host> getOptimizedAllocationMap(List<? extends Vm> vmList)
      Description copied from class: VmAllocationPolicyAbstract
      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.

      This method implementation doesn't perform any VM placement optimization and, in fact, has no effect. Classes implementing the VmAllocationPolicyMigration provide actual implementations for this method that can be overridden by subclasses.

      Specified by:
      getOptimizedAllocationMap in interface VmAllocationPolicy
      Overrides:
      getOptimizedAllocationMap in class VmAllocationPolicyAbstract
      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

      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.
      Parameters:
      host - the host to check the power consumption
      vm - 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

      public boolean isHostOverloaded(Host host)
      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 interface VmAllocationPolicyMigration
      Parameters:
      host - the host to check
      Returns:
      true, if the host is over utilized; false otherwise
    • isHostUnderloaded

      public boolean isHostUnderloaded(Host host)
      Checks if a host is under utilized, based on current CPU usage.
      Specified by:
      isHostUnderloaded in interface VmAllocationPolicyMigration
      Parameters:
      host - the host
      Returns:
      true, if the host is under utilized; false otherwise
    • defaultFindHostForVm

      protected Optional<Host> defaultFindHostForVm(Vm vm)
      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 class VmAllocationPolicyAbstract
      Parameters:
      vm - the VM to find a suitable Host to
      Returns:
      an Optional containing a suitable Host to place the VM or an empty Optional if no suitable Host was found
      See Also:
    • findHostForVmInternal

      protected Optional<Host> findHostForVmInternal(Vm vm, Stream<Host> hostStream)
      Applies additional filters to the Hosts Stream and performs the actual Host selection. This method is a Stream's final operation, that it, it closes the Stream and returns an Optional value.

      This method can be overridden by sub-classes to change the method used to select the Host for the given VM.

      Parameters:
      vm - the VM to find a Host to be placed into
      hostStream - a Stream containing the Hosts after passing the basic filtering
      Returns:
      an Optional containing a suitable Host to place the VM or an empty Optional if not found
      See Also:
      • findHostForVm(Vm, Set)
    • getVmsToMigrateFromUnderUtilizedHost

      protected List<? extends Vm> getVmsToMigrateFromUnderUtilizedHost(Host host)
      Gets the VMs to migrate from under utilized host.
      Parameters:
      host - the host
      Returns:
      the vms to migrate from under utilized host
    • getSwitchedOffHosts

      protected List<Host> getSwitchedOffHosts()
      Gets the switched off hosts.
      Returns:
      the switched off hosts
    • getPowerAfterAllocation

      protected double getPowerAfterAllocation(Host host, Vm vm)
      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 consumption
      vm - the candidate vm
      Returns:
      the host power consumption after the supposed VM placement or 0 if the power consumption could not be determined
    • getMaxUtilizationAfterAllocation

      protected double getMaxUtilizationAfterAllocation(Host host, Vm vm)
      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 host
      vm - the vm
      Returns:
      the power after allocation
    • getUtilizationOfCpuMips

      protected double getUtilizationOfCpuMips(Host host)
      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

      public final void setVmSelectionPolicy(VmSelectionPolicy vmSelectionPolicy)
      Description copied from interface: VmAllocationPolicyMigration
      Sets the the policy that defines how VMs are selected for migration.
      Specified by:
      setVmSelectionPolicy in interface VmAllocationPolicyMigration
      Parameters:
      vmSelectionPolicy - the new vm selection policy
    • getVmSelectionPolicy

      public VmSelectionPolicy getVmSelectionPolicy()
      Description copied from interface: VmAllocationPolicyMigration
      Gets the the policy that defines how VMs are selected for migration.
      Specified by:
      getVmSelectionPolicy in interface VmAllocationPolicyMigration
      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 interface VmAllocationPolicyMigration
      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 interface VmAllocationPolicyMigration
      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 interface VmAllocationPolicy
      Overrides:
      isVmMigrationSupported in class VmAllocationPolicyAbstract
      Returns:
      See Also:
    • areHostsUnderloaded

      public boolean areHostsUnderloaded()
      Description copied from interface: VmAllocationPolicyMigration
      Checks if there are some Hosts underloaded.
      Specified by:
      areHostsUnderloaded in interface VmAllocationPolicyMigration
      Returns:
    • areHostsOverloaded

      public boolean areHostsOverloaded()
      Description copied from interface: VmAllocationPolicyMigration
      Checks if there are some Hosts overloaded.
      Specified by:
      areHostsOverloaded in interface VmAllocationPolicyMigration
      Returns: