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 Details

  • Constructor Details

  • Method Details

    • setDatacenter

      public VmAllocationPolicyAbstract setDatacenter(Datacenter datacenter)
      Description copied from interface: VmAllocationPolicy
      Sets the Datacenter associated to the VmAllocationPolicy
      Specified by:
      setDatacenter in interface VmAllocationPolicy
      Parameters:
      datacenter - the Datacenter to set
      Returns:
      this VmAllocationPolicy
    • getOptimizedAllocationMap

      public Map<Vm,Host> getOptimizedAllocationMap(List<? extends Vm> vmList)
      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 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
    • powerDiffAfterAllocation

      protected double powerDiffAfterAllocation(Host host, Vm vm)
      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 consumption
      vm - 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

      public boolean isOverloaded(Host host)
      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:
      isOverloaded in interface VmAllocationPolicyMigration
      Parameters:
      host - the host to check
      Returns:
      true if the host is overloaded, false otherwise
    • isUnderloaded

      public boolean isUnderloaded(Host host)
      Checks if a host is under-utilized, based on current CPU usage.
      Specified by:
      isUnderloaded in interface VmAllocationPolicyMigration
      Parameters:
      host - the host to check
      Returns:
      true, if the host is underloaded; 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, Predicate<Host> predicate)
      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.
      Parameters:
      vm - the VM to find a Host to be placed into
      predicate - a Predicate to filter suitable Hosts
      Returns:
      an Optional containing a suitable Host to place the VM, or an empty Optional if not found
      See Also:
      • findHostForVm(Vm, Predicate)
    • getVmsToMigrateFromUnderUtilizedHost

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

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

      protected double getPowerAfterAllocation(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. 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 power consumption of a host after the supposed placement of a candidate VM, 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)
      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: VmAllocationPolicyMigration
      Sets 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:
      setUnderUtilizationThreshold in interface VmAllocationPolicyMigration
      Parameters:
      underUtilizationThreshold - the under utilization threshold (a percentage value from 0 to 1)
    • 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:
      true if VM migration is supported; false otherwise.
      See Also: