分享

GridSim安装报告

 xuealice 2007-09-07

GridSim安装报告

清华大学 朱穗晖 2004-5-19
 

GridSim是一个在WindowsLinux的平台上都可以运行的网格模拟器。这个模拟器是用Java编写的所以具有跨平台特性。GridSim可以进行网格调度算法的模拟、,可以通过提供的method来编写模拟文件,从而完成模拟的过程。

1 与其他模拟器的比较

    在网格领域几个比较著名的模拟器有MicroGridSimGrid,和Bricks。与它们相比,GridSim对于人们来说是比较陌生的。下面先来简单总结一下我这段时间根据阅读的材料,得出对这几个模拟器的一些总结。

1       MicroGrid

这个模拟器是最有名的模拟器,关于它的详细资料可以参阅刘鹏的网格信息中转站www.chinagrid.net,上面有比较多的人研究这个。在这个网格中转站上有一个关于模拟器的虚拟学习组织,经过这几天的阅读获益匪浅。

从模拟器的意义上来说,MicroGrid是这几个模拟器中比较最接近真实的模拟器。它基于Linux,建立在Globus平台上,所有的程序都模拟在Globus的基础上运行。这个模拟器现在有比较多研究算法的人采用。

    不过它有一个很致命的缺点,就是它要基于Globus,而且现在还没有支持Globus3的版本。只支持到Globus2.2,这也是我不选择这个模拟器的原因。

2       SimGrid

这个模拟器也是一个工具包,准确来说是一个API包。SimGrid也属于比较有名的一个工具包。它也是基于Linux平台,使用C来开发模拟器。这是我觉得最理想的一个模拟器,无奈想尽办法也装不上。如果能够装上,也希望能够在这个平台上跑模拟程序。

2 GridSim简介

    很多人将GridSimSimGrid混淆起来。其实SimGrid完全是Linux下面用C开发的。而GridSim完全是用Java开发的,因此具有跨平台特性。我选择Windows作为我的测试平台。

       GridSim也是一套API的工具包,它也可以产生资源如处理器,也可以产生计算任务。这些都由API来完成。使用J2SDK1.42编译。然后输出结果到文件中。

3 GridSim安装步骤

    下面以Window版本为例说明GridSim的安装。

1)安装准备工作

    从网站http://www.cs.mu./~raj/gridsim/ 上面下载gridsimtoolkit-2.2(现在的最新版本)。下来是一个Zip包。

    首先确认机器上是否有J2SDK。可以从java.sun.com上下载J2SDK的最新版本。一般是exe文件,点击装上即可。

    设置Java环境变量的时候要非常注意。下面是在Windows XP上的设置方法。

在我的电脑属性高级环境变量。双击Path,加入

.;C:\j2sdk1.4.1_01\bin;

点击新建,添加classpath项,值如下:

.;C:\j2sdk1.4.1_01\lib\dt.jar;C:\j2sdk1.4.1_01\lib\tools.jar;

点击确定完成设置。

2GridSim安装

点击解压后的安装文件。解压文件夹结构如下:

gridsimtoolkit-2.2/

    index.html          -- This file

    classes/            -- The .class files

    doc/                -- API Documentation

        eduni/

        gridbroker/

        gridsim/

        visualmodeler/

 

    examples/           -- Examples, see README.txt for details

    jars/               -- jar archives

    source/             -- The Java source code

        gridbroker/*.java

        gridsim/*.java

        visualmodeler/*.java

 

3       编译与运行设置

这一部分在帮助文档上没有,但是为了编译方便我自己尝试加入如下内容。

Classpath加入C:\gridsimtoolkit-2.2\jars\all.jar

这样可以在任意目录编译运行GridsimJava程序了。

4       测试运行结果

测试文件是软件包中的Example1

该文件显示了如何使用API来讲三台机器初始化为一个网路资源/

 

测试文件如下

Example1.java

/*

 * Author: Anthony Sulistio

 * Date: April 2003

 * Description: A simple program to demonstrate of how to use GridSim package.

 *              This example shows how to create one Grid resource with three

 *              machines.

 *

 * NOTE: The values used from this example are taken from the GridSim paper.

 *       http://www./gridsim/

 * $Id: Example1.java,v 1.5 2003/12/14 05:35:24 anthony Exp $

 */

import java.util.*;

import gridsim.*;

 

/**

 * This class creates one Grid resource with three machines. Before creating

 * any of GridSim entities, you should remember to call

 * <tt>GridSim.Init()</tt>.

 */

class Example1

{

    /**

     * Main function to run this example

     */

    public static void main(String[] args)

