CloudSim源码分析-Datacenter创建

1、创建物理机列表。List<Host> hostList = newArrayList<Host>();

2、创建PE列表。一个物理机包含一个或多个PECPU)。List<Pe> peList = new ArrayList<Pe>();

3、创建PE,并将其添加到PE列表。peList.add(new Pe(0, new PeProvisionerSimple(mips)));可以设置PEIDmips

4、创建物理机,并添加到物理机列表。物理机的配置参数有:id,内存,存储,带宽,PE列表,虚拟机分配策略(时间共享和空间共享),并加入物理机列表。

  1. int hostId = 0;
  2.         int ram = 2048;// host memory (MB)

  3.         long storage = 1000000;// host storage

  4.         int bw = 10000;

  5.         hostList.add(
  6.             new Host(
  7.                 hostId,
  8.                 new RamProvisionerSimple(ram),
  9.                 new BwProvisionerSimple(bw),
  10.                 storage,
  11.                 peList,
  12.                 new VmSchedulerTimeShared(peList)
  13.             )
  14.         );

5、创建数据中心特征DatacenterCharacteristics对象,用来存储数据中心的属性,包含体系结构、操作系统、虚拟机类型、时区、价格(使用该数据中心单价)、单位内存价格、单位存储价格、单位带宽价格、机器列表。

  1.        String arch ="x86";// system architecture

  2.         String os ="Linux";// operating system

  3.         String vmm ="Xen";
  4.         double time_zone = 10.0;// time zone this resource located

  5.         double cost = 3.0;// the cost of using processing in this resource

  6.         double costPerMem = 0.05;// the cost of using memory in this resource

  7.         double costPerStorage = 0.001;// the cost of using storage in this

  8.                                         // resource

  9.         double costPerBw = 0.0;// the cost of using bw in this resource

  10.         LinkedList<Storage> storageList =newLinkedList<Storage>();// we are not adding SAN

  11.                                                     // devices by now


  12.         DatacenterCharacteristics characteristics =new DatacenterCharacteristics(
  13.                 arch, os, vmm, hostList, time_zone, cost, costPerMem,
  14.                 costPerStorage, costPerBw);

6、创建数据中心对象,它的主要参数有名称、特征对象、虚拟机分配策略(目前只有最简单的,研究者可以替换新策略)、用于数据仿真的存储列表以及调度间隔。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章