1、创建物理机列表。List<Host> hostList = newArrayList<Host>();
2、创建PE列表。一个物理机包含一个或多个PE(CPU)。List<Pe> peList = new ArrayList<Pe>();
3、创建PE,并将其添加到PE列表。peList.add(new Pe(0, new PeProvisionerSimple(mips)));可以设置PE的ID和mips。
4、创建物理机,并添加到物理机列表。物理机的配置参数有:id,内存,存储,带宽,PE列表,虚拟机分配策略(时间共享和空间共享),并加入物理机列表。
- int hostId = 0;
- int ram = 2048;// host memory (MB)
- long storage = 1000000;// host storage
- int bw = 10000;
- hostList.add(
- new Host(
- hostId,
- new RamProvisionerSimple(ram),
- new BwProvisionerSimple(bw),
- storage,
- peList,
- new VmSchedulerTimeShared(peList)
- )
- );
5、创建数据中心特征DatacenterCharacteristics对象,用来存储数据中心的属性,包含体系结构、操作系统、虚拟机类型、时区、价格(使用该数据中心单价)、单位内存价格、单位存储价格、单位带宽价格、机器列表。
- String arch ="x86";// system architecture
- String os ="Linux";// operating system
- String vmm ="Xen";
- double time_zone = 10.0;// time zone this resource located
- double cost = 3.0;// the cost of using processing in this resource
- double costPerMem = 0.05;// the cost of using memory in this resource
- double costPerStorage = 0.001;// the cost of using storage in this
- // resource
- double costPerBw = 0.0;// the cost of using bw in this resource
- LinkedList<Storage> storageList =newLinkedList<Storage>();// we are not adding SAN
- // devices by now
- DatacenterCharacteristics characteristics =new DatacenterCharacteristics(
- arch, os, vmm, hostList, time_zone, cost, costPerMem,
- costPerStorage, costPerBw);
6、创建数据中心对象,它的主要参数有名称、特征对象、虚拟机分配策略(目前只有最简单的,研究者可以替换新策略)、用于数据仿真的存储列表以及调度间隔。