public class CloudSim extends Object implements Simulation
Modifier and Type | Field and Description |
---|---|
static String |
VERSION
CloudSim Plus current version.
|
ANY_EVT, NULL
Constructor and Description |
---|
CloudSim()
Creates a CloudSim simulation.
|
CloudSim(double minTimeBetweenEvents)
Creates a CloudSim simulation that tracks events happening in a time interval
as little as the minTimeBetweenEvents parameter.
|
Modifier and Type | Method and Description |
---|---|
void |
abort()
Aborts the simulation without finishing the processing
of entities in the
entities list , what may give
unexpected results. |
void |
addEntity(CloudSimEntity e)
Adds a new entity to the simulation.
|
Simulation |
addOnClockTickListener(EventListener<EventInfo> listener)
Adds a
EventListener object that will be notified every time when the
simulation clock advances. |
Simulation |
addOnEventProcessingListener(EventListener<SimEvent> listener)
Adds a
EventListener object that will be notified when any event
is processed by CloudSim. |
Simulation |
addOnSimulationPausedListener(EventListener<EventInfo> listener)
Adds an
EventListener object that will be notified when the simulation is paused. |
SimEvent |
cancel(SimEntity src,
Predicate<SimEvent> p)
Cancels the first event from the future event queue that matches a given predicate
and was sent by a given entity, then removes it from the queue.
|
boolean |
cancelAll(SimEntity src,
Predicate<SimEvent> p)
Cancels all events from the future event queue that matches a given predicate
and were sent by a given entity, then removes those ones from the queue.
|
double |
clock()
Gets the current simulation time in seconds.
|
double |
clockInHours()
Gets the current simulation time in hours.
|
double |
clockInMinutes()
Gets the current simulation time in minutes.
|
SimEvent |
findFirstDeferred(SimEntity dest,
Predicate<SimEvent> p)
Find first deferred event matching a predicate.
|
Calendar |
getCalendar()
Gets a new copy of initial simulation Calendar.
|
CloudInformationService |
getCloudInfoService()
Gets the
CloudInformationService . |
Set<Datacenter> |
getDatacenterList()
Sends a request to Cloud Information Service (CIS) entity to get the list
of all Cloud Datacenter IDs.
|
List<SimEntity> |
getEntityList()
Returns a read-only list of entities created for the simulation.
|
double |
getMinTimeBetweenEvents()
Returns the minimum time between events (in seconds).
|
NetworkTopology |
getNetworkTopology()
Gets the network topology used for Network simulations.
|
long |
getNumberOfFutureEvents(Predicate<SimEvent> predicate)
Gets the number of events in the future queue
which match a given predicate.
|
int |
getNumEntities()
Get the current number of entities in the simulation.
|
void |
holdEntity(SimEntity src,
long delay)
Holds an entity for some time.
|
boolean |
isPaused()
Checks if the simulation is paused.
|
boolean |
isRunning()
Check if the simulation is still running.
|
boolean |
isTerminationTimeSet() |
boolean |
isTimeToTerminateSimulationUnderRequest() |
boolean |
pause()
Requests the simulation to be paused as soon as possible.
|
boolean |
pause(double time)
Requests the simulation to be paused at a given time.
|
void |
pauseEntity(SimEntity src,
double delay)
Pauses an entity for some time.
|
boolean |
removeOnClockTickListener(EventListener<? extends EventInfo> listener)
Removes a listener from the onClockTickListener List.
|
boolean |
removeOnEventProcessingListener(EventListener<SimEvent> listener)
Removes a listener from the onEventProcessingListener List.
|
boolean |
removeOnSimulationPausedListener(EventListener<EventInfo> listener)
Removes a listener from the onSimulationPausedListener List.
|
boolean |
resume()
This method is called if one wants to resume the simulation that has
previously been paused.
|
SimEvent |
select(SimEntity dest,
Predicate<SimEvent> p)
Selects the first deferred event that matches a given predicate
and removes it from the queue.
|
void |
send(SimEntity src,
SimEntity dest,
double delay,
int tag,
Object data)
Sends an event from one entity to another.
|
void |
sendFirst(SimEntity src,
SimEntity dest,
double delay,
int tag,
Object data)
Sends an event from one entity to another, adding it to the beginning of the queue in order to give priority to it.
|
void |
sendNow(SimEntity src,
SimEntity dest,
int tag,
Object data)
Sends an event from one entity to another without delaying
the message.
|
void |
setNetworkTopology(NetworkTopology networkTopology)
Sets the network topology used for Network simulations.
|
double |
start()
Starts simulation execution and waits for
all entities to finish, i.e.
|
boolean |
terminate()
Forces the termination of the simulation before it ends.
|
boolean |
terminateAt(double time)
Schedules the termination of the simulation for a given time (in seconds).
|
void |
wait(CloudSimEntity src,
Predicate<SimEvent> p)
Sets the state of an entity to
SimEntity.State.WAITING ,
making it to wait for events that satisfy a given predicate. |
long |
waiting(SimEntity dest,
Predicate<SimEvent> p)
Gets the number of events in the deferred event queue that are targeted to a given entity and
match a given predicate.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
setIdForEntitiesWithoutOne, setIdForEntitiesWithoutOne
public static final String VERSION
public CloudSim()
CloudInformationService
,
CloudSim(double)
public CloudSim(double minTimeBetweenEvents)
CloudInformationService
.minTimeBetweenEvents
- the minimal period between events. Events
within shorter periods after the last event are discarded.CloudInformationService
public double start()
Simulation
Note: This method should be called just after all the entities have been setup and added. The method blocks until the simulation is ended.
start
in interface Simulation
public boolean isTimeToTerminateSimulationUnderRequest()
isTimeToTerminateSimulationUnderRequest
in interface Simulation
public boolean terminate()
Simulation
terminate
in interface Simulation
public boolean terminateAt(double time)
Simulation
If a termination time is set, the simulation stays running even
if there is no event to process.
It keeps waiting for new dynamic events, such as the creation
of Cloudlets and VMs at runtime.
If no event happens, the clock is increased to simulate time passing.
The clock increment is defined according to: (i) the lower Datacenter.getSchedulingInterval()
between existing Datacenters; or (ii) Simulation.getMinTimeBetweenEvents()
in case
no Datacenter
has its schedulingInterval set.
terminateAt
in interface Simulation
time
- the time at which the simulation has to be terminated (in seconds)public double getMinTimeBetweenEvents()
Simulation
getMinTimeBetweenEvents
in interface Simulation
public Calendar getCalendar()
Simulation
getCalendar
in interface Simulation
public CloudInformationService getCloudInfoService()
Simulation
CloudInformationService
.getCloudInfoService
in interface Simulation
public Set<Datacenter> getDatacenterList()
Simulation
getDatacenterList
in interface Simulation
public double clock()
Simulation
clock
in interface Simulation
Simulation.isRunning()
public double clockInMinutes()
Simulation
clockInMinutes
in interface Simulation
Simulation.isRunning()
public double clockInHours()
Simulation
clockInHours
in interface Simulation
Simulation.isRunning()
public int getNumEntities()
Simulation
getNumEntities
in interface Simulation
public List<SimEntity> getEntityList()
Simulation
getEntityList
in interface Simulation
public void addEntity(CloudSimEntity e)
Simulation
CloudSimEntity
object
register itself when it is instantiated.addEntity
in interface Simulation
e
- The new entitypublic void sendNow(SimEntity src, SimEntity dest, int tag, Object data)
Simulation
sendNow
in interface Simulation
src
- entity that scheduled the eventdest
- entity that the event will be sent totag
- the tag
that classifies the eventdata
- the data
to be sent inside the eventpublic void send(SimEntity src, SimEntity dest, double delay, int tag, Object data)
Simulation
send
in interface Simulation
src
- entity that scheduled the eventdest
- entity that the event will be sent todelay
- How many seconds after the current simulation time the event should be senttag
- the tag
that classifies the eventdata
- the data
to be sent inside the eventpublic void sendFirst(SimEntity src, SimEntity dest, double delay, int tag, Object data)
Simulation
sendFirst
in interface Simulation
src
- entity that scheduled the eventdest
- entity that the event will be sent todelay
- How many seconds after the current simulation time the event should be senttag
- the tag
that classifies the eventdata
- the data
to be sent inside the eventpublic void wait(CloudSimEntity src, Predicate<SimEvent> p)
Simulation
SimEntity.State.WAITING
,
making it to wait for events that satisfy a given predicate.
Only such events will be passed to the entity.
This is done to avoid unnecessary context Datacenter.wait
in interface Simulation
src
- entity that scheduled the eventp
- the event selection predicatepublic long waiting(SimEntity dest, Predicate<SimEvent> p)
Simulation
waiting
in interface Simulation
dest
- Id of entity that the event has to be sent top
- the event selection predicatepublic SimEvent select(SimEntity dest, Predicate<SimEvent> p)
Simulation
select
in interface Simulation
dest
- entity that the event has to be sent top
- the event selection predicateSimEvent.NULL
if not foundpublic SimEvent findFirstDeferred(SimEntity dest, Predicate<SimEvent> p)
Simulation
findFirstDeferred
in interface Simulation
dest
- Id of entity that the event has to be sent top
- the event selection predicateSimEvent.NULL
if not foundpublic SimEvent cancel(SimEntity src, Predicate<SimEvent> p)
Simulation
cancel
in interface Simulation
src
- Id of entity that scheduled the eventp
- the event selection predicateSimEvent.NULL
if not foundpublic boolean cancelAll(SimEntity src, Predicate<SimEvent> p)
Simulation
cancelAll
in interface Simulation
src
- Id of entity that scheduled the eventp
- the event selection predicatepublic boolean isRunning()
Simulation
is paused
,
the method returns true to indicate that the simulation is
in fact active yet.
This method should be used by entities to check if they should continue executing.
isRunning
in interface Simulation
public boolean pause()
Simulation
pause
in interface Simulation
public boolean pause(double time)
Simulation
pause
in interface Simulation
time
- the time at which the simulation has to be pausedpublic boolean resume()
Simulation
resume
in interface Simulation
public void pauseEntity(SimEntity src, double delay)
Simulation
pauseEntity
in interface Simulation
src
- id of entity to be pauseddelay
- the time period for which the entity will be inactivepublic void holdEntity(SimEntity src, long delay)
Simulation
holdEntity
in interface Simulation
src
- id of entity to be helddelay
- How many seconds after the current time the entity has to be heldpublic long getNumberOfFutureEvents(Predicate<SimEvent> predicate)
Simulation
getNumberOfFutureEvents
in interface Simulation
predicate
- the predicate to filter the list of future events.public boolean isTerminationTimeSet()
isTerminationTimeSet
in interface Simulation
public void abort()
Simulation
entities list
, what may give
unexpected results.
Use this method just if you want to abandon the simulation an usually ignore the results.
abort
in interface Simulation
public boolean isPaused()
Simulation
isPaused
in interface Simulation
public final Simulation addOnSimulationPausedListener(EventListener<EventInfo> listener)
Simulation
EventListener
object that will be notified when the simulation is paused.
When this Listener is notified, it will receive an EventInfo
informing
the time the pause occurred.
This object is just information about the event that happened. In fact, it isn't generated an actual for a pause event because there is not need for that.
addOnSimulationPausedListener
in interface Simulation
listener
- the event listener to addpublic boolean removeOnSimulationPausedListener(EventListener<EventInfo> listener)
Simulation
removeOnSimulationPausedListener
in interface Simulation
listener
- the listener to removepublic final Simulation addOnEventProcessingListener(EventListener<SimEvent> listener)
Simulation
EventListener
object that will be notified when any event
is processed by CloudSim. When this Listener is notified, it will receive
the SimEvent
that was processed.addOnEventProcessingListener
in interface Simulation
listener
- the event listener to addpublic boolean removeOnEventProcessingListener(EventListener<SimEvent> listener)
Simulation
removeOnEventProcessingListener
in interface Simulation
listener
- the listener to removepublic Simulation addOnClockTickListener(EventListener<EventInfo> listener)
Simulation
EventListener
object that will be notified every time when the
simulation clock advances. Notifications are sent in a second interval to avoid notification flood.
Thus, if the clock changes, for instance, from 1.0, to 1.1, 2.0, 2.1, 2.2, 2.5 and then 3.2,
notifications will just be sent for the times 1, 2 and 3 that represent the integer
part of the simulation time.addOnClockTickListener
in interface Simulation
listener
- the event listener to addpublic boolean removeOnClockTickListener(EventListener<? extends EventInfo> listener)
Simulation
removeOnClockTickListener
in interface Simulation
listener
- the listener to removepublic NetworkTopology getNetworkTopology()
Simulation
getNetworkTopology
in interface Simulation
public void setNetworkTopology(NetworkTopology networkTopology)
Simulation
setNetworkTopology
in interface Simulation
networkTopology
- the network topology to setCopyright © 2015–2018 Systems, Security and Image Communication Lab - Instituto de Telecomunicações (IT) - Universidade da Beira Interior (UBI) - Instituto Federal de Educação Ciência e Tecnologia do Tocantins (IFTO). All rights reserved.