Package org.cloudbus.cloudsim.core
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
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
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptiondouble
Gets the time the entity was shutdown (in seconds).Gets the CloudSim instance that represents the simulation to each the Entity belongs to.double
Gets the time the entity was started.getState()
Gets the entity state.boolean
isAlive()
Checks if the entity is alive, i.e, it's not finished.boolean
Checks if the entity is finished or not.boolean
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, CloudSimTag tag) Sends an event from the entity to itself with no data.boolean
schedule
(double delay, CloudSimTag tag, Object data) Sends an event from the entity to itself.default boolean
schedule
(CloudSimTag tag) Sends an event from the entity to itself with no delay.boolean
schedule
(CloudSimTag 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, CloudSimTag tag) Sends an event to another entity with no attached data.boolean
schedule
(SimEntity dest, double delay, CloudSimTag tag, Object data) Sends an event to another entity.Sets the Entity name.setSimulation
(Simulation simulation) Sets the CloudSim instance that represents the simulation the Entity belongs to.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
-
Field Details
-
NULL
An attribute that implements the Null Object Design Pattern forSimEntity
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 entityisAlive()
yet, the method returns -1.- Returns:
-
getState
SimEntity.State getState()Gets the entity state.- Returns:
- the state
-
setState
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 belongs to.- Returns:
-
setSimulation
Sets the CloudSim instance that represents the simulation the Entity belongs to.- Parameters:
simulation
- The simulation instance the Entity is related to- Returns:
-
processEvent
Processes events or services that are available for the entity. This method is invoked by theCloudSim
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
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
Sends an event from the entity to itself with no delay.- Parameters:
tag
- a tag representing the type of event.- Returns:
- true if the event was sent; false if the simulation was not started yet
-
schedule
Sends an event from the entity to itself.- Parameters:
delay
- How many seconds after the current simulation time the event should be senttag
- a tag 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
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 senttag
- a tag representing the type of event.- Returns:
- true if the event was sent; false if the simulation was not started yet
-
schedule
Sends an event to another entity.- Parameters:
dest
- the destination entitydelay
- How many seconds after the current simulation time the event should be senttag
- a tag 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
Sends an event to another entity with no attached data.- Parameters:
dest
- the destination entitydelay
- How many seconds after the current simulation time the event should be senttag
- a tag representing the type of event.- Returns:
- true if the event was sent; false if the simulation was not started yet
-
schedule
Sends an event from the entity to itself with no delay.- Parameters:
tag
- a tag 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 theprocessEvent(SimEvent)
method. -
start
boolean start()Starts the entity during simulation start. This method is invoked by theCloudSim
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 theCloudSim
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
Sets the Entity name.- Parameters:
newName
- the new name- Returns:
- Throws:
IllegalArgumentException
- when the entity name is null or empty
-