    {

        System.out.println("Starting example of how to create one Grid " +

                "resource");

 

        try

        {

            // First step: Initialize the GridSim package. It should be called

            // before creating any entities. We can‘t run GridResource

            // entity without initializing GridSim first. We will get run-time

            // exception error.

            int num_user = 0;   // number of users need to be created

            Calendar calendar = Calendar.getInstance();

            boolean trace_flag = true; // mean trace GridSim events/activities

 

            // list of files or processing names to be excluded from any

            //statistical measures

            String[] exclude_from_file = { "" };

            String[] exclude_from_processing = { "" };

 

            // the name of a report file to be written. We don‘t want to write

            // anything here. See other examples of using the

            // ReportWriter class

            String report_name = null;

 

            // Initialize the GridSim package

            System.out.println("Initializing GridSim package");

            GridSim.init(num_user, calendar, trace_flag, exclude_from_file,

                    exclude_from_processing, report_name);

 

            // Second step: Create one Grid resource

            GridResource gridResource = createGridResource();

            System.out.println("Finish the 1st example");

        }

        catch (Exception e)

        {

            e.printStackTrace();

            System.out.println("Unwanted error happens");

        }

    }

 

 

    /**

     * Creates one Grid resource. A Grid resource contains one or more

     * Machines. Similarly, a Machine contains one or more PEs (Processing

     * Elements or CPUs).

     * <p>

     * In this simple example, we are simulating one Grid resource with three

     * Machines that contains one or more PEs.

     * @return a GridResource object

     */

    private static GridResource createGridResource()

    {

        System.out.println("Starting to create one Grid resource with " +

                "3 Machines ...");

 

        // Here are the steps needed to create a Grid resource:

        // 1. We need to create an object of MachineList to store one or more

        //    Machines

        MachineList mList = new MachineList();

        System.out.println("Creates a Machine list");

 

 

        // 2. A Machine contains one or more PEs or CPUs. Therefore, should

        //    create an object of PEList to store these PEs before creating

        //    a Machine.

        PEList peList1 = new PEList();

        System.out.println("Creates a PE list for the 1st Machine");

 

 

        // 3. Create PEs and add these into an object of PEList.

        //    In this example, we are using a resource from

        //    hpc420.hpcc.jp, AIST, Tokyo, Japan

        //    Note: these data are taken the from GridSim paper, page 25.

        //          In this example, all PEs has the same MIPS (Millions

        //          Instruction Per Second) Rating for a Machine.

        int MIPSRating = 377;

        peList1.add( new PE(0, MIPSRating) );  // store PE id and MIPS Rating

        peList1.add( new PE(1, MIPSRating) );

        peList1.add( new PE(2, MIPSRating) );

        peList1.add( new PE(3, MIPSRating) );

        System.out.println("Creates 4 PEs with same MIPS Rating and put " +

                "them into the PE list");

 

 

        // 4. Create one Machine with its id and list of PEs or CPUs

        mList.add( new Machine(0, peList1) );   // First Machine

        System.out.println("Creates the 1st Machine that has 4 PEs and " +

                "stores it into the Machine list");

 

 

        // 5. Repeat the process from 2 if we want to create more Machines

        //    In this example, the AIST in Japan has 3 Machines with same

        //    MIPS Rating but different PEs.

        // NOTE: if you only want to create one Machine for one Grid resource,

        //       then you could skip this step.

        PEList peList2 = new PEList();

        System.out.println();

        System.out.println("Creates a PE list for the 2nd Machine");

 

        peList2.add( new PE(0, MIPSRating) );

        peList2.add( new PE(1, MIPSRating) );

        peList2.add( new PE(2, MIPSRating) );

        peList2.add( new PE(3, MIPSRating) );

        System.out.println("Creates 4 PEs with same MIPS Rating and put " +

                "them into the PE list");

 

        mList.add( new Machine(1, peList2) );   // Second Machine

        System.out.println("Creates the 2nd Machine that has 4 PEs and " +

                "stores it into the Machine list");

 

        PEList peList3 = new PEList();

        System.out.println();

        System.out.println("Creates a PE list for the 3rd Machine");

 

        peList3.add( new PE(0, MIPSRating) );

        peList3.add( new PE(1, MIPSRating) );

        System.out.println("Creates 2 PEs with same MIPS Rating and put " +

                "them into the PE list");

 

        mList.add( new Machine(2, peList3) );   // Third Machine

        System.out.println("Creates the 3rd Machine that has 2 PEs and " +

                "stores it into the Machine list");

 

 

        // 6. Create a ResourceCharacteristics object that stores the

        //    properties of a Grid resource: architecture, OS, list of

        //    Machines, allocation policy: time- or space-shared, time zone

        //    and its price (G$/PE time unit).

        String arch = "Sun Ultra";      // system architecture

 

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多