Interface VmAllocationPolicy

    • Method Detail

      • getDatacenter

        Datacenter getDatacenter()
        Gets the Datacenter associated to the Allocation Policy.
        Returns:
      • setDatacenter

        void setDatacenter​(Datacenter datacenter)
        Sets the Datacenter associated to the Allocation Policy
        Parameters:
        datacenter - the Datacenter to set
      • allocateHostForVm

        boolean allocateHostForVm​(Vm vm)
        Allocates a host for a given VM.
        Parameters:
        vm - the VM to allocate a host to
        Returns:
        $true if the host could be allocated; $false otherwise
        Precondition:
        $none
        Postcondition:
        $none
      • allocateHostForVm

        boolean allocateHostForVm​(Vm vm,
                                  Host host)
        Allocates a specified host for a given VM.
        Parameters:
        vm - the VM to allocate a host to
        host - the host to allocate to the given VM
        Returns:
        $true if the host could be allocated; $false otherwise
        Precondition:
        $none
        Postcondition:
        $none
      • scaleVmVertically

        boolean scaleVmVertically​(VerticalVmScaling scaling)
        Try to scale some Vm's resource vertically up or down, respectively if:
        • the Vm is overloaded and the Host where the Vm is placed has enough capacity
        • the Vm is underloaded
        The resource to be scaled is defined by the given VerticalVmScaling object.
        Parameters:
        scaling - the VerticalVmScaling object with information of which resource is being requested to be scaled
        Returns:
        true if the requested resource was scaled, false otherwise
      • deallocateHostForVm

        void deallocateHostForVm​(Vm vm)
        Releases the host used by a VM.
        Parameters:
        vm - the vm to get its host released
        Precondition:
        $none
        Postcondition:
        $none
      • findHostForVm

        Optional<Host> findHostForVm​(Vm vm)
        Finds a host that has enough resources to place a given VM. Classes must implement this method to define how to select a Host for a given VM. They just have to provide a default implementation. However, this implementation can be dynamically changed by calling setFindHostForVmFunction(BiFunction).
        Parameters:
        vm - the vm to find a host for it
        Returns:
        an Optional containing a suitable Host to place the VM or an empty Optional if no suitable Host was found
      • getHostList

        <T extends HostList<T> getHostList()
        Gets the list of Hosts available in a Datacenter, that will be used by the Allocation Policy to place VMs.
        Type Parameters:
        T - The generic type
        Returns:
        the host list
      • getOptimizedAllocationMap

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

        void setFindHostForVmFunction​(BiFunction<VmAllocationPolicy,​Vm,​Optional<Host>> findHostForVmFunction)
        Sets a BiFunction that selects a Host for a given Vm. This Function receives the current VmAllocationPolicy and the Vm requesting to be place. It then returns an Optional that may contain a suitable Host for that Vm or not.

        If not Function is set, the default VM selection method provided by implementing classes will be used.

        Parameters:
        findHostForVmFunction - the BiFunction to set