From: <mar...@us...> - 2008-03-05 02:36:51
|
Revision: 140 http://gridsim.svn.sourceforge.net/gridsim/?rev=140&view=rev Author: marcos_dias Date: 2008-03-04 18:36:56 -0800 (Tue, 04 Mar 2008) Log Message: ----------- This update gives the user to quit the simulation when a given event occurs. This is useful for users who want to simulate steady state of a system and want to quit the simulation whenever a user submits its last job. Modified Paths: -------------- branches/gridsim4.0-branch3/source/gridsim/GridSim.java branches/gridsim4.0-branch3/source/gridsim/GridSimShutdown.java branches/gridsim4.0-branch3/source/gridsim/GridSimTags.java Modified: branches/gridsim4.0-branch3/source/gridsim/GridSim.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/GridSim.java 2008-03-02 22:53:59 UTC (rev 139) +++ branches/gridsim4.0-branch3/source/gridsim/GridSim.java 2008-03-05 02:36:56 UTC (rev 140) @@ -2013,7 +2013,7 @@ /** * Tells all user entities to shut down the simulation. * {@link gridsim.GridSimShutdown} entity waits for all users - * termination before shuting down other entities. + * termination before shutting down other entities. * @see gridsim.GridSimShutdown * @pre $none * @post $none @@ -2026,6 +2026,23 @@ } /** + * Tells all user entities to shut down the simulation. + * {@link gridsim.GridSimShutdown} will not wait for all users + * termination before shutting down other entities. This method is relevant + * if you want to avoid the cooling down phase of simulation and use + * only the steady state. Therefore, you can shutdown the whole simulation + * when required. + * @see gridsim.GridSimShutdown + * @pre $none + * @post $none + */ + protected void shutdownSimulation() { + if (shutdownID_ != NOT_FOUND) { + send(shutdownID_, 0.0, GridSimTags.ABRUPT_END_OF_SIMULATION); + } + } + + /** * Tells the <tt>GridStatistics</tt> entity the end of the simulation * @pre $none * @post $none Modified: branches/gridsim4.0-branch3/source/gridsim/GridSimShutdown.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/GridSimShutdown.java 2008-03-02 22:53:59 UTC (rev 139) +++ branches/gridsim4.0-branch3/source/gridsim/GridSimShutdown.java 2008-03-05 02:36:56 UTC (rev 140) @@ -110,9 +110,10 @@ * end of a simulation based on <tt>reportWriterName</tt> defined in * the Constructor. * <br> - * <b>NOTE:</b> This method shuts down grid resources and GIS entities - * <tt>AFTER</tt> all grid users have been shut down. - * Therefore, the number of grid users given in the + * <b>NOTE:</b> This method shuts down grid resources and GIS entities + * either <tt>AFTER</tt> all grid users have been shut down or + * an entity requires an abrupt end of the whole simulation. + * In the first case, the number of grid users given in the * Constructor <tt>must</tt> be correct. Otherwise, GridSim * package hangs forever or it does not terminate properly. * @pre $none @@ -127,6 +128,11 @@ // with number of user entities given during GridSim.init(). for (int i = 0; i < numUser_; i++) { super.sim_get_next(ev); + if(ev.get_tag() == GridSimTags.ABRUPT_END_OF_SIMULATION) { + System.out.println(super.get_name() + + ": Abrupting stopping simulation!"); + break; + } } // Shutdown GIS - now GIS is responsible for informing end of simulation Modified: branches/gridsim4.0-branch3/source/gridsim/GridSimTags.java =================================================================== --- branches/gridsim4.0-branch3/source/gridsim/GridSimTags.java 2008-03-02 22:53:59 UTC (rev 139) +++ branches/gridsim4.0-branch3/source/gridsim/GridSimTags.java 2008-03-05 02:36:56 UTC (rev 140) @@ -47,7 +47,12 @@ /** Denotes the end of simulation */ public static final int END_OF_SIMULATION = -1; - + + /** Denotes an abrupt end of simulation. That is, one event of this + * type is enough for {@link GridSimShutdown} to trigger the end of the + * simulation */ + public static final int ABRUPT_END_OF_SIMULATION = -2; + ////////////////////////////////////////////////////////////////////// /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |