We have to extend “CloudServerManager.java”abstract file and add methods to create datacenter and hosts. The host configuration parameters can be accessed from Simsettings.java file. But the host IDs should be unique, so we have to create hosts for edge before cloud.
package edu.boun.edgecloudsim.cloud_server;
Import ……;
.
.
.
import ……..;
public class newCloudServerManager extends CloudServerManager{
private Datacenter createDatacenter(int index) {
String arch = "x86";
String os = "Linux";
String vmm = "Xen";
double costPerBw = 0;
double costPerSec = 0;
double costPerMem = 0;
double costPerStorage = 0;
List hostList=createHosts();
String name = "CloudDatacenter_" + Integer.toString(index);
double time_zone = 3.0;
LinkedList storageList = new LinkedList();
DatacenterCharacteristics characteristics = new DatacenterCharacteristics(arch, os, vmm, hostList, time_zone, costPerSec, costPerMem, costPerStorage, costPerBw);
Datacenter datacenter = null;
VmAllocationPolicy vm_policy = getVmAllocationPolicy(hostList,index);
datacenter = new Datacenter(name, characteristics, vm_policy, storageList, 0);
return datacenter;
}
private List createHosts(){
List hostList = new ArrayList();
for (int i = 0; i < SimSettings.getInstance().getNumOfCoudHost(); i++) {
int numOfVMPerHost = SimSettings.getInstance().getNumOfCloudVMsPerHost();
int numOfCores = SimSettings.getInstance().getCoreForCloudVM() * numOfVMPerHost;
double mips = SimSettings.getInstance().getMipsForCloudVM() * numOfVMPerHost;
int ram = SimSettings.getInstance().getRamForCloudVM() * numOfVMPerHost;
long storage = SimSettings.getInstance().getStorageForCloudVM() * numOfVMPerHost;
long bandwidth = 0;
List peList = new ArrayList();
for(int j=0; j<numOfCores; j++){
peList.add(new Pe(j, new PeProvisionerSimple(mips)));
}
//Hosts should have unique IDs, so create Cloud Hosts after Edge Hosts
Host host = new Host(
i+SimSettings.getInstance().getNumOfEdgeHosts(),
new RamProvisionerSimple(ram),
new BwProvisionerSimple(bandwidth),
storage,
peList,
new VmSchedulerSpaceShared(peList)
);
hostList.add(host);
}
return hostList;
}
}