Interface Vm

    • Field Detail

      • NULL

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

      • getDescription

        java.lang.String getDescription()
        Gets the Vm description, which is an optional text which one can use to provide details about this of this VM.
        Returns:
      • setDescription

        Vm setDescription​(java.lang.String description)
        Sets the VM description, which is an optional text which one can use to provide details about this of this VM.
        Parameters:
        description - the Vm description to set
        Returns:
      • addStateHistoryEntry

        void addStateHistoryEntry​(VmStateHistoryEntry entry)
        Adds a VM state history entry.
        Parameters:
        entry - the data about the state of the VM at given time
      • getCloudletScheduler

        CloudletScheduler getCloudletScheduler()
        Gets the the Cloudlet scheduler the VM uses to schedule cloudlets execution.
        Returns:
        the cloudlet scheduler
      • getCurrentRequestedBw

        long getCurrentRequestedBw()
        Gets the current requested bw.
        Returns:
        the current requested bw
      • getCurrentRequestedMaxMips

        double getCurrentRequestedMaxMips()
        Gets the current requested max MIPS among all virtual PEs.
        Returns:
        the current requested max MIPS
      • getCurrentRequestedMips

        java.util.List<java.lang.Double> getCurrentRequestedMips()
        Gets a copy list of current requested MIPS of each virtual Pe, avoiding the original list to be changed.
        Returns:
        the current requested MIPS of each Pe
      • getRelativeMipsCapacityPercent

        double getRelativeMipsCapacityPercent()
        Gets the percentage of the MIPS capacity this VM represents from the total Host MIPS capacity.
        Returns:
        the VM relative MIPS capacity percentage
      • getCurrentRequestedRam

        long getCurrentRequestedRam()
        Gets the current requested ram.
        Returns:
        the current requested ram
      • getCurrentRequestedTotalMips

        double getCurrentRequestedTotalMips()
        Gets the current requested total MIPS. It is the sum of MIPS capacity requested for every virtual Pe.
        Returns:
        the current requested total MIPS
        See Also:
        getCurrentRequestedMips()
      • getHost

        Host getHost()
        Gets the Host where the Vm is or will be placed. To know if the Vm was already created inside this Host, call the isCreated() method.
        Returns:
        the Host
        See Also:
        isCreated()
      • allocateResource

        void allocateResource​(java.lang.Class<? extends ResourceManageable> resourceClass,
                              long newTotalResourceAmount)
        Changes the allocation of a given resource for a VM. The old allocated amount will be changed to the new given amount.
        Parameters:
        resourceClass - the class of the resource to change the allocation
        newTotalResourceAmount - the new amount to change the current allocation to
      • deallocateResource

        void deallocateResource​(java.lang.Class<? extends ResourceManageable> resourceClass)
        Removes the entire amount of a given resource allocated to VM.
        Parameters:
        resourceClass - the class of the resource to deallocate from the VM
      • addOnHostAllocationListener

        Vm addOnHostAllocationListener​(EventListener<VmHostEventInfo> listener)
        Adds a listener object that will be notified when a Host is allocated to the Vm, that is, when the Vm is placed into a given Host.
        Parameters:
        listener - the listener to add
        Returns:
      • addOnHostDeallocationListener

        Vm addOnHostDeallocationListener​(EventListener<VmHostEventInfo> listener)
        Adds a listener object that will be notified when the Vm is moved/removed from a Host.
        Parameters:
        listener - the listener to add
        Returns:
      • notifyOnHostAllocationListeners

        void notifyOnHostAllocationListeners()
        Notifies all registered listeners when a Host is allocated to the Vm.

        This method is used just internally and must not be called directly.

      • notifyOnHostDeallocationListeners

        void notifyOnHostDeallocationListeners​(Host deallocatedHost)
        Notifies all registered listeners when the Vm is moved/removed from a Host.

        This method is used just internally and must not be called directly.

        Parameters:
        deallocatedHost - the Host the Vm was moved/removed from
      • notifyOnCreationFailureListeners

        void notifyOnCreationFailureListeners​(Datacenter failedDatacenter)
        Notifies all registered listeners when the Vm fail in being placed for lack of a Host with enough resources in a specific Datacenter.

        This method is used just internally and must not be called directly.

        Parameters:
        failedDatacenter - the Datacenter where the VM creation failed
      • removeOnUpdateProcessingListener

        boolean removeOnUpdateProcessingListener​(EventListener<VmHostEventInfo> listener)
        Removes a listener from the onUpdateVmProcessingListener List.
        Parameters:
        listener - the listener to remove
        Returns:
        true if the listener was found and removed, false otherwise
      • removeOnHostAllocationListener

        boolean removeOnHostAllocationListener​(EventListener<VmHostEventInfo> listener)
        Removes a listener from the onHostAllocationListener List.
        Parameters:
        listener - the listener to remove
        Returns:
        true if the listener was found and removed, false otherwise
      • removeOnHostDeallocationListener

        boolean removeOnHostDeallocationListener​(EventListener<VmHostEventInfo> listener)
        Removes a listener from the onHostDeallocationListener List.
        Parameters:
        listener - the listener to remove
        Returns:
        true if the listener was found and removed, false otherwise
      • removeOnCreationFailureListener

        boolean removeOnCreationFailureListener​(EventListener<VmDatacenterEventInfo> listener)
        Removes a listener from the onVmCreationFailureListener List.
        Parameters:
        listener - the listener to remove
        Returns:
        true if the listener was found and removed, false otherwise
      • getBw

        Resource getBw()
        Gets bandwidth resource (in Megabits/s) assigned to the Vm, allowing to check its capacity and usage.
        Specified by:
        getBw in interface Machine
        Returns:
        bandwidth resource.
      • getRam

        Resource getRam()
        Gets the RAM resource assigned to the Vm, allowing to check its capacity (in Megabytes) and usage.
        Specified by:
        getRam in interface Machine
        Returns:
        the RAM resource
      • getStorage

        Resource getStorage()
        Gets the storage device of the VM, which represents the VM image, allowing to check its capacity (in Megabytes) and usage.
        Specified by:
        getStorage in interface Machine
        Returns:
        the storage resource
      • getStateHistory

        java.util.List<VmStateHistoryEntry> getStateHistory()
        Gets a read-only list with the history of requests and allocation of MIPS for this VM.
        Returns:
        the state history
      • getCpuPercentUsage

        double getCpuPercentUsage​(double time)
        Gets the CPU utilization percentage of all Clouddlets running on this VM at the given time.
        Parameters:
        time - the time
        Returns:
        total utilization percentage
      • getCpuPercentUsage

        double getCpuPercentUsage()
        Gets the current CPU utilization percentage (in scale from 0 to 1) of all Cloudlets running on this VM.
        Returns:
        total utilization percentage for the current time, in scale from 0 to 1
      • getTotalCpuMipsUsage

        double getTotalCpuMipsUsage()
        Gets the current total CPU MIPS utilization of all PEs from all cloudlets running on this VM.
        Returns:
        total CPU utilization in MIPS
        See Also:
        getCpuPercentUsage(double)
      • getTotalCpuMipsUsage

        double getTotalCpuMipsUsage​(double time)
        Gets the total CPU MIPS utilization of all PEs from all cloudlets running on this VM at the given time.
        Parameters:
        time - the time to get the utilization
        Returns:
        total CPU utilization in MIPS
        See Also:
        getCpuPercentUsage(double)
      • getVmm

        java.lang.String getVmm()
        Gets the Virtual Machine Monitor (VMM) that manages the VM.
        Returns:
        VMM
      • isCreated

        boolean isCreated()
        Checks if the VM was created and placed inside the Host. If so, resources required by the Vm already were provisioned.
        Returns:
        true, if it was created inside the Host, false otherwise
      • isSuitableForCloudlet

        boolean isSuitableForCloudlet​(Cloudlet cloudlet)
        Checks if the VM has enough capacity to run a Cloudlet.
        Parameters:
        cloudlet - the candidate Cloudlet to run inside the VM
        Returns:
        true if the VM can run the Cloudlet, false otherwise
        To do something:
        the Method is not being called anywhere to check if a VM has enough capacity to run a Cloudlet
      • setCreated

        void setCreated​(boolean created)
        Changes the created status of the Vm inside the Host.
        Parameters:
        created - true to indicate the VM was created inside the Host; false otherwise
        See Also:
        isCreated()
      • isInMigration

        boolean isInMigration()
        Checks if the VM is in migration process or not, that is, if it is migrating in or out of a Host.
        Returns:
      • setInMigration

        void setInMigration​(boolean migrating)
        Defines if the VM is in migration process or not.
        Parameters:
        migrating - true to indicate the VM is migrating into a Host, false otherwise
      • setBw

        Vm setBw​(long bwCapacity)
        Sets the bandwidth capacity (in Megabits/s)
        Parameters:
        bwCapacity - new BW capacity (in Megabits/s)
        Returns:
      • setHost

        void setHost​(Host host)
        Sets the PM that hosts the VM.
        Parameters:
        host - Host to run the VM
      • setRam

        Vm setRam​(long ramCapacity)
        Sets RAM capacity in Megabytes.
        Parameters:
        ramCapacity - new RAM capacity
        Returns:
      • setSize

        Vm setSize​(long size)
        Sets the storage size (capacity) of the VM image in Megabytes.
        Parameters:
        size - new storage size
        Returns:
      • updateProcessing

        double updateProcessing​(double currentTime,
                                java.util.List<java.lang.Double> mipsShare)
        Updates the processing of cloudlets running on this VM.
        Parameters:
        currentTime - current simulation time
        mipsShare - list with MIPS share of each Pe available to the scheduler
        Returns:
        the predicted completion time of the earliest finishing cloudlet (which is a relative delay from the current simulation time), or Double.MAX_VALUE if there is no next Cloudlet to execute
      • updateProcessing

        double updateProcessing​(java.util.List<java.lang.Double> mipsShare)
        Updates the processing of cloudlets running on this VM at the current simulation time.
        Parameters:
        mipsShare - list with MIPS share of each Pe available to the scheduler
        Returns:
        the predicted completion time of the earliest finishing cloudlet (which is a relative delay from the current simulation time), or Double.MAX_VALUE if there is no next Cloudlet to execute
      • setCloudletScheduler

        Vm setCloudletScheduler​(CloudletScheduler cloudletScheduler)
        Sets the Cloudlet scheduler the Vm uses to schedule cloudlets execution. It also sets the Vm itself to the given scheduler.
        Parameters:
        cloudletScheduler - the cloudlet scheduler to set
        Returns:
      • setFailed

        void setFailed​(boolean failed)
        Sets the status of VM to FAILED.
        Parameters:
        failed - true to indicate that the VM is failed, false to indicate it is working
      • isFailed

        boolean isFailed()
        Checks if the Vm is failed or not.
        Returns:
        See Also:
        isWorking()
      • isWorking

        boolean isWorking()
        Checks if the Vm is working or failed.
        Returns:
        See Also:
        isFailed()
      • getResources

        java.util.List<ResourceManageable> getResources()
        Gets a read-only list of resources the machine has. Such resources represent virtual resources corresponding to physical resources from the Host where the VM is placed.
        Specified by:
        getResources in interface Resourceful
        Returns:
        a read-only list of resources
        See Also:
        Resourceful.getResource(Class)
      • getHorizontalScaling

        HorizontalVmScaling getHorizontalScaling()
        Gets a HorizontalVmScaling that will check if the Vm is overloaded, based on some conditions defined by a Predicate given to the HorizontalVmScaling, and then request the creation of new VMs to horizontally scale the Vm.

        If no HorizontalVmScaling is set, the Broker will not dynamically create VMs to balance arrived Cloudlets.

        Returns:
      • setHorizontalScaling

        Vm setHorizontalScaling​(HorizontalVmScaling horizontalScaling)
                         throws java.lang.IllegalArgumentException
        Sets a HorizontalVmScaling that will check if the Vm is overloaded, based on some conditions defined by a Predicate given to the HorizontalVmScaling, and then request the creation of new VMs to horizontally scale the Vm.
        Parameters:
        horizontalScaling - the HorizontalVmScaling to set
        Returns:
        Throws:
        java.lang.IllegalArgumentException - if the given VmScaling is already linked to a Vm. Each VM must have its own HorizontalVmScaling object or none at all.
      • setRamVerticalScaling

        Vm setRamVerticalScaling​(VerticalVmScaling ramVerticalScaling)
                          throws java.lang.IllegalArgumentException
        Sets a VerticalVmScaling that will check if the Vm's Ram is under or overloaded, based on some conditions defined by Predicates given to the VerticalVmScaling, and then request the RAM up or down scaling.
        Parameters:
        ramVerticalScaling - the VerticalVmScaling to set
        Returns:
        Throws:
        java.lang.IllegalArgumentException - if the given VmScaling is already linked to a Vm. Each VM must have its own VerticalVmScaling objects or none at all.
      • setBwVerticalScaling

        Vm setBwVerticalScaling​(VerticalVmScaling bwVerticalScaling)
                         throws java.lang.IllegalArgumentException
        Sets a VerticalVmScaling that will check if the Vm's Bandwidth is under or overloaded, based on some conditions defined by Predicates given to the VerticalVmScaling, and then request the Bandwidth up or down scaling.
        Parameters:
        bwVerticalScaling - the VerticalVmScaling to set
        Returns:
        Throws:
        java.lang.IllegalArgumentException - if the given VmScaling is already linked to a Vm. Each VM must have its own VerticalVmScaling objects or none at all.
      • setPeVerticalScaling

        Vm setPeVerticalScaling​(VerticalVmScaling peVerticalScaling)
                         throws java.lang.IllegalArgumentException
        Sets a VerticalVmScaling that will check if the Vm's Pe is under or overloaded, based on some conditions defined by Predicates given to the VerticalVmScaling, and then request the Pe up or down scaling.

        The Pe scaling is performed by adding or removing PEs to/from the VM. Added PEs will have the same MIPS than the already existing ones.

        Parameters:
        peVerticalScaling - the VerticalVmScaling to set
        Returns:
        Throws:
        java.lang.IllegalArgumentException - if the given VmScaling is already linked to a Vm. Each VM must have its own VerticalVmScaling objects or none at all.
      • getRamVerticalScaling

        VerticalVmScaling getRamVerticalScaling()
        Gets a VerticalVmScaling that will check if the Vm's RAM is overloaded, based on some conditions defined by a Predicate given to the VerticalVmScaling, and then request the RAM up scaling.
        Returns:
      • getBwVerticalScaling

        VerticalVmScaling getBwVerticalScaling()
        Gets a VerticalVmScaling that will check if the Vm's Bandwidth is overloaded, based on some conditions defined by a Predicate given to the VerticalVmScaling, and then request the BW up scaling.
        Returns:
      • getPeVerticalScaling

        VerticalVmScaling getPeVerticalScaling()
        Gets a VerticalVmScaling that will check if the Vm's Pe is overloaded, based on some conditions defined by a Predicate given to the VerticalVmScaling, and then request the RAM up scaling.
        Returns:
      • getProcessor

        Processor getProcessor()
        Gets the Processor of this VM. It is its Virtual CPU which may be compounded of multiple Pes.
        Returns:
      • getStartTime

        double getStartTime()
        Gets the time the VM was created into some Host for the first time (in seconds). The value -1 means the VM was not created yet.
        Returns:
      • setStartTime

        Vm setStartTime​(double startTime)
        Sets the time the VM was created into some Host for the first time. The value -1 means the VM was not created yet.
        Parameters:
        startTime - the start time to set (in seconds)
        Returns:
      • getStopTime

        double getStopTime()
        Gets the time the VM was destroyed into the last Host it executed (in seconds). The value -1 means the VM has not stopped or has not even started yet.
        Returns:
        See Also:
        isCreated()
      • getTotalExecutionTime

        double getTotalExecutionTime()
        Gets the total time (in seconds) the Vm spent executing. It considers the entire VM execution even if in different Hosts it has possibly migrated.
        Returns:
        the VM total execution time if the VM has stopped, the time executed so far if the VM is running yet, or 0 if it hasn't started.
      • setStopTime

        Vm setStopTime​(double stopTime)
        Sets the time the VM was destroyed into the last Host it executed (in seconds). The value -1 means the VM has not stopped or has not even started yet.
        Parameters:
        stopTime - the stop time to set (in seconds)
        Returns:
        See Also:
        isCreated()
      • getLastBusyTime

        double getLastBusyTime()
        Gets the last time the VM was running some Cloudlet.
        Returns:
        the last busy time (in seconds)
      • getIdleInterval

        double getIdleInterval()
        Gets the last interval the VM was idle (without running any Cloudlet).
        Returns:
        the last idle time interval (in seconds)
      • isIdle

        boolean isIdle()
        Checks if the VM is currently idle.
        Returns:
        true if the VM currently idle, false otherwise
      • isIdleEnough

        boolean isIdleEnough​(double time)
        Checks if the VM has been idle for a given amount of time (in seconds).
        Parameters:
        time - the time interval to check if the VM has been idle (in seconds). If time is zero, it will be checked if the VM is currently idle.
        Returns:
        true if the VM has been idle as long as the given time, false if it's active of isn't idle as long enough