public class CloudSim extends 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 List<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(String name)
Get the entity with a given name.
|
static int |
getEntityId(String name)
Get the id of an entity with a given name.
|
static List<SimEntity> |
getEntityList()
Returns a list of entities created for the simulation.
|
static String |
getEntityName(int entityID)
Gets name of the entity given its entity ID.
|
static String |
getEntityName(Integer entityID)
Gets name of the entity given its entity ID.
|
static int |
getNumEntities()
Get the current number of entities in the simulation.
|
static 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,
Calendar cal,
boolean traceFlag)
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,
Object data)
Used to send an event from one entity to another.
|
static void |
sendFirst(int src,
int dest,
double delay,
int tag,
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, 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.CloudInformationService
public static double startSimulation() throws NullPointerException
Note: This method should be called after all the entities have been setup and added.
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 NullPointerException
Simulation#runStop()
). This should be only called if
any of the user defined entities explicitly want to terminate simulation during
execution.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 Calendar getSimulationCalendar()
gridsim.CloudSim#init(int, Calendar, boolean, String[], String[], String)
,
gridsim.CloudSim#init(int, Calendar, boolean)
public static int getCloudInfoServiceEntityId()
public static List<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(String name)
name
- The entity's namepublic static int getEntityId(String name)
name
- The entity's namepublic static String getEntityName(int entityID)
entityID
- the entity IDpublic static String getEntityName(Integer entityID)
entityID
- the entity IDpublic static 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, Object data)
src
- the srcdest
- the destdelay
- the delaytag
- the tagdata
- the datapublic static void sendFirst(int src, int dest, double delay, int tag, 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()
Copyright © 2012 The Cloud Computing and Distributed Systems (CLOUDS) Laboratory, The University of Melbourne. All Rights Reserved.