/** Title: cloudsim toolkit * Description: cloudsim (cloud simulation) Toolkit for modeling and simulation of clouds * Licence: GPL-http://www.gnu.org/copyleft/gpl.html ** copyright (c) 2009-2010, the University of Melbourne, Australia */package Org. cloudid. cloudsim. core; import Java. util. calendar;/*** contains a field that records the number of users and calls the processevent method. * when the number of users is 0, or a user requests to terminate the simulation, then, the CIS entity is notified to end * cloudimshutdown wait S for termination of all cloudsim user entities to * determine the end of simulation. * <p> * this class will be created by cloudsim upon initialisation of the simulation, * I. e. done via <tt> cloudsim. init () </tt> method. hence, do not need to worry * about creating an object of this class. * <p> * This object signals the end of simulation to cloudinformationservice (GIS) * entity. ** @ authormanzu R Murshed * @ authorrajkumar buyya * @ sincecloudsim toolkit 1.0 */public class cloudsimshutdown extends simentity {/*** the num user. * field: Number of users **/private int numuser;/*** initialization function parameter: Name and number of users * allocates a new cloudsimshutdown object. * <p> * The total number of * grid user entity plays an important role to determine whether all * hostlist shocould be shut down or not. * if one or more users are St Ill not finish, then the hostlist will not * be shut down. therefore, it is important to give a correct number of * Total grid user entity. otherwise, cloudsim program will hang or encounter * a weird behaviour. ** @ Param name the name to be associated with this entity (as * required by simentity class) * @ Param numuser total number of grid user entity * @ throws exception this happens when creati Ng this entity before * initialising cloudsim package or this entity name is * <tt> null </tt> or empty * @ see gridsim. cloudsim # Init (INT, calendar, Boolean) * @ pre name! = NULL * @ pre numuser> = 0 * @ post $ none */Public cloudsimshutdown (string name, int numuser) throws exception {// note: this entity doesn't use any I/O port. // super (name, cloudsimtags. default_baud_rate); Super (name); this. numuser = numuser;}/*** process the event. When the number of users is 0, or a user requests to terminate the simulation, the event is terminated. * The main method that shuts down hostlist and Cloud information * Service (GIS ). in addition, this method writes down a report at the * end of a simulation based on <tt> reportwritername </tt> defined in * the constructor. * <br> * <B> note: </B> This method shuts down grid hostlist and GIS entities * either <tt> after </tt> All grid users have been shut down or * an entity requires an abrupt end of whole simulation. * In the first case, the number of grid users given in the * constructor <tt> must </tt> be correct. otherwise, cloudsim * package hangs forever or it does not terminate properly. ** @ Param EV the EV * @ pre $ none * @ post $ none */@ overridepublic void processevent (simevent eV) {numuser --; if (numuser = 0 | eV. gettag () = cloudsimtags. abrupt_end_of_simulation) {cloudsim. abruptallyterminate () ;}}/* (non-javadoc) * @ see Org. cloudid. cloudsim. core. simentity # startentity () */@ overridepublic void startentity () {// do nothing}/* (non-javadoc) * @ see Org. cloudid. cloudsim. core. simentity # shutdownentity () */@ overridepublic void shutdownentity () {// do nothing }}