SimEntity

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.

Author:Marcos Dias de Assuncao, Manoel Campos da Silva Filho

See also: CloudSimEntity

Fields

NULL

SimEntity NULL

An attribute that implements the Null Object Design Pattern for SimEntity objects.

Methods

getSimulation

Simulation getSimulation()

Gets the CloudSim instance that represents the simulation to each the Entity is related to.

getState

State getState()

Gets the entity state.

Returns:the state

isAlive

boolean isAlive()

Checks if the entity is alive, i.e, it’s not finished.

isFinished

boolean isFinished()

Checks if the entity is finished or not.

isStarted

boolean isStarted()

Checks if the entity already was started or not.

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

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.

See also: .processEvent(SimEvent)

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

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(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

setName

SimEntity setName(String newName)

Sets the Entity name.

Parameters:
  • newName – the new name
Throws:

setSimulation

SimEntity setSimulation(Simulation simulation)

Sets the CloudSim instance that represents the simulation the Entity is related to.

Parameters:
  • simulation – The CloudSim instance that represents the simulation the Entity is related to

setState

SimEntity setState(State state)

shutdownEntity

void shutdownEntity()

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.

start

void start()

Starts the entity during simulation start. This method is invoked by the CloudSim class when the simulation is started.