Class CloudSimEntity
java.lang.Object
org.cloudsimplus.core.CloudSimEntity
- All Implemented Interfaces:
Comparable<SimEntity>,Runnable,Identifiable,Nameable,SimEntity
- Direct Known Subclasses:
AbstractSwitch,CloudInformationService,DatacenterBrokerAbstract,DatacenterSimple,HostFaultInjection,PowerMeter
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.cloudsimplus.core.SimEntity
SimEntity.State -
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncancelEvent(Predicate<SimEvent> predicate) Cancels the first event from the future event queue that matches a given predicate and that was submitted by this entity, then removes it from the queue.intGets the first event waiting in the entity's deferred queue, or if there are none, wait for an event to arrive.getNextEvent(Predicate<SimEvent> predicate) Gets the first event matching a predicate from the deferred queue, or if none match, wait for a matching event to arrive.booleanisAlive()booleanbooleanvoidpause(double delay) Sets the entity to be inactive for a time period.voidrun()Starts the run loop to process events fired during the simulation.voidrun(double until) booleanschedule(double delay, int tag) Sends an event from the entity to itself with no data.booleanSends an event from the entity to itself.booleanSends an event from the entity to itself with no delay.booleanSends an event where all data required is defined inside the event instance.booleanSends an event to another entity with no attached data.booleanSends an event to another entity.voidscheduleFirst(SimEntity dest, double delay, int tag) Sends a high-priority event to another entity and with no attached data.voidscheduleFirst(SimEntity dest, double delay, int tag, Object data) Sends a high-priority event to another entity.voidscheduleFirstNow(SimEntity dest, int tag) Sends a high-priority event to another entity with no attached data and no delay.voidscheduleFirstNow(SimEntity dest, int tag, Object data) Sends a high-priority event to another entity with no delay.voidscheduleNow(SimEntity dest, int tag) Sends an event to another entity with no attached data and no delay.voidscheduleNow(SimEntity dest, int tag, Object data) Sends an event to another entity with no delay.selectEvent(Predicate<SimEvent> predicate) Extracts the first event matching a predicate waiting in the entity's deferred queue.protected voidSends an event/message to another entity by delaying the simulation time from the current time, with a tag representing the event type.protected voidSends an event/message to another entity by delaying the simulation time from the current time, with a tag representing the event type.protected voidSends an event/message to another entity, with a tag representing the event type.protected voidSends an event/message to another entity, with a tag representing the event type.protected voidsetEventBuffer(@NonNull SimEvent evt) Sets the event buffer.protected final voidsetId(int id) Sets the entity id and defines its name based on it.Sets the Entity name.voidshutdown()Shuts down the entity.final booleanstart()Starts the entity during simulation start.protected abstract voidDefines the logic to be performed by the entity when the simulation starts.voidwaitForEvent(Predicate<SimEvent> predicate) Waits for an event matching a specific predicate.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.cloudsimplus.core.Identifiable
getIdMethods inherited from interface org.cloudsimplus.core.SimEntity
getShutdownTime, getSimulation, getStartTime, getState, processEvent, schedule, setState
-
Constructor Details
-
CloudSimEntity
Creates a new entity.- Parameters:
simulation- TheCloudSimPlusinstance that represents the simulation the Entity belongs to- Throws:
IllegalArgumentException- when the entity name is invalid
-
-
Method Details
-
start
public final boolean start()Starts the entity during simulation start. This method is invoked by theCloudSimPlusclass when the simulation is started.. It performs general initialization tasks that are common for every entity and executes the specific entity startup code. -
shutdown
public void shutdown()Description copied from interface:SimEntityShuts down the entity. This method is invoked byCloudSimPlusbefore the simulation finishes. If you want to save data in log files, this is the method in which the corresponding code may be placed. -
startInternal
protected abstract void startInternal()Defines the logic to be performed by the entity when the simulation starts. -
schedule
Description copied from interface:SimEntitySends an event to another entity.- Specified by:
schedulein interfaceSimEntity- 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, according to theCloudSimTagor 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
Description copied from interface:SimEntitySends an event from the entity to itself.- Specified by:
schedulein interfaceSimEntity- Parameters:
delay- How many seconds after the current simulation time the event should be senttag- a tag representing the type of event, according to theCloudSimTagor 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
public boolean schedule(double delay, int tag) Description copied from interface:SimEntitySends an event from the entity to itself with no data.- Specified by:
schedulein interfaceSimEntity- Parameters:
delay- How many seconds after the current simulation time the event should be senttag- a tag representing the type of event, according to theCloudSimTagor some custom one.- Returns:
- true if the event was sent; false if the simulation was not started yet
-
schedule
Description copied from interface:SimEntitySends an event to another entity with no attached data.- Specified by:
schedulein interfaceSimEntity- 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, according to theCloudSimTagor some custom one.- Returns:
- true if the event was sent; false if the simulation was not started yet
-
schedule
Description copied from interface:SimEntitySends an event from the entity to itself with no delay.- Specified by:
schedulein interfaceSimEntity- Parameters:
tag- a tag representing the type of event, according to theCloudSimTagor 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
Description copied from interface:SimEntitySends an event where all data required is defined inside the event instance. -
scheduleNow
Sends an event to another entity with no delay.- Parameters:
dest- the destination entitytag- a tag representing the type of event, according to theCloudSimTagor some custom one.data- the data to be sent with the event, according to the tag
-
scheduleNow
Sends an event to another entity with no attached data and no delay.- Parameters:
dest- the destination entitytag- a tag representing the type of event, according to theCloudSimTagor some custom one.
-
scheduleFirstNow
Sends a high-priority event to another entity with no delay.- Parameters:
dest- the destination entitytag- a tag representing the type of event, according to theCloudSimTagor some custom one.data- The data to be sent with the event, according to the tag
-
scheduleFirstNow
Sends a high-priority event to another entity with no attached data and no delay.- Parameters:
dest- the destination entitytag- a tag representing the type of event, according to theCloudSimTagor some custom one.
-
scheduleFirst
Sends a high-priority event to another entity and 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, according to theCloudSimTagor some custom one.
-
scheduleFirst
Sends a high-priority 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, according to theCloudSimTagor some custom one.data- The data to be sent with the event, according to the tag
-
pause
public void pause(double delay) Sets the entity to be inactive for a time period.- Parameters:
delay- the time period for which the entity will be inactive
-
selectEvent
Extracts the first event matching a predicate waiting in the entity's deferred queue.- Parameters:
predicate- The event selection predicate- Returns:
- the simulation event;
or
SimEvent.NULLif not found or the simulation is not running
-
cancelEvent
Cancels the first event from the future event queue that matches a given predicate and that was submitted by this entity, then removes it from the queue.- Parameters:
predicate- the event selection predicate- Returns:
- the removed event or
SimEvent.NULLif not found
-
getNextEvent
Gets the first event matching a predicate from the deferred queue, or if none match, wait for a matching event to arrive.- Parameters:
predicate- The predicate to match- Returns:
- the simulation event;
or
SimEvent.NULLif not found or the simulation is not running
-
getNextEvent
Gets the first event waiting in the entity's deferred queue, or if there are none, wait for an event to arrive.- Returns:
- the simulation event;
or
SimEvent.NULLif not found or the simulation is not running
-
waitForEvent
-
run
public void run()Description copied from interface:SimEntityStarts the run loop to process events fired during the simulation. The events that will be processed are defined in theSimEntity.processEvent(SimEvent)method. -
run
public void run(double until) -
setName
Description copied from interface:SimEntitySets the Entity name.- Specified by:
setNamein interfaceSimEntity- Parameters:
name- the new name- Returns:
- this entity instance
- Throws:
IllegalArgumentException- when the entity name is null or empty
-
setId
protected final void setId(int id) Sets the entity id and defines its name based on it.- Parameters:
id- the new id
-
setEventBuffer
Sets the event buffer.- Parameters:
evt- the new event buffer
-
send
Sends an event/message to another entity by delaying the simulation time from the current time, with a tag representing the event type.- Parameters:
dest- the destination entitydelay- How many seconds after the current simulation time the event should be sent. If the delay is a negative number, then it will be changed to 0tag- a tag representing the type of event, according to theCloudSimTagor some custom one.data- A reference to data to be sent with the event
-
send
Sends an event/message to another entity by delaying the simulation time from the current time, with a tag representing the event type.- Parameters:
dest- the destination entitydelay- How many seconds after the current simulation time the event should be sent. If the delay is a negative number, then it will be changed to 0tag- a tag representing the type of event, according to theCloudSimTagor some custom one
-
sendNow
Sends an event/message to another entity, with a tag representing the event type.- Parameters:
dest- the destination entitytag- a tag representing the type of event, according to theCloudSimTagor some custom onedata- the data to be sent with the event, according to the tag
-
sendNow
Sends an event/message to another entity, with a tag representing the event type.- Parameters:
dest- the destination entitytag- a tag representing the type of event, according to theCloudSimTagor some custom one
-
isStarted
-
isAlive
-
isFinished
public boolean isFinished()- Specified by:
isFinishedin interfaceSimEntity- Returns:
- true if the entity is finished, false otherwise.
-
compareTo
- Specified by:
compareToin interfaceComparable<SimEntity>
-