Interface Cloudlet

All Superinterfaces:
ChangeableId, Comparable<Cloudlet>, CustomerEntity, ExecDelayable, Identifiable, Lifetimed, Startable, SubmissionDelayable, UniquelyIdentifiable
All Known Implementing Classes:
CloudletAbstract, CloudletSimple, NetworkCloudlet

public interface Cloudlet extends UniquelyIdentifiable, Comparable<Cloudlet>, CustomerEntity
An interface to be implemented by each class that provides basic features for cloud applications, a.k.a. Cloudlets.

The interface implements the Null Object Design Pattern in order to avoid NullPointerException when using the NULL object instead of attributing null to Cloudlet variables.

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

    • NULL

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

    • addRequiredFile

      boolean addRequiredFile(String fileName)
      Adds a file to the list or required files.
      Parameters:
      fileName - the name of the required file
      Returns:
      true if the file was added (it didn't exist in the list of required files); false otherwise (it did already exist)
    • addRequiredFiles

      boolean addRequiredFiles(List<String> fileNames)
      Adds a list of files to the required files list. Just the files that don't exist yet in the current required list will be added.
      Parameters:
      fileNames - the list of files to be added
      Returns:
      true if at least one file was added; false if no file was added (in the case that all given files already exist in the current required list)
    • deleteRequiredFile

      boolean deleteRequiredFile(String filename)
      Deletes the given filename from the list.
      Parameters:
      filename - the filename to be deleted
      Returns:
      true if the file was found and removed; false if not found
    • hasRequiresFiles

      boolean hasRequiresFiles()
      Checks whether this cloudlet requires any files or not.
      Returns:
      true if required, false otherwise
      See Also:
    • getRequiredFiles

      List<String> getRequiredFiles()
      Gets the list of required files to be used by the cloudlet (if any). The time to transfer these files by the network is considered when placing the cloudlet inside a given VM
      Returns:
      the required files
    • getDcArrivalTime

      double getDcArrivalTime()
      Gets the time the Cloudlet arrived at a Datacenter to be executed.
      Returns:
      the arrival time in seconds.
    • getFileSize

      long getFileSize()
      Returns the input file size of this Cloudlet before execution (in bytes). This size has to be considered the program + input data sizes.
      Returns:
      the input file size of this Cloudlet before execution (in bytes)
    • getOutputSize

      long getOutputSize()
      Returns the output file size of this Cloudlet after execution (in bytes). It is the data produced as result of cloudlet execution that needs to be transferred thought the network to simulate sending response data to the user.
      Returns:
      the output file size of this Cloudlet after execution (in bytes)
    • getStatus

      Cloudlet.Status getStatus()
      Returns:
      the execution status of this Cloudlet.
    • getSubmissionDelay

      double getSubmissionDelay()
      Gets the time (in seconds) that a DatacenterBroker will wait to submit the entity to a Datacenter, in order to request the creation of the object. This is a relative time from the current simulation time.

      If the VM where the Cloudlet will run is submitted with some delay, the DatacenterBroker waits the VM creation. Only after the VM is created, the Cloudlet creation is requested with the delay specified here.

      Specified by:
      getSubmissionDelay in interface SubmissionDelayable
      Returns:
      the submission delay (in seconds)
    • isReturnedToBroker

      boolean isReturnedToBroker()
      Checks if the Cloudlet has finished and returned to the broker, so that the broker is aware about the end of execution of the Cloudlet.
      Returns:
      true if the Cloudlet has finished and returned to the broker, false otherwise
    • registerArrivalInDatacenter

      double registerArrivalInDatacenter()
      Register the arrival time of this Cloudlet into a Datacenter to the current simulation time and returns this time.
      Returns:
      the arrived time set (in seconds); or Startable.NOT_ASSIGNED if the cloudlet is not assigned to a Datacenter
    • getStartTime

      double getStartTime()
      Gets the latest execution start time of this Cloudlet (in seconds). This attribute only stores the latest execution time. Previous execution times are ignored. This time represents the simulation second when the cloudlet started.
      Specified by:
      getStartTime in interface Startable
      Returns:
      the latest execution start time (in seconds)
    • getFinishTime

      double getFinishTime()
      Gets the time when this Cloudlet has completed executing in the latest Datacenter. This time represents the simulation second when the cloudlet finished.
      Specified by:
      getFinishTime in interface CustomerEntity
      Specified by:
      getFinishTime in interface Startable
      Returns:
      the finish time of this Cloudlet (in seconds); or Startable.NOT_ASSIGNED if not finished yet.
    • getJobId

      long getJobId()
      Gets the id of the job that this Cloudlet belongs to, if any. This field is just used for classification. If there is a supposed job that multiple Cloudlets belong to, one can set the job id for all Cloudlets of that job in order to classify them. Besides classification, this field doesn't have any effect.
      Returns:
      the job id; or Startable.NOT_ASSIGNED if the Cloudlet doesn't belong to a job
    • setJobId

      Cloudlet setJobId(long jobId)
      Sets the id of the job that this Cloudlet belongs to, if any. This field is just used for classification. If there is a supposed job that multiple Cloudlets belong to, one can set the job id for all Cloudlets of that job in order to classify them. Besides classification, this field doesn't have any effect.
      Parameters:
      jobId - the job id to set
      Returns:
      this Cloudlet
    • getPriority

      int getPriority()
      Gets the priority of this Cloudlet for scheduling inside a Vm. Each CloudletScheduler implementation can define if it will use this attribute to impose execution priorities or not.

      WARNING: How the priority is interpreted and what is the range of values it accepts depends on the CloudletScheduler that is being used by the Vm running the Cloudlet.

      Returns:
      priority of this cloudlet
      See Also:
    • setPriority

      Cloudlet setPriority(int priority)
      Sets the priority of this Cloudlet for scheduling inside a Vm. Each CloudletScheduler implementation can define if it will use this attribute to impose execution priorities or not.

      WARNING: How the priority is interpreted and what is the range of values it accepts depends on the CloudletScheduler that is being used by the Vm running the Cloudlet.

      Parameters:
      priority - the priority to set
      Returns:
      this Cloudlet
      See Also:
    • getNetServiceLevel

      int getNetServiceLevel()
      Gets the Type of Service (ToS) of IPv4 for sending Cloudlet over the network. It is the ToS this cloudlet receives in the network (applicable to selected CloudletTaskScheduler class only).
      Returns:
      the network service level
    • getPesNumber

      long getPesNumber()
      Gets the number of Processing Elements (Pe)s from the VM, that is required to execute this cloudlet.
      Returns:
      number of PEs
      See Also:
    • getUtilizationModelBw

      UtilizationModel getUtilizationModelBw()
      Returns:
      the utilization model that defines how the cloudlet will use the VM's bandwidth (bw).
    • getUtilizationModelCpu

      UtilizationModel getUtilizationModelCpu()
      Returns:
      the utilization model that defines how the cloudlet will use the VM's CPU.
    • getUtilizationModelRam

      UtilizationModel getUtilizationModelRam()
      Returns:
      the utilization model that defines how the cloudlet will use the VM's RAM.
    • getUtilizationModel

      UtilizationModel getUtilizationModel(Class<? extends ResourceManageable> resourceClass)
      Returns the utilization model for a given resource.
      Parameters:
      resourceClass - the kind of resource to get its UtilizationModel
      Returns:
      the utilization model for a given resource
    • getUtilizationOfCpu

      double getUtilizationOfCpu()
      Gets the utilization of CPU at the current simulation time, that is defined in percentage (from [0 to 1]) or absolute values, depending on the UtilizationModel.getUnit() set for the CPU utilizaton model.
      Returns:
      the CPU utilization in percentage or absolute value
      See Also:
    • getUtilizationOfCpu

      double getUtilizationOfCpu(double time)
      Gets the utilization of CPU at a given time, that is defined in percentage (from [0 to 1]) or absolute values, depending on the UtilizationModel.getUnit() defined for the getUtilizationModelCpu().
      Parameters:
      time - the time to get the utilization
      Returns:
      the CPU utilization in percentage or absolute value
      See Also:
    • getUtilizationOfRam

      double getUtilizationOfRam()
      Gets the utilization of RAM at the current simulation time, that is defined in percentage (from [0 to 1]) or absolute values, depending on the UtilizationModel.getUnit() set for the RAM utilizaton model.
      Returns:
      the RAM utilization in percentage or absolute value
      See Also:
    • getUtilizationOfRam

      double getUtilizationOfRam(double time)
      Gets the utilization of RAM at a given time, that is defined in percentage (from [0 to 1]) or absolute values, depending on the UtilizationModel.getUnit() defined for the getUtilizationModelRam().
      Parameters:
      time - the time to get the utilization
      Returns:
      the RAM utilization in percentage or absolute value
      See Also:
    • getUtilizationOfBw

      double getUtilizationOfBw()
      Gets the utilization of Bandwidth at the current simulation time, that is defined in percentage (from [0 to 1]) or absolute values, depending on the UtilizationModel.getUnit() set for the BW utilizaton model.
      Returns:
      the BW utilization in percentage or absolute value
      See Also:
    • getUtilizationOfBw

      double getUtilizationOfBw(double time)
      Gets the utilization of Bandwidth at a given time, that is defined in percentage (from [0 to 1]) or absolute values, depending on the UtilizationModel.getUnit() defined for the getUtilizationModelBw().
      Parameters:
      time - the time to get the utilization
      Returns:
      the BW utilization in percentage or absolute value
      See Also:
    • getVm

      Vm getVm()
      Returns:
      the Vm that is planned to execute the cloudlet; or Vm.NULL if the Cloudlet was not assigned to a VM yet
    • isBoundToVm

      boolean isBoundToVm()
      Checks whether the Cloudlet is bounded to a specific Vm, meaning that the DatacenterBroker doesn't have to select a VM for it. In this case, the Cloudlet was already bounded to a specific VM and must run on it.
      Returns:
      true if the Cloudlet is bounded to a specific VM, false otherwise
    • getStartWaitTime

      double getStartWaitTime()
      Gets the time (in seconds) the cloudlet had to wait before start executing on a Datacenter.
      Returns:
      the waiting time (in seconds) when the cloudlet waited to execute; or -1 if the cloudlet hasn't started executing yet.
    • isRunning

      default boolean isRunning()
      Checks whether this Cloudlet is still executing.
      Returns:
      true if this Cloudlet is running, false otherwise
    • setFileSize

      Cloudlet setFileSize(long fileSize)
      Sets the input file size of this Cloudlet before execution (in bytes). This size has to be considered the program + input data sizes.
      Parameters:
      fileSize - the size to set (in bytes)
      Returns:
      this Cloudlet
      Throws:
      IllegalArgumentException - when the given size is lower or equal to zero
      See Also:
    • setOutputSize

      Cloudlet setOutputSize(long outputSize)
      Sets the output file size of this Cloudlet after execution (in bytes). It is the data produced as result of cloudlet execution that needs to be transferred thought the network to simulate sending response data to the user.
      Parameters:
      outputSize - the output size to set (in bytes)
      Returns:
      this Cloudlet
      Throws:
      IllegalArgumentException - when the given size is lower or equal to zero
      See Also:
    • setSizes

      Cloudlet setSizes(long size)
      Sets the input and output file sizes of this Cloudlet to the same value (in bytes).
      Parameters:
      size - the value to set (in bytes) for input and output size
      Returns:
      this Cloudlet
      Throws:
      IllegalArgumentException - when the given size is lower or equal to zero
      See Also:
    • setStatus

      boolean setStatus(Cloudlet.Status newStatus)
      Sets the status of this Cloudlet.

      WARNING: This method is just used internally by classes such as CloudletScheduler to update Cloudlet status. Calling it directly might not get the expected result. You have to use the CloudletScheduler that controls the execution of the Cloudlet to change the Cloudlets status. The method is public due to a design issue.

      Parameters:
      newStatus - the status of this Cloudlet
      Returns:
      true if the cloudlet status was changed, i.e, if the newStatus is different from the current status; false otherwise TODO Move to abstract class
    • setNetServiceLevel

      Cloudlet setNetServiceLevel(int netServiceLevel)
      Sets the Type of Service (ToS) for sending this cloudlet over a network.
      Parameters:
      netServiceLevel - the new type of service (ToS) of this cloudlet
      Returns:
      this Cloudlet TODO This attribute is not used and should be removed (we need confirm it is not used)
    • setPesNumber

      Cloudlet setPesNumber(long pesNumber)
      Sets the number of Pes required to run this Cloudlet.
      NOTE: The Cloudlet length is computed only for 1 PE for simplicity.
      For example, consider a Cloudlet that has a length of 500 MI and requires 2 PEs. This means each PE will execute 500 MI of this Cloudlet.
      Parameters:
      pesNumber - number of PEs
      Returns:
      this Cloudlet
      Throws:
      IllegalArgumentException - when the number of PEs is lower or equal to zero
    • setUtilizationModel

      Cloudlet setUtilizationModel(UtilizationModel utilizationModel)
      Sets the same UtilizationModel for defining the usage of Bandwidth, CPU and RAM. To set different utilization models for each one of these resources, use the respective setters.
      Parameters:
      utilizationModel - the new utilization model for BW, CPU and RAM
      Returns:
      this Cloudlet
      See Also:
    • setUtilizationModelBw

      Cloudlet setUtilizationModelBw(UtilizationModel utilizationModelBw)
      Parameters:
      utilizationModelBw - the new utilization model of BW
      Returns:
      this Cloudlet
    • setUtilizationModelCpu

      Cloudlet setUtilizationModelCpu(UtilizationModel utilizationModelCpu)
      Parameters:
      utilizationModelCpu - the new utilization model of CPU
      Returns:
      this Cloudlet
    • setUtilizationModelRam

      Cloudlet setUtilizationModelRam(UtilizationModel utilizationModelRam)
      Parameters:
      utilizationModelRam - the new utilization model of RAM
      Returns:
      this Cloudlet
    • setVm

      Cloudlet setVm(Vm vm)
      Sets the id of Vm that is planned to execute the cloudlet.
      Parameters:
      vm - id of vm to run the cloudlet
      Returns:
      this Cloudlet
    • getLength

      long getLength()
      Gets the execution length of this Cloudlet (in Million Instructions (MI)) that will be executed in each defined Pe.

      In case the length is a negative value, it means the Cloudlet doesn't have a defined length, this way, it keeps running until a CloudSimTag.CLOUDLET_FINISH message is sent to the DatacenterBroker.

      According to this length and the power of the VM processor (in Million Instruction Per Second - MIPS) where the cloudlet will be run, the cloudlet will take a given time to finish processing. For instance, for a cloudlet of 10000 MI running on a processor of 2000 MIPS, the cloudlet will spend 5 seconds using the processor until completed (that may be uninterrupted or not, depending on the scheduling policy).

      Returns:
      the length of this Cloudlet (in MI)
      See Also:
    • setLength

      Cloudlet setLength(long length)
      Sets the execution length of this Cloudlet (in Million Instructions (MI)) that will be executed in each defined PE.

      A negative length means the Cloudlet in fact doesn't have a defined length. This way, it keeps running until a CloudSimTag.CLOUDLET_FINISH message is sent to the DatacenterBroker.

      According to this length and the power of the VM processor (in Million Instruction Per Second - MIPS) where the cloudlet will be run, the cloudlet will take a given time to finish processing. For instance, for a cloudlet of 10000 MI running on a processor of 2000 MIPS, the cloudlet will spend 5 seconds using the processor until completed (that may be uninterrupted or not, depending on the scheduling policy).

      Parameters:
      length - the length (in MI) of this Cloudlet to be executed in a Vm. A negative value means the Cloudlet in fact doesn't have a defined length.
      Returns:
      this Cloudlet
      Throws:
      IllegalArgumentException - when the given length is lower or equal to zero
      See Also:
    • getTotalLength

      long getTotalLength()
      Gets the total length (across all PEs) of this Cloudlet (in MI). It considers the getLength() of the cloudlet will be executed in each Pe defined by getPesNumber().

      For example, setting the cloudletLength as 10000 MI and getPesNumber() to 4, each Pe will execute 10000 MI. Thus, the entire Cloudlet has a total length of 40000 MI.

      Returns:
      the total length of this Cloudlet (in MI)
      See Also:
    • getFinishedLengthSoFar

      long getFinishedLengthSoFar()
      Gets the length of this Cloudlet that has been executed so far from the latest Datacenter (in MI). This method is useful when trying to move this Cloudlet into a different Datacenter or to cancel it.
      Returns:
      the length of a partially executed Cloudlet, or the full Cloudlet length if it is completed (in MI)
    • addFinishedLengthSoFar

      boolean addFinishedLengthSoFar(long partialFinishedMI)
      Adds the partial length of this Cloudlet that has executed so far (in MI).
      Parameters:
      partialFinishedMI - the partial executed length of this Cloudlet (in MI) from the last time span (the last time the Cloudlet execution was updated)
      Returns:
      true if the length is valid and the cloudlet already has assigned to a Datacenter; false otherwise
      See Also:
    • setStartTime

      Startable setStartTime(double clockTime)
      Sets the latest execution start time of this Cloudlet.

      NOTE: The execution start time only holds the latest one. Meaning all previous execution start times are ignored.

      Specified by:
      setStartTime in interface Startable
      Parameters:
      clockTime - the latest execution start time
      Returns:
    • addOnStartListener

      Cloudlet addOnStartListener(EventListener<CloudletVmEventInfo> listener)
      Adds a Listener object that will be notified when the Cloudlet starts executing in some Vm.
      Parameters:
      listener - the listener to add
    • removeOnStartListener

      boolean removeOnStartListener(EventListener<CloudletVmEventInfo> listener)
      Removes a listener from the onStartListener List.
      Parameters:
      listener - the listener to remove
      Returns:
      true if the listener was found and removed; false otherwise
    • addOnUpdateProcessingListener

      Cloudlet addOnUpdateProcessingListener(EventListener<CloudletVmEventInfo> listener)
      Adds a Listener object that will be notified every time the processing of the Cloudlet is updated in its Vm.
      Parameters:
      listener - the listener to add
      See Also:
    • removeOnUpdateProcessingListener

      boolean removeOnUpdateProcessingListener(EventListener<CloudletVmEventInfo> listener)
      Removes a listener from the onUpdateCloudletProcessingListener List.
      Parameters:
      listener - the listener to remove
      Returns:
      true if the listener was found and removed; false otherwise
    • addOnFinishListener

      Cloudlet addOnFinishListener(EventListener<CloudletVmEventInfo> listener)
      Adds a Listener object that will be notified when a cloudlet finishes its execution at a given Vm.
      Parameters:
      listener - the listener to add
      Returns:
    • removeOnFinishListener

      boolean removeOnFinishListener(EventListener<CloudletVmEventInfo> listener)
      Removes a listener from the onCloudletFinishEventListener List
      Parameters:
      listener - the listener to remove
      Returns:
      true if the listener was found and removed; false otherwise
      See Also:
    • notifyOnUpdateProcessingListeners

      void notifyOnUpdateProcessingListeners(double time)
      Notifies all registered listeners about the update on Cloudlet processing.

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

      Parameters:
      time - the time the event happened
    • getBroker

      DatacenterBroker getBroker()
      Gets the DatacenterBroker that represents the owner of this Cloudlet.
      Specified by:
      getBroker in interface CustomerEntity
      Returns:
      the broker or DatacenterBroker.NULL if a broker has not been set yet
    • setBroker

      CustomerEntity setBroker(DatacenterBroker broker)
      Sets a DatacenterBroker that represents the owner of this Cloudlet.
      Specified by:
      setBroker in interface CustomerEntity
      Parameters:
      broker - the DatacenterBroker to set
    • reset

      Cloudlet reset()
      Resets the state of the Cloudlet.
      Returns:
      this Cloudlet
    • getLifeTime

      double getLifeTime()
      Cloudlet Gets lifetime which indicates the maximum execution time, regardless of its length (in MI).
      Specified by:
      getLifeTime in interface Lifetimed
      Returns:
      the lifeTime (in seconds) or Double.MAX_VALUE indicating no lifeTime is set
      See Also:
    • setLifeTime

      Lifetimed setLifeTime(double lifeTime)
      Sets the Cloudlet Sets the lifetime which indicates the maximum execution time. The lifetime must be larger than Datacenter.getSchedulingInterval()..

      The cloudlet will finish execution as soon as possible, after the given lifeTime has passed, since its exec start time.

      Check Vm.setLifeTime(double) for additional details.
      Specified by:
      setLifeTime in interface Lifetimed
      Parameters:
      lifeTime - lifeTime to set (in seconds) or Double.MAX_VALUE to indicate there is no lifeTime
      Returns:
    • setStartupDelay

      ExecDelayable setStartupDelay(double delay)
      Set the time (in seconds) for the entity to finish starting up..

      WARNING: the method currently has no effect on Cloudlets.

      Specified by:
      setStartupDelay in interface ExecDelayable
      Parameters:
      delay -
      Returns:
      See Also:
    • setShutDownDelay

      ExecDelayable setShutDownDelay(double delay)
      Set the time (in seconds) for the entity to finish shutting down..

      WARNING: the method currently has no effect on Cloudlets.

      Specified by:
      setShutDownDelay in interface ExecDelayable
      Parameters:
      delay -
      Returns:
      See Also: