云计算仿真工具中文注释CloudSimShutdown.java

来源:互联网 发布:php蜘蛛池程序下载 编辑:程序博客网 时间:2024/05/21 20:21
/* * 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.cloudbus.cloudsim.core;import java.util.Calendar;/** * 里面有一个记录用户数量的字段,调用processevent方法, * 当用户数量为0时,或者一个用户要求终止仿真时,然后通知CIS实体结束 * CloudimShutdown waits 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. * * @authorManzur Murshed * @authorRajkumar Buyya * @sinceCloudSim Toolkit 1.0 */public class CloudSimShutdown extends SimEntity {    /**      * The num user.      *  字段:用户数量     * */    private int numUser;    /**     * 初始化函数参数:名字和用户数量     * Allocates a new CloudSimShutdown object.     * <p>     * The total number of     * grid user entity plays an important role to determine whether all     * hostList should be shut down or not.     * If one or more users are still 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 creating 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;    }    /**     * 处理事件,当用户数为0时,或者某一个用户要求终止仿真时,终止。     * 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 the 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.cloudbus.cloudsim.core.SimEntity#startEntity()     */    @Overridepublic void startEntity() {    // do nothing    }    /* (non-Javadoc)     * @see org.cloudbus.cloudsim.core.SimEntity#shutdownEntity()     */    @Overridepublic void shutdownEntity() {    // do nothing    }}

 
原创粉丝点击