Interface SimEntity

All Superinterfaces:
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, 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:
  • Nested Class Summary

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

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

    Modifier and Type
    Method
    Description
    double
     
     
    double
     
     
    boolean
     
    boolean
     
    boolean
     
    void
    Processes events or services that are available for the entity.
    void
    run()
    Starts 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
    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.
    setName(String newName)
    Sets the Entity name.
    setState(@NonNull SimEntity.State state)
    Sets the entity state.
    void
    Shuts down the entity.
    boolean
    Starts the entity during simulation start.

    Methods inherited from interface java.lang.Comparable

    compareTo

    Methods inherited from interface org.cloudsimplus.core.Identifiable

    getId

    Methods inherited from interface org.cloudsimplus.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()
      Returns:
      the time the entity was started (in seconds) or -1 if it hasn't started yet.
    • getShutdownTime

      double getShutdownTime()
      Returns:
      the time the entity was shutdown (in seconds), or -1 if the entity isAlive() yet.
    • getState

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

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

      boolean isStarted()
      Returns:
      true if the entity already was started, false otherwise.
    • isAlive

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

      boolean isFinished()
      Returns:
      true if the entity is finished, false otherwise.
    • getSimulation

      Simulation getSimulation()
      Returns:
      the CloudSimPlus instance that represents the simulation to which the Entity belongs to.
    • processEvent

      void processEvent(SimEvent evt)
      Processes events or services that are available for the entity. This method is invoked, by the CloudSimPlus class, whenever there is an event in the deferred queue that 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 - a tag representing the type of event, according to the CloudSimTag or some custom one.
      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 - a tag representing the type of event, according to the CloudSimTag or some custom one.
      data - The data to be sent with the event, according to the tag
      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 - a tag representing the type of event, according to the CloudSimTag or some custom one.
      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 - a tag representing the type of event, according to the CloudSimTag or some custom one.
      data - The data to be sent with the event, according to the tag
      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 - a tag representing the type of event, according to the CloudSimTag or some custom one.
      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 - a tag representing the type of event, according to the CloudSimTag or some custom one.
      data - The data to be sent with the event, according to the tag
      Returns:
      true if the event was sent; false if the simulation was not started yet
    • run

      void run()
      Starts 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
    • start

      boolean start()
      Starts the entity during simulation start. This method is invoked by the CloudSimPlus 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 CloudSimPlus before the simulation finishes. If you want to save data in log files, this is the method in which the corresponding code may be placed.
    • setName

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