Class VmAllocationPolicyMigrationAbstract

    • Method Detail

      • 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. The VmAllocationPolicyMigrationAbstract class provides an actual implementation 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
      • getPowerAfterAllocationDifference

        protected double getPowerAfterAllocationDifference​(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 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
      • findHostForVm

        public Optional<Host> findHostForVm​(Vm vm,
                                            Set<? extends Host> excludedHosts)
        Finds a Host that has enough resources to place a given VM and that will not be overloaded after the placement. The selected Host will be that one with most efficient power usage for the given VM.

        This method performs the basic filtering and delegates additional ones and the final selection of the Host to other method.

        Parameters:
        vm - the VM
        excludedHosts - the excluded hosts
        Returns:
        an Optional containing a suitable Host to place the VM or an empty Optional if not found
        See Also:
        findHostForVmInternal(Vm, Stream)
      • findHostForVm

        public Optional<Host> findHostForVm​(Vm vm,
                                            Set<? extends Host> excludedHosts,
                                            Predicate<Host> predicate)
        Finds a Host that has enough resources to place a given VM and that will not be overloaded after the placement. The selected Host will be that one with most efficient power usage for the given VM.

        This method performs the basic filtering and delegates additional ones and the final selection of the Host to other method.

        Parameters:
        vm - the VM
        excludedHosts - the excluded hosts
        predicate - an additional Predicate to be used to filter the Host to place the VM
        Returns:
        an Optional containing a suitable Host to place the VM or an empty Optional if not found
        See Also:
        findHostForVmInternal(Vm, Stream)
      • 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), additionalHostFilters(Vm, Stream)
      • 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
      • notAllVmsAreMigratingOut

        protected boolean notAllVmsAreMigratingOut​(Host host)
        Checks if all VMs of a Host are NOT migrating out. In this case, the given Host will not be selected as an underloaded Host at the current moment. That is: not all VMs are migrating out if at least one VM isn't in migration process.
        Parameters:
        host - the host to check
        Returns:
        true if at least one VM isn't migrating, false if all VMs are migrating
      • 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
      • addHistoryEntryIfAbsent

        protected void addHistoryEntryIfAbsent​(Host host,
                                               double metric)
        Adds an entry for each history map of a host if it doesn't contain an entry for the current simulation time.
        Parameters:
        host - the host to add metric history entries
        metric - the metric to be added to the metric history map
      • setVmSelectionPolicy

        protected final void setVmSelectionPolicy​(PowerVmSelectionPolicy vmSelectionPolicy)
        Sets the vm selection policy.
        Parameters:
        vmSelectionPolicy - the new vm selection policy
      • getVmSelectionPolicy

        protected PowerVmSelectionPolicy getVmSelectionPolicy()
        Gets the vm selection policy.
        Returns:
        the vm selection policy
      • 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%)
      • getHostCpuUsageArray

        protected double[] getHostCpuUsageArray​(Host host)
        Gets all CPU utilization values from the Host.getUtilizationHistorySum() as an array.
        Parameters:
        host - the Host to get the CPU utilization values
        Returns:
        the utilization values array