⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gridsim.java

📁 一个非常著名的网格模拟器,能够运行网格调度算法!
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* * Title:        GridSim Toolkit * Description:  GridSim (Grid Simulation) Toolkit for Modeling and Simulation *               of Parallel and Distributed Systems such as Clusters and Grids * Licence:      GPL - http://www.gnu.org/copyleft/gpl.html * * $Id: GridSim.java,v 1.65 2006/03/09 05:56:12 anthony Exp $ */package gridsim;import gridsim.net.Link;import gridsim.filter.*;import java.io.*;import java.util.*;import eduni.simjava.*;/** * This class is mainly responsible in initialization, running and stopping of * the overall simulation. * <p> * GridSim must be initialized to set-up the * simulation environment before creating any other GridSim entities at the * user level. This method also prepares the system for simulation by creating * three GridSim internal entities - {@link gridsim.GridInformationService}, * {@link gridsim.GridSimShutdown}, {@link gridsim.GridStatistics}. Invoking the * {@link #startGridSimulation()} method starts the Grid simulation. * All the resource and user entities must be instantiated in between invoking * the above two methods. * <p> * Since GridSim version 3.0, all of the I/O methods have been moved * into {@link gridsim.GridSimCore}. * As a result, this class only concentrates on recording statistics and * managing Gridlets. In addition, there are three different ways to initialize * GridSim simulation. These methods are: * <ul> *     <li> by using *          {@link #init(int, Calendar, boolean, String[], String[], String)} *          method. <br> *          This method will create {@link gridsim.GridStatistics}, *          {@link gridsim.GridSimRandom}, {@link gridsim.GridSimShutdown} and *          {@link gridsim.GridInformationService} entity. <br> * *     <li> by using {@link #init(int, Calendar, boolean)} method. <br> *          This method will create {@link gridsim.GridSimRandom}, *          {@link gridsim.GridSimShutdown} and *          {@link gridsim.GridInformationService} entity. <br> * *     <li> by using {@link #init(int, Calendar, boolean, boolean)} method.<br> *          This method will create {@link gridsim.GridSimRandom} and *          {@link gridsim.GridSimShutdown}. A different type of *          {@link gridsim.GridInformationService} entity needs to be entered *          using {@link #setGIS(GridInformationService)} method before running *          the simulation. * </ul> * * @author       Manzur Murshed and Rajkumar Buyya * @since        GridSim Toolkit 1.0 * @see eduni.simjava.Sim_entity * @see gridsim.GridSimCore * @see gridsim.GridInformationService * @see gridsim.GridSimShutdown * @see gridsim.GridStatistics * @invariant $none */public class GridSim extends GridSimCore{    // array[0] = gridlet id, [1] = user Id, and [2] = destinated resource id    private final int ARRAY_SIZE = 3;    private final int SIZE = 12;     // Integer object size incl. overhead    private final int RESULT = 1;    // array[0] = gridlet id, [1] = result    /////////////////////////// STATIC variables ////////////////////    /**     * Simulation start date. This object is initialized     * during the call to {@link #init(int, Calendar, boolean, String[],     *             String[], String)} or     * {@link #init(int, Calendar, boolean)}     */    public static Date SimulationStartDate = null;    /**     * A Random object. This object is initialized during the call to     * {@link #init(int, Calendar, boolean, String[], String[], String)} or     * {@link #init(int, Calendar, boolean)}.     */    public static GridSimRandom rand = null;    /** Pause for a certain time delay (in seconds) before a resource     * registers to a Regional GIS entity.     * By default, a resource will pause for 10 seconds before registering.     * As a rule of thumb, if a network topology is huge (involving several     * routers), then a resource needs to pause much longer.     */    public static int PAUSE = 10;  // pause before registering to regional GIS    private static int gisID_ = -1;         // id of GIS entity    private static int shutdownID_ = -1;    // id of GridSimShutdown entity    private static int statsID_ = -1;       // id of GridStatistics entity    private static Calendar calendar_ = null;    // a Calendar object    private static GridInformationService gis_ = null;   // a GIS object    private final static int NOT_FOUND = -1;     // a constant    ////////////////////////////////////////////////////////////////////////    /**     * Allocates a new GridSim object     * <b>without</b> NETWORK communication channels: "input" and     * "output" Sim_port. In summary, this object has <tt>NO</tt>     * network communication or bandwidth speed.     * @param name       the name to be associated with this entity (as     *                   required by Sim_entity class from simjava package)     * @throws Exception This happens when creating this entity before     *                   initializing GridSim package or this entity name is     *                   <tt>null</tt> or empty     * @see gridsim.GridSim#init(int, Calendar, boolean, String[], String[],     *          String)     * @see gridsim.GridSim#init(int, Calendar, boolean)     * @see eduni.simjava.Sim_entity     * @pre name != null     * @post $none     */    public GridSim(String name) throws Exception {        super(name);    }    /**     * Allocates a new GridSim object     * <b>with</b> NETWORK communication channels: "input" and     * "output" Sim_port. In addition, this method will create <tt>Input</tt>     * and <tt>Output</tt> object.     * @param name       the name to be associated with this entity (as     *                   required by Sim_entity class from simjava package)     * @param baudRate   network communication or bandwidth speed     * @throws Exception This happens when creating this entity before     *                   initializing GridSim package or this entity name is     *                   <tt>null</tt> or empty     * @see gridsim.GridSim#init(int, Calendar, boolean, String[], String[],     *          String)     * @see gridsim.GridSim#init(int, Calendar, boolean)     * @see eduni.simjava.Sim_entity     * @see gridsim.net.Input     * @see gridsim.net.Output     * @pre name != null     * @pre baudRate > 0.0     * @post $none     */    public GridSim(String name, double baudRate) throws Exception {        super(name, baudRate);    }    /**     * Allocates a new GridSim object     * <b>with</b> NETWORK communication channels: "input" and     * "output" Sim_port. In addition, this method will create <tt>Input</tt>     * and <tt>Output</tt> object.     * <p>     * Use this constructor in a wired network.     *     * @param name       the name to be associated with this entity (as     *                   required by Sim_entity class from simjava package)     * @param link       the physical link that connects this entity     * @throws Exception This happens when creating this entity before     *                   initializing GridSim package or this entity name is     *                   <tt>null</tt> or empty     * @see gridsim.GridSim#init(int, Calendar, boolean, String[], String[],     *          String)     * @see gridsim.GridSim#init(int, Calendar, boolean)     * @see eduni.simjava.Sim_entity     * @see gridsim.net.Input     * @see gridsim.net.Output     * @pre name != null     * @pre link != null     * @post $none     */    public GridSim(String name, Link link) throws Exception {        super(name, link);    }    /**     * Gets simulation start date. If the return object is     * <tt>null</tt>, then need to initialize it by calling     * {@link #init(int, Calendar, boolean, String[], String[], String)} or     * {@link #init(int, Calendar, boolean)}     *     * @return a Date object or <tt>null</tt> if it is empty     * @deprecated As of GridSim 2.1, replaced by     *             {@link #getSimulationStartDate()}     * @see java.util.Date     * @pre $none     * @post $none     */    public static Date GetSimulationStartDate() {        return getSimulationStartDate();    }    /**     * Gets a new copy of simulation start date. If the return object     * is <tt>null</tt>, then need to initialize it by calling     * {@link #init(int, Calendar, boolean, String[], String[], String)} or     * {@link #init(int, Calendar, boolean)}     *     * @return a new copy of Date object or <tt>null</tt> if GridSim hasn't     *         been initialized     * @see java.util.Date     * @pre $none     * @post $none     */    public static Date getSimulationStartDate()    {        // make a new copy        Date clone = SimulationStartDate;        if (SimulationStartDate != null) {            clone = (Date) SimulationStartDate.clone();        }        return clone;    }    /**     * Gets a new copy of initial simulation Calendar.     * @return a new copy of Calendar object or <tt>null</tt> if GridSim hasn't     *         been initialized     * @see gridsim.GridSim#init(int, Calendar, boolean, String[], String[],     *      String)     * @see gridsim.GridSim#init(int, Calendar, boolean)     * @pre $none     * @post $none     */    public static Calendar getSimulationCalendar()    {        // make a new copy        Calendar clone = calendar_;        if (calendar_ != null) {            clone = (Calendar) calendar_.clone();        }        return clone;    }    /**     * Initializes GridSim parameters.     * This method should be called before creating any entities.     * <p>     * Inside this method, it will create the following GridSim entities:     * <ul>     *     <li>GridSimRandom     *     <li>GridStatistics     *     <li>GridInformationService     *     <li>GridSimShutdown     * </ul>     * <p>     * The Calendar object can be specified using     * <tt>Calendar.getInstance()</tt> to denote the start of the simulation     * time.     * This simulation time is <b>very important</b> in handling     * advanced reservations functionalities.     *     * @param numUser  the number of User Entities created.     *                 This parameters indicates that     *                 {@link gridsim.GridSimShutdown} first waits for     *                 User Entities's END_OF_SIMULATION signal before     *                 issuing terminate signal to other entities     * @param cal          starting time for this simulation. If it is     *        <tt>null</tt>, then the time will be taken from     *        <tt>Calendar.getInstance()</tt>.     * @param traceFlag    true if GridSim trace need to be written     * @param excludeFromFile  an array of String containing list of files to     *                         be excluded from statistics     * @param excludeFromProcessing   an array of String containing list of     *                                processings to be excluded from writing     *                                into a file     * @param reportWriterName  a <tt>ReportWriter</tt> entity name. This entity     *                          can be found inside a gridbroker package.     * @deprecated As of GridSim 2.1, replaced by     *             {@link #init(int, Calendar, boolean, String[],     *             String[], String)}     * @see gridsim.GridSimShutdown     * @see gridsim.GridStatistics     * @see gridsim.GridInformationService     * @see gridsim.GridSimRandom     * @pre numUser >= 0     * @post $none     */    public static void Init(int numUser, Calendar cal, boolean traceFlag,            String[] excludeFromFile, String[] excludeFromProcessing,            String reportWriterName)    {        init(numUser, cal, traceFlag, excludeFromFile,                excludeFromProcessing, reportWriterName);    }    /**     * Initializes GridSim parameters.     * This method should be called before creating any entities.     * <p>     * Inside this method, it will create the following GridSim entities:     * <ul>     *     <li>GridSimRandom     *     <li>GridStatistics     *     <li>GridInformationService     *     <li>GridSimShutdown     * </ul>     * <p>     * The Calendar object can be specified using     * <tt>Calendar.getInstance()</tt> to denote the start of the simulation     * time.     * This simulation time is <b>very important</b> in handling     * advanced reservations functionalities.     *     * @param numUser  the number of User Entities created.     *                 This parameters indicates that     *                 {@link gridsim.GridSimShutdown} first waits for     *                 User Entities's END_OF_SIMULATION signal before     *                 issuing terminate signal to other entities     * @param cal          starting time for this simulation. If it is     *        <tt>null</tt>, then the time will be taken from     *        <tt>Calendar.getInstance()</tt>.     * @param traceFlag    true if GridSim trace need to be written     * @param excludeFromFile  an array of String containing list of files to     *                         be excluded from statistics     * @param excludeFromProcessing   an array of String containing list of     *                                processings to be excluded from writing     *                                into a file     * @param reportWriterName  a <tt>ReportWriter</tt> entity name. This entity     *                          can be found inside a gridbroker package.     * @see gridsim.GridSimShutdown     * @see gridsim.GridStatistics     * @see gridsim.GridInformationService     * @see gridsim.GridSimRandom     * @pre numUser >= 0     * @post $none     */    public static void init(int numUser, Calendar cal, boolean traceFlag,            String[] excludeFromFile, String[] excludeFromProcessing,            String reportWriterName)    {        try        {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -