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

📄 resfailureex03.java

📁 中間件開發详细说明:清华大学J2EE教程讲义(ppt)-Tsinghua University J2EE tutorial lectures (ppt) [上载源码成为会员下载此源码] [成为VIP会
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * Title:        GridSim Toolkit * Description:  GridSim (Grid Simulation) Toolkit for Modeling and Simulation *               of Parallel and Distributed Systems such as Clusters and Grids *               An example of how to use the failure functionality. * Licence:      GPL - http://www.gnu.org/copyleft/gpl.html * * Author: Agustin Caminero and Anthony Sulistio * Organization: UCLM (Spain) * Created on: August 2007 */import gridsim.resFailure.*;import gridsim.*;import gridsim.net.*;import java.util.*;import gridsim.util.NetworkReader;import gridsim.util.HyperExponential;/** * This example shows a basic topology with n users, m resources and p GISes. * All of them are connected by a router. * There is only one VO in this example. * @author       Agustin Caminero and Anthony Sulistio * @since        GridSim Toolkit 4.1 */public class ResFailureEx03{    public static void main(String[] args)    {        System.out.println("Starting failure example 3...");        try        {            if (args.length < 1)            {                System.out.println("Usage: java ResFailureEx03 network_ex03.txt");                return;            }            // specify the number of users, resources and GISes            int num_user = 30;           // number of grid users            int totalResource = 15;      // number of resources            int num_GIS = 3;             // number of regional GIS entity            Random random = new Random();       // randomize the selection            //////////////////////////////////////////            // First step: Initialize the GridSim package. It should be called            // before creating any entities. We can't run this example without            // initializing GridSim first. We will get a run-time exception            // error.            // a flag that denotes whether to trace GridSim events or not.            boolean trace_flag = false;  // dont use SimJava trace            Calendar calendar = Calendar.getInstance();            // Initialize the GridSim package            System.out.println("Initializing GridSim package");            GridSim.init(num_user, calendar, trace_flag);            trace_flag = true;            //////////////////////////////////////////            // Second step: Builds the network topology among Routers.            String filename = args[0];  // get the network topology            System.out.println("Reading network from " + filename);            LinkedList routerList = NetworkReader.createFIFO(filename);            //////////////////////////////////////////            // Third step: Creates one RegionalGISWithFailure entity,            // linked to a router in the topology            double baud_rate = 100000000;   // 100Mbps, i.e. baud rate of links            double propDelay = 10;      // propagation delay in milliseconds            int mtu = 1500;             // max. transmission unit in byte            int totalMachines = 16;     // num of machines each resource has            Router router0 = NetworkReader.getRouter("Router0", routerList);            Router router1 = NetworkReader.getRouter("Router1", routerList);            String NAME = "Ex03_";  // a common name            ArrayList gisList = new ArrayList(num_GIS); // list of GIS entities            for (int i = 0; i < num_GIS; i++)            {                String gisName = NAME + "Regional_GIS_" + i;  // GIS name                // a network link attached to this regional GIS entity                Link link = new SimpleLink(gisName + "_link", baud_rate,                                           propDelay, mtu);                // HyperExponential: mean, standard deviation, stream                // how many resources will fail                HyperExponential failureNumResPattern =                        new HyperExponential(totalMachines / 2, totalMachines, 4);                // when they will fail                HyperExponential failureTimePattern =                        new HyperExponential(25, 100, 4);                // how long the failure will be                HyperExponential failureLengthPattern =                        new HyperExponential(20, 25, 4); // big test: (20, 100, 4);                // creates a new Regional GIS entity that generates a resource                // failure message according to these patterns.                RegionalGISWithFailure gis = new RegionalGISWithFailure(gisName,                                  link, failureNumResPattern, failureTimePattern,                                  failureLengthPattern);                gis.setTrace(trace_flag);   // record this GIS activity                gisList.add(gis);   // add into the list                // link these GIS to a router                String routerName = null;                if (random.nextBoolean() == true)                {                    linkNetwork(router0, gis);                    routerName = router0.get_name();                }                else                {                    linkNetwork(router1, gis);                    routerName = router1.get_name();                }                // print some info messages                System.out.println("Created a REGIONAL GIS with name " +                        gisName + " and id = " + gis.get_id() +                        ", connected to " + routerName);            }            //////////////////////////////////////////            // Fourth step: Creates one or more GridResourceWithFailure            // entities, linked to a router in the topology            String sched_alg = "SPACE";  // use space-shared policy            ArrayList resList = new ArrayList(totalResource);            // Each resource may have different baud rate,            // totalMachine, rating, allocation policy and the router to            // which it will be connected. However, in this example, we assume            // all have the same properties for simplicity.            int totalPE = 4;        // num of PEs each machine has            int rating = 49000;     // rating (MIPS) of PEs            int GB = 1000000000;    // 1 GB in bits            baud_rate = 2.5 * GB;            for (int i = 0; i < totalResource; i++)            {                // creates a new grid resource                String resName = NAME + "Res_" + i;                GridResourceWithFailure res = createGridResource(resName,                            baud_rate, propDelay, mtu, totalPE, totalMachines,                            rating, sched_alg);                if (i % 2 == 0) {                    trace_flag = true;                }                else {                    trace_flag = false;                }                resList.add(res);   // add a resource into a list                res.setTrace(trace_flag);   // record this resource activity                // link these GIS to a router                String routerName = null;                if (random.nextBoolean() == true)                {                    linkNetwork(router0, res);                    routerName = router0.get_name();                }                else                {                    linkNetwork(router1, res);                    routerName = router1.get_name();                }                // randomly select which GIS to choose                int index = random.nextInt( gisList.size() );                RegionalGISWithFailure gis = (RegionalGISWithFailure) gisList.get(index);                res.setRegionalGIS(gis); // set the regional GIS entity                System.out.println("Created " + resName + " with id = " +                        res.get_id() + ", linked to " + routerName +

⌨️ 快捷键说明

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