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、創建數據中心對象,它的主要參數有名稱、特徵對象、虛擬機分配策略(目前只有最簡單的,研究者可以替換新策略)、用於數據仿真的存儲列表以及調度間隔。