Interface VmScheduler

  • All Known Implementing Classes:
    VmSchedulerAbstract, VmSchedulerSpaceShared, VmSchedulerTimeShared, VmSchedulerTimeSharedOverSubscription

    public interface VmScheduler
    An interface that represents the policy used by a Virtual Machine Monitor (VMM) to share processing power of a PM among VMs running in a host. Each host has to use is own instance of a VmScheduler that will so schedule the allocation of host's PEs for VMs running on it.

    It also implements the Null Object Design Pattern in order to start avoiding NullPointerException when using the NULL object instead of attributing null to VmScheduler variables.

    Since:
    CloudSim Plus 1.0
    Author:
    Rodrigo N. Calheiros, Anton Beloglazov, Manoel Campos da Silva Filho
    • Field Detail

      • NULL

        static final VmScheduler NULL
        An attribute that implements the Null Object Design Pattern for VmScheduler objects.
    • Method Detail

      • allocatePesForVm

        boolean allocatePesForVm​(Vm vm,
                                 List<Double> requestedMips)
        Requests the allocation of PEs for a VM.
        Parameters:
        vm - the vm to allocate PEs to
        requestedMips - the list of MIPS share to be allocated to a VM
        Returns:
        true if the PEs were allocated to the VM, false otherwise
        Precondition:
        $none
        Postcondition:
        $none
      • allocatePesForVm

        boolean allocatePesForVm​(Vm vm)
        Requests the allocation of PEs for a VM, according to the number of PEs and MIPS defined by VM attributes.
        Parameters:
        vm - the vm to allocate PEs to
        Returns:
        true if the PEs were allocated to the VM, false otherwise
        Precondition:
        $none
        Postcondition:
        $none
      • deallocatePesForAllVms

        void deallocatePesForAllVms()
        Releases PEs allocated to all the VMs of the host the VmScheduler is associated to. After that, all PEs will be available to be used on demand for requesting VMs.
        Precondition:
        $none
        Postcondition:
        $none
      • deallocatePesFromVm

        void deallocatePesFromVm​(Vm vm)
        Releases all PEs allocated to a VM. After that, the PEs may be used on demand by other VMs.
        Parameters:
        vm - the vm to deallocate PEs from
        Precondition:
        $none
        Postcondition:
        $none
      • deallocatePesFromVm

        void deallocatePesFromVm​(Vm vm,
                                 int pesToRemove)
        Releases a given number of PEs from a VM. After that, the PEs may be used on demand by other VMs.
        Parameters:
        vm - the vm to deallocate PEs from
        pesToRemove - number of PEs to deallocate
        Precondition:
        $none
        Postcondition:
        $none
      • getAllocatedMips

        List<Double> getAllocatedMips​(Vm vm)
        Gets the MIPS share of each host's Pe that is allocated to a given VM.
        Parameters:
        vm - the vm to get the MIPS share
        Returns:
        Precondition:
        $none
        Postcondition:
        $none
      • getAvailableMips

        double getAvailableMips()
        Gets the total amount of MIPS that is currently free. If there are VMs migrating into the Host, their requested MIPS will already be allocated, reducing the total available MIPS.
        Returns:
      • getRequestedMips

        List<Double> getRequestedMips​(Vm vm)
        Gets a copy of the List of MIPS requested by a VM, avoiding the original list to be changed.
        Parameters:
        vm - the VM to get the List of requested MIPS
        Returns:
      • isSuitableForVm

        default boolean isSuitableForVm​(Vm vm)
        Checks if the PM using this scheduler has enough MIPS capacity to host a given VM.
        Parameters:
        vm - the vm to check if there is enough available resource on the PM to host it
        Returns:
        true, if it is possible to allocate the the VM into the host; false otherwise
      • isSuitableForVm

        boolean isSuitableForVm​(Vm vm,
                                boolean showLog)
        Checks if the PM using this scheduler has enough MIPS capacity to host a given VM.
        Parameters:
        vm - the vm to check if there is enough available resource on the PM to host it
        showLog - if a log message should be printed when the Host isn't suitable for the given VM
        Returns:
        true, if it is possible to allocate the the VM into the host; false otherwise
        See Also:
        isSuitableForVm(Vm)
      • isSuitableForVm

        default boolean isSuitableForVm​(Vm vm,
                                        List<Double> requestedMips)
        Checks if a list of MIPS requested by a VM is allowed to be allocated or not. Depending on the VmScheduler implementation, the return value of this method may have different effects:
        • true: requested MIPS can be allocated, partial or totally;
        • false: requested MIPS cannot be allocated because there is no availability at all or there is just a partial amount of the requested MIPS available and the VmScheduler implementation doesn't allow allocating less than the VM is requesting. If less than the required MIPS is allocated to a VM, it will cause performance degradation. Such situation defines an over-subscription situation which just specific VmSchedulers accept.
        Parameters:
        vm - the Vm to check if there are enough MIPS to allocate to
        requestedMips - a list of MIPS requested by a VM
        Returns:
        true if the requested MIPS List is allowed to be allocated to the VM, false otherwise
      • isSuitableForVm

        boolean isSuitableForVm​(Vm vm,
                                List<Double> requestedMips,
                                boolean showLog)
        Checks if a list of MIPS requested by a VM is allowed to be allocated or not.
        Parameters:
        vm - the Vm to check if there are enough MIPS to allocate to
        requestedMips - a list of MIPS requested by a VM
        showLog - if a log message should be printed when the Host isn't suitable for the given VM
        Returns:
        true if the requested MIPS List is allowed to be allocated to the VM, false otherwise
        See Also:
        isSuitableForVm(Vm, List)
      • getMaxAvailableMips

        double getMaxAvailableMips()
        Gets the maximum available MIPS among all the host's PEs.
        Returns:
      • getPeCapacity

        long getPeCapacity()
        Gets PE capacity in MIPS.
        Returns:
      • getWorkingPeList

        <T extends PeList<T> getWorkingPeList()
        Gets the list of working PEs from the Host, which excludes failed PEs.
        Type Parameters:
        T - the generic type
        Returns:
      • getTotalAllocatedMipsForVm

        double getTotalAllocatedMipsForVm​(Vm vm)
        Gets the actual total allocated MIPS for a VM along all its allocated PEs. If the VM is migrating into the Host, then just a fraction of the requested MIPS is actually allocated, representing the overhead of the migration process.

        The MIPS requested by the VM are just actually allocated after the migration is completed.

        Parameters:
        vm - the VM to get the total allocated MIPS
        Returns:
        See Also:
        getVmMigrationCpuOverhead()
      • getMaxCpuUsagePercentDuringOutMigration

        double getMaxCpuUsagePercentDuringOutMigration()
        Gets the max percentage of CPU a VM migrating out of this Host can use. Since there may be an overhead associated to the migration process (if the CPU overhead for VM migration is greater than 0), during the migration, the amount of MIPS the VM can use is reduced due to this overhead.
        Returns:
        the max percentage of CPU usage during migration (in scale from [0 to 1], where 1 is 100%)
      • getVmMigrationCpuOverhead

        double getVmMigrationCpuOverhead()
        Defines the percentage of Host's CPU usage increase when a VM is migrating in or out of the Host. The value is in scale from 0 to 1 (where 1 is 100%).
        Returns:
        the Host's CPU migration overhead percentage.
      • getHost

        Host getHost()
        Gets the host that the VmScheduler get the list of PEs to allocate to VMs.
        Returns:
      • setHost

        VmScheduler setHost​(Host host)
        Sets the host that the VmScheduler get the list of PEs to allocate to VMs. A host for the VmScheduler is set when the VmScheduler is set to a given host. Thus, the host is in charge to set itself to a VmScheduler.
        Parameters:
        host - the host to be set
        Returns:
        Throws:
        IllegalArgumentException - when the scheduler already is assigned to another Host, since each Host must have its own scheduler
        NullPointerException - when the host parameter is null