public class CloudSim
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected static DeferredQueue |
deferred
The deferred event queue.
|
protected static FutureQueue |
future
The future event queue.
|
static PredicateAny |
SIM_ANY
A standard predicate that matches any event.
|
static PredicateNone |
SIM_NONE
A standard predicate that does not match any events.
|
| Constructor and Description |
|---|
CloudSim() |
| Modifier and Type | Method and Description |
|---|---|
static void |
abruptallyTerminate()
Abruptally terminate.
|
static void |
addEntity(SimEntity e)
Add a new entity to the simulation.
|
protected static void |
addEntityDynamically(SimEntity e)
Internal method used to add a new entity to the simulation when the simulation is running.
|
static SimEvent |
cancel(int src,
Predicate p)
Removes an event from the event queue.
|
static boolean |
cancelAll(int src,
Predicate p)
Removes all events that match a given predicate from the future event queue returns true if
at least one event has been cancelled; false otherwise.
|
static double |
clock()
Get the current simulation time.
|
static SimEvent |
findFirstDeferred(int src,
Predicate p)
Find first deferred event matching a predicate.
|
static void |
finishSimulation()
Internal method that allows the entities to terminate.
|
static int |
getCloudInfoServiceEntityId()
Gets the entity ID of CloudInformationService.
|
static java.util.List<java.lang.Integer> |
getCloudResourceList()
Sends a request to Cloud Information Service (GIS) entity to get the list of all Cloud
hostList.
|
static SimEntity |
getEntity(int id)
Get the entity with a given id.
|
static SimEntity |
getEntity(java.lang.String name)
Get the entity with a given name.
|
static int |
getEntityId(java.lang.String name)
Get the id of an entity with a given name.
|
static java.util.List<SimEntity> |
getEntityList()
Returns a list of entities created for the simulation.
|
static java.lang.String |
getEntityName(int entityID)
Gets name of the entity given its entity ID.
|
static java.lang.String |
getEntityName(java.lang.Integer entityID)
Gets name of the entity given its entity ID.
|
static double |
getMinTimeBetweenEvents()
Returns the minimum time between events.
|
static int |
getNumEntities()
Get the current number of entities in the simulation.
|
static java.util.Calendar |
getSimulationCalendar()
Gets a new copy of initial simulation Calendar.
|
static void |
hold(int src,
long delay)
Used to hold an entity for some time.
|
static void |
init(int numUser,
java.util.Calendar cal,
boolean traceFlag)
Initialises CloudSim parameters.
|
static void |
init(int numUser,
java.util.Calendar cal,
boolean traceFlag,
double periodBetweenEvents)
Initialises CloudSim parameters.
|
protected static void |
initialize()
Initialise the simulation for stand alone simulations.
|
static boolean |
isPaused()
Checks if is paused.
|
static void |
pause(int src,
double delay)
Used to pause an entity for some time.
|
static boolean |
pauseSimulation()
This method is called if one wants to pause the simulation.
|
static boolean |
pauseSimulation(long time)
This method is called if one wants to pause the simulation at a given time.
|
static boolean |
resumeSimulation()
This method is called if one wants to resume the simulation that has previously been paused.
|
static double |
run()
Start the simulation running.
|
static boolean |
runClockTick()
Internal method used to run one tick of the simulation.
|
static boolean |
running()
Check if the simulation is still running.
|
static void |
runStart()
Internal method used to start the simulation.
|
static void |
runStop()
Internal method used to stop the simulation.
|
static SimEvent |
select(int src,
Predicate p)
Selects an event matching a predicate.
|
static void |
send(int src,
int dest,
double delay,
int tag,
java.lang.Object data)
Used to send an event from one entity to another.
|
static void |
sendFirst(int src,
int dest,
double delay,
int tag,
java.lang.Object data)
Used to send an event from one entity to another, with priority in the queue.
|
static double |
startSimulation()
Starts the execution of CloudSim simulation.
|
static void |
stopSimulation()
Stops Cloud Simulation (based on
Simulation#runStop()). |
static boolean |
terminateSimulation()
This method is called if one wants to terminate the simulation.
|
static boolean |
terminateSimulation(double time)
This method is called if one wants to terminate the simulation at a given time.
|
static void |
wait(int src,
Predicate p)
Sets an entity's state to be waiting.
|
static int |
waiting(int d,
Predicate p)
Checks if events for a specific entity are present in the deferred event queue.
|
protected static FutureQueue future
protected static DeferredQueue deferred
public static final PredicateAny SIM_ANY
public static final PredicateNone SIM_NONE
public static void init(int numUser,
java.util.Calendar cal,
boolean traceFlag)
Inside this method, it will create the following CloudSim entities:
numUser - the number of User Entities created. This parameters indicates that
gridsim.CloudSimShutdown first waits for all user entities's
END_OF_SIMULATION signal before issuing terminate signal to other entitiescal - starting time for this simulation. If it is null, then the time will be
taken from Calendar.getInstance()traceFlag - true if CloudSim trace need to be writtengridsim.CloudSimShutdown,
CloudInformationService.CloudInformationServicepublic static void init(int numUser,
java.util.Calendar cal,
boolean traceFlag,
double periodBetweenEvents)
Inside this method, it will create the following CloudSim entities:
numUser - the number of User Entities created. This parameters indicates that
gridsim.CloudSimShutdown first waits for all user entities's
END_OF_SIMULATION signal before issuing terminate signal to other entitiescal - starting time for this simulation. If it is null, then the time will be
taken from Calendar.getInstance()traceFlag - true if CloudSim trace need to be writtenperiodBetweenEvents - - the minimal period between events. Events within shorter periods
after the last event are discarded.gridsim.CloudSimShutdown,
CloudInformationService.CloudInformationServicepublic static double startSimulation()
throws java.lang.NullPointerException
Note: This method should be called after all the entities have been setup and added.
java.lang.NullPointerException - This happens when creating this entity before initialising
CloudSim package or this entity name is null or empty.gridsim.CloudSim#init(int, Calendar, boolean)public static void stopSimulation()
throws java.lang.NullPointerException
Simulation#runStop()). This should be only called if
any of the user defined entities explicitly want to terminate simulation during
execution.java.lang.NullPointerException - This happens when creating this entity before initialising
CloudSim package or this entity name is null or emptygridsim.CloudSim#init(int, Calendar, boolean),
Simulation#runStop()public static boolean terminateSimulation()
public static boolean terminateSimulation(double time)
time - the time at which the simulation has to be terminatedpublic static double getMinTimeBetweenEvents()
public static java.util.Calendar getSimulationCalendar()
gridsim.CloudSim#init(int, Calendar, boolean, String[], String[], String),
gridsim.CloudSim#init(int, Calendar, boolean)public static int getCloudInfoServiceEntityId()
public static java.util.List<java.lang.Integer> getCloudResourceList()
protected static void initialize()
public static double clock()
public static int getNumEntities()
public static SimEntity getEntity(int id)
id - the entity's unique id numberpublic static SimEntity getEntity(java.lang.String name)
name - The entity's namepublic static int getEntityId(java.lang.String name)
name - The entity's namepublic static java.lang.String getEntityName(int entityID)
entityID - the entity IDpublic static java.lang.String getEntityName(java.lang.Integer entityID)
entityID - the entity IDpublic static java.util.List<SimEntity> getEntityList()
public static void addEntity(SimEntity e)
e - The new entityprotected static void addEntityDynamically(SimEntity e)
e - The new entitypublic static boolean runClockTick()
public static void runStop()
public static void hold(int src,
long delay)
src - the srcdelay - the delaypublic static void pause(int src,
double delay)
src - the srcdelay - the delaypublic static void send(int src,
int dest,
double delay,
int tag,
java.lang.Object data)
src - the srcdest - the destdelay - the delaytag - the tagdata - the datapublic static void sendFirst(int src,
int dest,
double delay,
int tag,
java.lang.Object data)
src - the srcdest - the destdelay - the delaytag - the tagdata - the datapublic static void wait(int src,
Predicate p)
src - the srcp - the ppublic static int waiting(int d,
Predicate p)
d - the dp - the ppublic static SimEvent select(int src, Predicate p)
src - the srcp - the ppublic static SimEvent findFirstDeferred(int src, Predicate p)
src - the srcp - the ppublic static SimEvent cancel(int src, Predicate p)
src - the srcp - the ppublic static boolean cancelAll(int src,
Predicate p)
src - the srcp - the ppublic static void runStart()
public static boolean running()
public static boolean pauseSimulation()
public static boolean pauseSimulation(long time)
time - the time at which the simulation has to be pausedpublic static boolean resumeSimulation()
public static double run()
public static void finishSimulation()
public static void abruptallyTerminate()
public static boolean isPaused()