Commit 1c980a4e authored by rodrigo.calheiros's avatar rodrigo.calheiros

CloudSin version String updated to 3.0.

parent 6ef9f1ed
...@@ -30,25 +30,25 @@ import org.cloudbus.cloudsim.core.predicates.PredicateNone; ...@@ -30,25 +30,25 @@ import org.cloudbus.cloudsim.core.predicates.PredicateNone;
* such file are mapped to CloudSim entities. Delay calculated from the BRITE * such file are mapped to CloudSim entities. Delay calculated from the BRITE
* model are added to the messages send through CloudSim. Messages using the old * model are added to the messages send through CloudSim. Messages using the old
* model are converted to the apropriate methods with the correct parameters. * model are converted to the apropriate methods with the correct parameters.
* *
* @author Rodrigo N. Calheiros * @author Rodrigo N. Calheiros
* @author Anton Beloglazov * @author Anton Beloglazov
* @since CloudSim Toolkit 1.0 * @since CloudSim Toolkit 1.0
*/ */
public class CloudSim { public class CloudSim {
/** The Constant CLOUDSIM_VERSION_STRING. */ /** The Constant CLOUDSIM_VERSION_STRING. */
private static final String CLOUDSIM_VERSION_STRING = "2.1.1"; private static final String CLOUDSIM_VERSION_STRING = "3.0";
/** The id of CIS entity. */ /** The id of CIS entity. */
private static int cisId = -1; private static int cisId = -1;
/** The id of CloudSimShutdown entity. */ /** The id of CloudSimShutdown entity. */
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static int shutdownId = -1; private static int shutdownId = -1;
/** The CIS object. */ /** The CIS object. */
private static CloudInformationService cis = null; private static CloudInformationService cis = null;
/** The Constant NOT_FOUND. */ /** The Constant NOT_FOUND. */
private static final int NOT_FOUND = -1; private static final int NOT_FOUND = -1;
...@@ -59,22 +59,28 @@ public class CloudSim { ...@@ -59,22 +59,28 @@ public class CloudSim {
/** The calendar. */ /** The calendar. */
private static Calendar calendar = null; private static Calendar calendar = null;
/** The termination time. */ /** The termination time. */
private static double terminateAt = -1; private static double terminateAt = -1;
/** /**
* Initialises all the common attributes. * Initialises all the common attributes.
* *
* @param _calendar the _calendar * @param _calendar
* @param _traceFlag the _trace flag * the _calendar
* @param numUser number of users * @param _traceFlag
* @throws Exception This happens when creating this entity before initialising * the _trace flag
* CloudSim package or this entity name is <tt>null</tt> or empty * @param numUser
* number of users
* @throws Exception
* This happens when creating this entity before initialising
* CloudSim package or this entity name is <tt>null</tt> or
* empty
* @pre $none * @pre $none
* @post $none * @post $none
*/ */
private static void initCommonVariable(Calendar _calendar, boolean _traceFlag, int numUser) throws Exception { private static void initCommonVariable(Calendar _calendar, boolean _traceFlag, int numUser)
throws Exception {
initialize(); initialize();
// NOTE: the order for the below 3 lines are important // NOTE: the order for the below 3 lines are important
traceFlag = _traceFlag; traceFlag = _traceFlag;
...@@ -102,16 +108,19 @@ public class CloudSim { ...@@ -102,16 +108,19 @@ public class CloudSim {
* <li>CloudSimShutdown * <li>CloudSimShutdown
* </ul> * </ul>
* <p> * <p>
* *
* @param numUser the number of User Entities created. This parameters indicates * @param numUser
* that {@link gridsim.CloudSimShutdown} first waits for all user * the number of User Entities created. This parameters indicates
* entities's END_OF_SIMULATION signal before issuing terminate * that {@link gridsim.CloudSimShutdown} first waits for all user
* signal to other entities * entities's END_OF_SIMULATION signal before issuing terminate
* @param cal starting time for this simulation. If it is <tt>null</tt>, * signal to other entities
* then the time will be taken from * @param cal
* <tt>Calendar.getInstance()</tt> * starting time for this simulation. If it is <tt>null</tt>,
* @param traceFlag <tt>true</tt> if CloudSim trace need to be written * then the time will be taken from
* * <tt>Calendar.getInstance()</tt>
* @param traceFlag
* <tt>true</tt> if CloudSim trace need to be written
*
* @see gridsim.CloudSimShutdown * @see gridsim.CloudSimShutdown
* @see CloudInformationService.CloudInformationService * @see CloudInformationService.CloudInformationService
* @pre numUser >= 0 * @pre numUser >= 0
...@@ -142,11 +151,12 @@ public class CloudSim { ...@@ -142,11 +151,12 @@ public class CloudSim {
* <p> * <p>
* <b>Note</b>: This method should be called after all the entities have * <b>Note</b>: This method should be called after all the entities have
* been setup and added. * been setup and added.
* *
* @return the double * @return the double
* @throws NullPointerException This happens when creating this entity before initialising * @throws NullPointerException
* CloudSim package or this entity name is <tt>null</tt> or * This happens when creating this entity before initialising
* empty. * CloudSim package or this entity name is <tt>null</tt> or
* empty.
* @see gridsim.CloudSim#init(int, Calendar, boolean) * @see gridsim.CloudSim#init(int, Calendar, boolean)
* @pre $none * @pre $none
* @post $none * @post $none
...@@ -175,10 +185,12 @@ public class CloudSim { ...@@ -175,10 +185,12 @@ public class CloudSim {
* Stops Cloud Simulation (based on {@link Simulation#runStop()}). This * Stops Cloud Simulation (based on {@link Simulation#runStop()}). This
* should be only called if any of the user defined entities * should be only called if any of the user defined entities
* <b>explicitly</b> want to terminate simulation during execution. * <b>explicitly</b> want to terminate simulation during execution.
* *
* @throws NullPointerException This happens when creating this entity before initialising * @throws NullPointerException
* CloudSim package or this entity name is <tt>null</tt> or empty * This happens when creating this entity before initialising
* * CloudSim package or this entity name is <tt>null</tt> or
* empty
*
* @see gridsim.CloudSim#init(int, Calendar, boolean) * @see gridsim.CloudSim#init(int, Calendar, boolean)
* @see Simulation#runStop() * @see Simulation#runStop()
* @pre $none * @pre $none
...@@ -192,10 +204,10 @@ public class CloudSim { ...@@ -192,10 +204,10 @@ public class CloudSim {
+ "Error - can't stop Cloud Simulation."); + "Error - can't stop Cloud Simulation.");
} }
} }
/** /**
* This method is called if one wants to terminate the simulation. * This method is called if one wants to terminate the simulation.
* *
* @return true, if successful; false otherwise. * @return true, if successful; false otherwise.
*/ */
public static boolean terminateSimulation() { public static boolean terminateSimulation() {
...@@ -205,12 +217,12 @@ public class CloudSim { ...@@ -205,12 +217,12 @@ public class CloudSim {
} }
/** /**
* This method is called if one wants to terminate the simulation at a * This method is called if one wants to terminate the simulation at a given
* given time. * time.
* *
* @param time the time at which the simulation has to be terminated * @param time
* @return true, if successful * the time at which the simulation has to be terminated
* otherwise. * @return true, if successful otherwise.
*/ */
public static boolean terminateSimulation(double time) { public static boolean terminateSimulation(double time) {
if (time <= clock) { if (time <= clock) {
...@@ -223,11 +235,11 @@ public class CloudSim { ...@@ -223,11 +235,11 @@ public class CloudSim {
/** /**
* Gets a new copy of initial simulation Calendar. * Gets a new copy of initial simulation Calendar.
* *
* @return a new copy of Calendar object or if CloudSim hasn't * @return a new copy of Calendar object or if CloudSim hasn't been
* been initialized * initialized
* @see gridsim.CloudSim#init(int, Calendar, boolean, String[], String[], * @see gridsim.CloudSim#init(int, Calendar, boolean, String[], String[],
* String) * String)
* @see gridsim.CloudSim#init(int, Calendar, boolean) * @see gridsim.CloudSim#init(int, Calendar, boolean)
* @pre $none * @pre $none
* @post $none * @post $none
...@@ -244,8 +256,8 @@ public class CloudSim { ...@@ -244,8 +256,8 @@ public class CloudSim {
/** /**
* Gets the entity ID of <tt>CloudInformationService</tt>. * Gets the entity ID of <tt>CloudInformationService</tt>.
* *
* @return the Entity ID or if it is not found * @return the Entity ID or if it is not found
* @pre $none * @pre $none
* @post $result >= -1 * @post $result >= -1
*/ */
...@@ -256,9 +268,9 @@ public class CloudSim { ...@@ -256,9 +268,9 @@ public class CloudSim {
/** /**
* Sends a request to Cloud Information Service (GIS) entity to get the list * Sends a request to Cloud Information Service (GIS) entity to get the list
* of all Cloud hostList. * of all Cloud hostList.
* *
* @return A List containing CloudResource ID (as an Integer object) * @return A List containing CloudResource ID (as an Integer object) or if a
* or if a CIS entity hasn't been created before * CIS entity hasn't been created before
* @pre $none * @pre $none
* @post $none * @post $none
*/ */
...@@ -276,13 +288,13 @@ public class CloudSim { ...@@ -276,13 +288,13 @@ public class CloudSim {
private static List<SimEntity> entities; private static List<SimEntity> entities;
/** The future event queue. */ /** The future event queue. */
protected static FutureQueue future; protected static FutureQueue future;
/** The deferred event queue. */ /** The deferred event queue. */
protected static DeferredQueue deferred; protected static DeferredQueue deferred;
/** The simulation clock. */ /** The simulation clock. */
private static double clock; private static double clock;
/** Flag for checking if the simulation is running. */ /** Flag for checking if the simulation is running. */
private static boolean running; private static boolean running;
...@@ -330,7 +342,7 @@ public class CloudSim { ...@@ -330,7 +342,7 @@ public class CloudSim {
/** /**
* Get the current simulation time. * Get the current simulation time.
* *
* @return the simulation time * @return the simulation time
*/ */
public static double clock() { public static double clock() {
...@@ -339,7 +351,7 @@ public class CloudSim { ...@@ -339,7 +351,7 @@ public class CloudSim {
/** /**
* Get the current number of entities in the simulation. * Get the current number of entities in the simulation.
* *
* @return The number of entities * @return The number of entities
*/ */
public static int getNumEntities() { public static int getNumEntities() {
...@@ -348,9 +360,10 @@ public class CloudSim { ...@@ -348,9 +360,10 @@ public class CloudSim {
/** /**
* Get the entity with a given id. * Get the entity with a given id.
* *
* @param id the entity's unique id number * @param id
* @return The entity, or if it could not be found * the entity's unique id number
* @return The entity, or if it could not be found
*/ */
public static SimEntity getEntity(int id) { public static SimEntity getEntity(int id) {
return entities.get(id); return entities.get(id);
...@@ -358,8 +371,9 @@ public class CloudSim { ...@@ -358,8 +371,9 @@ public class CloudSim {
/** /**
* Get the entity with a given name. * Get the entity with a given name.
* *
* @param name The entity's name * @param name
* The entity's name
* @return The entity * @return The entity
*/ */
public static SimEntity getEntity(String name) { public static SimEntity getEntity(String name) {
...@@ -368,8 +382,9 @@ public class CloudSim { ...@@ -368,8 +382,9 @@ public class CloudSim {
/** /**
* Get the id of an entity with a given name. * Get the id of an entity with a given name.
* *
* @param name The entity's name * @param name
* The entity's name
* @return The entity's unique id number * @return The entity's unique id number
*/ */
public static int getEntityId(String name) { public static int getEntityId(String name) {
...@@ -383,9 +398,10 @@ public class CloudSim { ...@@ -383,9 +398,10 @@ public class CloudSim {
/** /**
* Gets name of the entity given its entity ID. * Gets name of the entity given its entity ID.
* *
* @param entityID the entity ID * @param entityID
* @return the Entity name or if this object does not have one * the entity ID
* @return the Entity name or if this object does not have one
* @pre entityID > 0 * @pre entityID > 0
* @post $none * @post $none
*/ */
...@@ -401,9 +417,10 @@ public class CloudSim { ...@@ -401,9 +417,10 @@ public class CloudSim {
/** /**
* Gets name of the entity given its entity ID. * Gets name of the entity given its entity ID.
* *
* @param entityID the entity ID * @param entityID
* @return the Entity name or if this object does not have one * the entity ID
* @return the Entity name or if this object does not have one
* @pre entityID > 0 * @pre entityID > 0
* @post $none * @post $none
*/ */
...@@ -416,7 +433,7 @@ public class CloudSim { ...@@ -416,7 +433,7 @@ public class CloudSim {
/** /**
* Returns a list of entities created for the simulation. * Returns a list of entities created for the simulation.
* *
* @return the entity iterator * @return the entity iterator
*/ */
public static List<SimEntity> getEntityList() { public static List<SimEntity> getEntityList() {
...@@ -433,8 +450,9 @@ public class CloudSim { ...@@ -433,8 +450,9 @@ public class CloudSim {
* Add a new entity to the simulation. This is present for compatibility * Add a new entity to the simulation. This is present for compatibility
* with existing simulations since entities are automatically added to the * with existing simulations since entities are automatically added to the
* simulation upon instantiation. * simulation upon instantiation.
* *
* @param e The new entity * @param e
* The new entity
*/ */
public static void addEntity(SimEntity e) { public static void addEntity(SimEntity e) {
SimEvent evt; SimEvent evt;
...@@ -455,8 +473,9 @@ public class CloudSim { ...@@ -455,8 +473,9 @@ public class CloudSim {
* Internal method used to add a new entity to the simulation when the * Internal method used to add a new entity to the simulation when the
* simulation is running. It should <b>not</b> be called from user * simulation is running. It should <b>not</b> be called from user
* simulations. * simulations.
* *
* @param e The new entity * @param e
* The new entity
*/ */
protected static void addEntityDynamically(SimEntity e) { protected static void addEntityDynamically(SimEntity e) {
if (e == null) { if (e == null) {
...@@ -470,9 +489,8 @@ public class CloudSim { ...@@ -470,9 +489,8 @@ public class CloudSim {
/** /**
* Internal method used to run one tick of the simulation. This method * Internal method used to run one tick of the simulation. This method
* should <b>not</b> be called in simulations. * should <b>not</b> be called in simulations.
* *
* @return true, if successful * @return true, if successful otherwise
* otherwise
*/ */
public static boolean runClockTick() { public static boolean runClockTick() {
SimEntity ent; SimEntity ent;
...@@ -531,9 +549,11 @@ public class CloudSim { ...@@ -531,9 +549,11 @@ public class CloudSim {
/** /**
* Used to hold an entity for some time. * Used to hold an entity for some time.
* *
* @param src the src * @param src
* @param delay the delay * the src
* @param delay
* the delay
*/ */
public static void hold(int src, long delay) { public static void hold(int src, long delay) {
SimEvent e = new SimEvent(SimEvent.HOLD_DONE, clock + delay, src); SimEvent e = new SimEvent(SimEvent.HOLD_DONE, clock + delay, src);
...@@ -543,9 +563,11 @@ public class CloudSim { ...@@ -543,9 +563,11 @@ public class CloudSim {
/** /**
* Used to pause an entity for some time. * Used to pause an entity for some time.
* *
* @param src the src * @param src
* @param delay the delay * the src
* @param delay
* the delay
*/ */
public static void pause(int src, double delay) { public static void pause(int src, double delay) {
SimEvent e = new SimEvent(SimEvent.HOLD_DONE, clock + delay, src); SimEvent e = new SimEvent(SimEvent.HOLD_DONE, clock + delay, src);
...@@ -555,12 +577,17 @@ public class CloudSim { ...@@ -555,12 +577,17 @@ public class CloudSim {
/** /**
* Used to send an event from one entity to another. * Used to send an event from one entity to another.
* *
* @param src the src * @param src
* @param dest the dest * the src
* @param delay the delay * @param dest
* @param tag the tag * the dest
* @param data the data * @param delay
* the delay
* @param tag
* the tag
* @param data
* the data
*/ */
public static void send(int src, int dest, double delay, int tag, Object data) { public static void send(int src, int dest, double delay, int tag, Object data) {
if (delay < 0) { if (delay < 0) {
...@@ -572,13 +599,19 @@ public class CloudSim { ...@@ -572,13 +599,19 @@ public class CloudSim {
} }
/** /**
* Used to send an event from one entity to another, with priority in the queue. * Used to send an event from one entity to another, with priority in the
* * queue.
* @param src the src *
* @param dest the dest * @param src
* @param delay the delay * the src
* @param tag the tag * @param dest
* @param data the data * the dest
* @param delay
* the delay
* @param tag
* the tag
* @param data
* the data
*/ */
public static void sendFirst(int src, int dest, double delay, int tag, Object data) { public static void sendFirst(int src, int dest, double delay, int tag, Object data) {
if (delay < 0) { if (delay < 0) {
...@@ -590,12 +623,15 @@ public class CloudSim { ...@@ -590,12 +623,15 @@ public class CloudSim {
} }
/** /**
* Sets an entity's state to be waiting. The predicate used to wait for an event * Sets an entity's state to be waiting. The predicate used to wait for an
* is now passed to Sim_system. Only events that satisfy the predicate will be * event is now passed to Sim_system. Only events that satisfy the predicate
* passed to the entity. This is done to avoid unnecessary context switches. * will be passed to the entity. This is done to avoid unnecessary context
* * switches.
* @param src the src *
* @param p the p * @param src
* the src
* @param p
* the p
*/ */
public static void wait(int src, Predicate p) { public static void wait(int src, Predicate p) {
entities.get(src).setState(SimEntity.WAITING); entities.get(src).setState(SimEntity.WAITING);
...@@ -606,11 +642,14 @@ public class CloudSim { ...@@ -606,11 +642,14 @@ public class CloudSim {
} }
/** /**
* Checks if events for a specific entity are present in the deferred event queue. * Checks if events for a specific entity are present in the deferred event
* * queue.
* @param d the d *
* @param p the p * @param d
* * the d
* @param p
* the p
*
* @return the int * @return the int
*/ */
public static int waiting(int d, Predicate p) { public static int waiting(int d, Predicate p) {
...@@ -628,10 +667,12 @@ public class CloudSim { ...@@ -628,10 +667,12 @@ public class CloudSim {
/** /**
* Selects an event matching a predicate. * Selects an event matching a predicate.
* *
* @param src the src * @param src
* @param p the p * the src
* * @param p
* the p
*
* @return the sim event * @return the sim event
*/ */
public static SimEvent select(int src, Predicate p) { public static SimEvent select(int src, Predicate p) {
...@@ -649,9 +690,11 @@ public class CloudSim { ...@@ -649,9 +690,11 @@ public class CloudSim {
/** /**
* Find first deferred event matching a predicate. * Find first deferred event matching a predicate.
* *
* @param src the src * @param src
* @param p the p * the src
* @param p
* the p
* @return the sim event * @return the sim event
*/ */
public static SimEvent findFirstDeferred(int src, Predicate p) { public static SimEvent findFirstDeferred(int src, Predicate p) {
...@@ -668,10 +711,12 @@ public class CloudSim { ...@@ -668,10 +711,12 @@ public class CloudSim {
/** /**
* Removes an event from the event queue. * Removes an event from the event queue.
* *
* @param src the src * @param src
* @param p the p * the src
* * @param p
* the p
*
* @return the sim event * @return the sim event
*/ */
public static SimEvent cancel(int src, Predicate p) { public static SimEvent cancel(int src, Predicate p) {
...@@ -689,12 +734,15 @@ public class CloudSim { ...@@ -689,12 +734,15 @@ public class CloudSim {
} }
/** /**
* Removes all events that match a given predicate from the future event queue * Removes all events that match a given predicate from the future event
* returns true if at least one event has been cancelled; false otherwise. * queue returns true if at least one event has been cancelled; false
* * otherwise.
* @param src the src *
* @param p the p * @param src
* * the src
* @param p
* the p
*
* @return true, if successful * @return true, if successful
*/ */
public static boolean cancelAll(int src, Predicate p) { public static boolean cancelAll(int src, Predicate p) {
...@@ -716,8 +764,9 @@ public class CloudSim { ...@@ -716,8 +764,9 @@ public class CloudSim {
/** /**
* Processes an event. * Processes an event.
* *
* @param e the e * @param e
* the e
*/ */
private static void processEvent(SimEvent e) { private static void processEvent(SimEvent e) {
int dest, src; int dest, src;
...@@ -730,50 +779,49 @@ public class CloudSim { ...@@ -730,50 +779,49 @@ public class CloudSim {
// Ok now process it // Ok now process it
switch (e.getType()) { switch (e.getType()) {
case SimEvent.ENULL: case SimEvent.ENULL:
throw new IllegalArgumentException("Event has a null type."); throw new IllegalArgumentException("Event has a null type.");
case SimEvent.CREATE: case SimEvent.CREATE:
SimEntity newe = (SimEntity) e.getData(); SimEntity newe = (SimEntity) e.getData();
addEntityDynamically(newe); addEntityDynamically(newe);
break; break;
case SimEvent.SEND: case SimEvent.SEND:
// Check for matching wait // Check for matching wait
dest = e.getDestination(); dest = e.getDestination();
if (dest < 0) { if (dest < 0) {
throw new IllegalArgumentException( throw new IllegalArgumentException("Attempt to send to a null entity detected.");
"Attempt to send to a null entity detected."); } else {
} else { int tag = e.getTag();
int tag = e.getTag(); dest_ent = entities.get(dest);
dest_ent = entities.get(dest); if (dest_ent.getState() == SimEntity.WAITING) {
if (dest_ent.getState() == SimEntity.WAITING) { Integer destObj = Integer.valueOf(dest);
Integer destObj = Integer.valueOf(dest); Predicate p = waitPredicates.get(destObj);
Predicate p = waitPredicates.get(destObj); if ((p == null) || (tag == 9999) || (p.match(e))) {
if ((p == null) || (tag == 9999) || (p.match(e))) { dest_ent.setEventBuffer((SimEvent) e.clone());
dest_ent.setEventBuffer((SimEvent) e.clone()); dest_ent.setState(SimEntity.RUNNABLE);
dest_ent.setState(SimEntity.RUNNABLE); waitPredicates.remove(destObj);
waitPredicates.remove(destObj);
} else {
deferred.addEvent(e);
}
} else { } else {
deferred.addEvent(e); deferred.addEvent(e);
} }
}
break;
case SimEvent.HOLD_DONE:
src = e.getSource();
if (src < 0) {
throw new IllegalArgumentException("Null entity holding.");
} else { } else {
entities.get(src).setState(SimEntity.RUNNABLE); deferred.addEvent(e);
} }
break; }
break;
case SimEvent.HOLD_DONE:
src = e.getSource();
if (src < 0) {
throw new IllegalArgumentException("Null entity holding.");
} else {
entities.get(src).setState(SimEntity.RUNNABLE);
}
break;
default: default:
break; break;
} }
} }
...@@ -794,19 +842,17 @@ public class CloudSim { ...@@ -794,19 +842,17 @@ public class CloudSim {
/** /**
* Check if the simulation is still running. This method should be used by * Check if the simulation is still running. This method should be used by
* entities to check if they should continue executing. * entities to check if they should continue executing.
* *
* @return if the simulation is still running, * @return if the simulation is still running, otherwise
* otherwise
*/ */
public static boolean running() { public static boolean running() {
return running; return running;
} }
/** /**
* This method is called if one wants to pause the simulation. * This method is called if one wants to pause the simulation.
* *
* @return true, if successful * @return true, if successful otherwise.
* otherwise.
*/ */
public static boolean pauseSimulation() { public static boolean pauseSimulation() {
paused = true; paused = true;
...@@ -816,10 +862,10 @@ public class CloudSim { ...@@ -816,10 +862,10 @@ public class CloudSim {
/** /**
* This method is called if one wants to pause the simulation at a given * This method is called if one wants to pause the simulation at a given
* time. * time.
* *
* @param time the time at which the simulation has to be paused * @param time
* @return true, if successful * the time at which the simulation has to be paused
* otherwise. * @return true, if successful otherwise.
*/ */
public static boolean pauseSimulation(long time) { public static boolean pauseSimulation(long time) {
if (time <= clock) { if (time <= clock) {
...@@ -833,9 +879,8 @@ public class CloudSim { ...@@ -833,9 +879,8 @@ public class CloudSim {
/** /**
* This method is called if one wants to resume the simulation that has * This method is called if one wants to resume the simulation that has
* previously been paused. * previously been paused.
* *
* @return if the simulation has been restarted or or * @return if the simulation has been restarted or or otherwise.
* otherwise.
*/ */
public static boolean resumeSimulation() { public static boolean resumeSimulation() {
paused = false; paused = false;
...@@ -845,12 +890,12 @@ public class CloudSim { ...@@ -845,12 +890,12 @@ public class CloudSim {
} }
return !paused; return !paused;
} }
/** /**
* Start the simulation running. This should be called after all the * Start the simulation running. This should be called after all the
* entities have been setup and added, and their ports linked. * entities have been setup and added, and their ports linked.
* *
* @return the double last clock value * @return the double last clock value
*/ */
public static double run() { public static double run() {
...@@ -861,15 +906,17 @@ public class CloudSim { ...@@ -861,15 +906,17 @@ public class CloudSim {
if (runClockTick() || abruptTerminate) { if (runClockTick() || abruptTerminate) {
break; break;
} }
//this block allows termination of simulation at a specific time // this block allows termination of simulation at a specific time
if (terminateAt > 0.0 && clock >= terminateAt) { if (terminateAt > 0.0 && clock >= terminateAt) {
terminateSimulation(); terminateSimulation();
clock = terminateAt; clock = terminateAt;
break; break;
} }
if (pauseAt != -1 && ((future.size() > 0 && clock <= pauseAt && pauseAt <= future.iterator().next().eventTime()) || future.size() == 0 && pauseAt <= clock)) { if (pauseAt != -1
&& ((future.size() > 0 && clock <= pauseAt && pauseAt <= future.iterator().next()
.eventTime()) || future.size() == 0 && pauseAt <= clock)) {
pauseSimulation(); pauseSimulation();
clock = pauseAt; clock = pauseAt;
} }
...@@ -933,8 +980,9 @@ public class CloudSim { ...@@ -933,8 +980,9 @@ public class CloudSim {
/** /**
* Prints a message about the progress of the simulation. * Prints a message about the progress of the simulation.
* *
* @param message the message * @param message
* the message
*/ */
private static void printMessage(String message) { private static void printMessage(String message) {
Log.printLine(message); Log.printLine(message);
...@@ -942,7 +990,7 @@ public class CloudSim { ...@@ -942,7 +990,7 @@ public class CloudSim {
/** /**
* Checks if is paused. * Checks if is paused.
* *
* @return true, if is paused * @return true, if is paused
*/ */
public static boolean isPaused() { public static boolean isPaused() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment