Interface SimEntity

All Superinterfaces:
Cloneable, Comparable<SimEntity>, Identifiable, Nameable, Runnable
All Known Subinterfaces:
Datacenter, DatacenterBroker, SimEntityNullBase, Switch
All Known Implementing Classes:
AbstractSwitch, AggregateSwitch, CloudInformationService, CloudSimEntity, DatacenterBrokerAbstract, DatacenterBrokerBestFit, DatacenterBrokerFirstFit, DatacenterBrokerHeuristic, DatacenterBrokerSimple, DatacenterSimple, EdgeSwitch, HostFaultInjection, NetworkDatacenter, PowerMeter, RootSwitch

public interface SimEntity
extends Nameable, Cloneable, Runnable, Comparable<SimEntity>
An interface that represents a simulation entity. An entity handles events and can send events to other entities.
Since:
CloudSim Plus 1.0
Author:
Marcos Dias de Assuncao, Manoel Campos da Silva Filho
See Also:
CloudSimEntity
  • Nested Class Summary

    Nested Classes
    Modifier and Type Interface Description
    static class  SimEntity.State
    Defines the event state.
  • Field Summary

    Fields
    Modifier and Type Field Description
    static SimEntity NULL
    An attribute that implements the Null Object Design Pattern for SimEntity objects.
  • Method Summary

    Modifier and Type Method Description
    double getShutdownTime()
    Gets the time the entity was shutdown (in seconds).
    Simulation getSimulation()
    Gets the CloudSim instance that represents the simulation to each the Entity is related to.
    double getStartTime()
    Gets the time the entity was started.
    SimEntity.State getState()
    Gets the entity state.
    boolean isAlive()
    Checks if the entity is alive, i.e, it's not finished.
    boolean isFinished()
    Checks if the entity is finished or not.
    boolean isStarted()
    Checks if the entity already was started or not.
    void processEvent​(SimEvent evt)
    Processes events or services that are available for the entity.
    void run()
    The run loop to process events fired during the simulation.
    boolean schedule​(double delay, int tag)
    Sends an event from the entity to itself with no data.
    boolean schedule​(double delay, int tag, Object data)
    Sends an event from the entity to itself.
    default boolean schedule​(int tag)
    Sends an event from the entity to itself with no delay.
    boolean schedule​(int tag, Object data)
    Sends an event from the entity to itself with no delay.
    boolean schedule​(SimEvent evt)
    Sends an event where all data required is defined inside the event instance.
    boolean schedule​(SimEntity dest, double delay, int tag)
    Sends an event to another entity with no attached data.
    boolean schedule​(SimEntity dest, double delay, int tag, Object data)
    Sends an event to another entity.
    SimEntity setName​(String newName)
    Sets the Entity name.
    SimEntity setSimulation​(Simulation simulation)
    Sets the CloudSim instance that represents the simulation the Entity is related to.
    SimEntity setState​(SimEntity.State state)
    Sets the entity state.
    void shutdown()
    Shuts down the entity.
    boolean start()
    Starts the entity during simulation start.

    Methods inherited from interface java.lang.Comparable

    compareTo

    Methods inherited from interface org.cloudbus.cloudsim.core.Identifiable

    getId

    Methods inherited from interface org.cloudbus.cloudsim.core.Nameable

    getName
  • Field Details

    • NULL

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

    • getStartTime

      double getStartTime()
      Gets the time the entity was started.
      Returns:
      the entity start time or -1 if it haven't started yet.
    • getShutdownTime

      double getShutdownTime()
      Gets the time the entity was shutdown (in seconds). If the entity isAlive() yet, the method returns -1.
      Returns:
    • getState

      SimEntity.State getState()
      Gets the entity state.
      Returns:
      the state
    • setState

      SimEntity setState​(SimEntity.State state)
      Sets the entity state.
      Parameters:
      state - the state to set
    • isStarted

      boolean isStarted()
      Checks if the entity already was started or not.
      Returns:
    • isAlive

      boolean isAlive()
      Checks if the entity is alive, i.e, it's not finished.
      Returns:
    • isFinished

      boolean isFinished()
      Checks if the entity is finished or not.
      Returns:
    • getSimulation

      Simulation getSimulation()
      Gets the CloudSim instance that represents the simulation to each the Entity is related to.
      Returns:
    • setSimulation

      SimEntity setSimulation​(Simulation simulation)
      Sets the CloudSim instance that represents the simulation the Entity is related to.
      Parameters:
      simulation - The simulation instance the Entity is related to
      Returns:
    • processEvent

      void processEvent​(SimEvent evt)
      Processes events or services that are available for the entity. This method is invoked by the CloudSim class whenever there is an event in the deferred queue, which needs to be processed by the entity.
      Parameters:
      evt - information about the event just happened
    • schedule

      boolean schedule​(SimEvent evt)
      Sends an event where all data required is defined inside the event instance.
      Parameters:
      evt - the event to send
      Returns:
      true if the event was sent, false if the simulation was not started yet
    • schedule

      default boolean schedule​(int tag)
      Sends an event from the entity to itself with no delay.
      Parameters:
      tag - An user-defined number representing the type of event.
      Returns:
      true if the event was sent, false if the simulation was not started yet
    • schedule

      boolean schedule​(double delay, int tag, Object data)
      Sends an event from the entity to itself.
      Parameters:
      delay - How many seconds after the current simulation time the event should be sent
      tag - An user-defined number representing the type of event.
      data - The data to be sent with the event.
      Returns:
      true if the event was sent, false if the simulation was not started yet
    • schedule

      boolean schedule​(double delay, int tag)
      Sends an event from the entity to itself with no data.
      Parameters:
      delay - How many seconds after the current simulation time the event should be sent
      tag - An user-defined number representing the type of event.
      Returns:
      true if the event was sent, false if the simulation was not started yet
    • schedule

      boolean schedule​(SimEntity dest, double delay, int tag, Object data)
      Sends an event to another entity.
      Parameters:
      dest - the destination entity
      delay - How many seconds after the current simulation time the event should be sent
      tag - An user-defined number representing the type of event.
      data - The data to be sent with the event.
      Returns:
      true if the event was sent, false if the simulation was not started yet
    • schedule

      boolean schedule​(SimEntity dest, double delay, int tag)
      Sends an event to another entity with no attached data.
      Parameters:
      dest - the destination entity
      delay - How many seconds after the current simulation time the event should be sent
      tag - An user-defined number representing the type of event.
      Returns:
      true if the event was sent, false if the simulation was not started yet
    • schedule

      boolean schedule​(int tag, Object data)
      Sends an event from the entity to itself with no delay.
      Parameters:
      tag - An user-defined number representing the type of event.
      data - The data to be sent with the event.
      Returns:
      true if the event was sent, false if the simulation was not started yet
    • run

      void run()
      The run loop to process events fired during the simulation. The events that will be processed are defined in the processEvent(SimEvent) method.
      Specified by:
      run in interface Runnable
      See Also:
      processEvent(SimEvent)
    • start

      boolean start()
      Starts the entity during simulation start. This method is invoked by the CloudSim class when the simulation is started.
      Returns:
      true if the entity started successfully, false if it was already started
    • shutdown

      void shutdown()
      Shuts down the entity. This method is invoked by the CloudSim before the simulation finishes. If you want to save data in log files this is the method in which the corresponding code would be placed.
    • setName

      SimEntity setName​(String newName) throws IllegalArgumentException
      Sets the Entity name.
      Parameters:
      newName - the new name
      Returns:
      Throws:
      IllegalArgumentException - when the entity name is null or empty