The mobile processing unit support as well as a sample application are added.

The mobile processing units are simulated via CloudSim.
It is assumed that the mobile devices operate Hosts and VMs like a server.
Therefore, the classes located in the mobile_processing_unit package have a similar naming convention to the other Cloud and Edge components.
This commit is contained in:
Cagatay Sonmez
2018-11-25 23:26:41 +03:00
parent 38b122ae6c
commit 95edf172fe
36 changed files with 3095 additions and 90 deletions

View File

@@ -36,6 +36,8 @@ public class CpuUtilizationModel_Custom implements UtilizationModel {
int index = 9;
if(task.getAssociatedDatacenterId() == SimSettings.CLOUD_DATACENTER_ID)
index = 10;
else if(task.getAssociatedDatacenterId() == SimSettings.MOBILE_DATACENTER_ID)
index = 11;
return SimSettings.getInstance().getTaskLookUpTable()[task.getTaskType()][index];
}
@@ -50,6 +52,8 @@ public class CpuUtilizationModel_Custom implements UtilizationModel {
index = 9;
else if(_vmType == SimSettings.VM_TYPES.CLOUD_VM)
index = 10;
else if(_vmType == SimSettings.VM_TYPES.MOBILE_VM)
index = 11;
else{
SimLogger.printLine("Unknown VM Type! Terminating simulation...");
System.exit(0);

View File

@@ -154,7 +154,7 @@ public class DefaultMobileDeviceManager extends MobileDeviceManager {
if(task.getAssociatedDatacenterId() == SimSettings.CLOUD_DATACENTER_ID)
networkModel.downloadFinished(task.getSubmittedLocation(), SimSettings.CLOUD_DATACENTER_ID);
else
else if(task.getAssociatedDatacenterId() != SimSettings.MOBILE_DATACENTER_ID)
networkModel.downloadFinished(task.getSubmittedLocation(), SimSettings.GENERIC_EDGE_DEVICE_ID);
SimLogger.getInstance().taskEnded(task.getCloudletId(), CloudSim.clock());

View File

@@ -0,0 +1,58 @@
/*
* Title: EdgeCloudSim - Mobile Server Manager
*
* Description:
* DefaultMobileServerManager is responsible for creating datacenters, hosts and VMs.
*
* Please note that the mobile processing units are simulated via
* CloudSim. It is assumed that the mobile devices operate Hosts
* and VMs like a server. That is why the class names are similar
* to other Cloud and Edge components (to provide consistency).
*
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* Copyright (c) 2017, Bogazici University, Istanbul, Turkey
*/
package edu.boun.edgecloudsim.edge_client.mobile_processing_unit;
import java.util.List;
import org.cloudbus.cloudsim.Host;
import org.cloudbus.cloudsim.VmAllocationPolicy;
public class DefaultMobileServerManager extends MobileServerManager{
public DefaultMobileServerManager() {
}
@Override
public void initialize() {
}
@Override
public VmAllocationPolicy getVmAllocationPolicy(List<? extends Host> list, int dataCenterIndex) {
return new MobileVmAllocationPolicy_Custom(list, dataCenterIndex);
}
@Override
public void startDatacenters() throws Exception {
//local computation is not supported in default Mobile Device Manager
}
@Override
public void terminateDatacenters() {
//local computation is not supported in default Mobile Device Manager
}
@Override
public void createVmList(int brockerId) {
//local computation is not supported in default Mobile Device Manager
}
@Override
public double getAvgUtilization() {
//local computation is not supported in default Mobile Device Manager
return 0;
}
}

View File

@@ -0,0 +1,43 @@
/*
* Title: EdgeCloudSim - MobileHost
*
* Description:
* MobileHost adds associated mobile device id information over CloudSim's Host class
*
* Please note that the mobile processing units are simulated via
* CloudSim. It is assumed that the mobile devices operate Hosts
* and VMs like a server. That is why the class names are similar
* to other Cloud and Edge components (to provide consistency).
*
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* Copyright (c) 2017, Bogazici University, Istanbul, Turkey
*/
package edu.boun.edgecloudsim.edge_client.mobile_processing_unit;
import java.util.List;
import org.cloudbus.cloudsim.Host;
import org.cloudbus.cloudsim.Pe;
import org.cloudbus.cloudsim.VmScheduler;
import org.cloudbus.cloudsim.provisioners.BwProvisioner;
import org.cloudbus.cloudsim.provisioners.RamProvisioner;
public class MobileHost extends Host {
private int mobileDeviceId;
public MobileHost(int id, RamProvisioner ramProvisioner,
BwProvisioner bwProvisioner, long storage,
List<? extends Pe> peList, VmScheduler vmScheduler) {
super(id, ramProvisioner, bwProvisioner, storage, peList, vmScheduler);
}
public void setMobileDeviceId(int _mobileDeviceId){
mobileDeviceId=_mobileDeviceId;
}
public int getMobileDeviceId(){
return mobileDeviceId;
}
}

View File

@@ -0,0 +1,78 @@
/*
* Title: EdgeCloudSim - MobileServerManager
*
* Description:
* MobileServerManager is responsible for creating and terminating
* the mobile datacenters which operates the hosts and VMs.
* It also provides the list of VMs running on the hosts and
* the average utilization of all VMs.
*
* Please note that, EdgeCloudSim is built on top of CloudSim
* Therefore, all the computational units are handled by CloudSim
*
* The mobile processing units are simulated via CloudSim as well.
* It is assumed that the mobile devices operate Hosts and VMs
* like a server. That is why the class names are similar to other
* Cloud and Edge components.
*
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* Copyright (c) 2017, Bogazici University, Istanbul, Turkey
*/
package edu.boun.edgecloudsim.edge_client.mobile_processing_unit;
import java.util.ArrayList;
import java.util.List;
import org.cloudbus.cloudsim.Datacenter;
import org.cloudbus.cloudsim.Host;
import org.cloudbus.cloudsim.VmAllocationPolicy;
public abstract class MobileServerManager {
protected Datacenter localDatacenter;
protected List<List<MobileVM>> vmList;
public MobileServerManager() {
vmList = new ArrayList<List<MobileVM>>();
}
public List<MobileVM> getVmList(int hostId){
if(vmList.size() > hostId)
return vmList.get(hostId);
else
return null;
}
public Datacenter getDatacenter(){
return localDatacenter;
}
/*
* initialize edge server manager if needed
*/
public abstract void initialize();
/*
* provides abstract Vm Allocation Policy for Mobile Datacenters
*/
public abstract VmAllocationPolicy getVmAllocationPolicy(List<? extends Host> list, int dataCenterIndex);
/*
* Starts Datacenters
*/
public abstract void startDatacenters() throws Exception;
/*
* Terminates Datacenters
*/
public abstract void terminateDatacenters();
/*
* Creates VM List
*/
public abstract void createVmList(int brockerId);
/*
* returns average utilization of all VMs
*/
public abstract double getAvgUtilization();
}

View File

@@ -0,0 +1,36 @@
/*
* Title: EdgeCloudSim - MobileVM
*
* Description:
* MobileVM adds vm type information over CloudSim's VM class
*
* Please note that the mobile processing units are simulated via
* CloudSim. It is assumed that the mobile devices operate Hosts
* and VMs like a server. That is why the class names are similar
* to other Cloud and Edge components (to provide consistency).
*
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* Copyright (c) 2017, Bogazici University, Istanbul, Turkey
*/
package edu.boun.edgecloudsim.edge_client.mobile_processing_unit;
import org.cloudbus.cloudsim.CloudletScheduler;
import org.cloudbus.cloudsim.Vm;
import edu.boun.edgecloudsim.core.SimSettings;
public class MobileVM extends Vm {
private SimSettings.VM_TYPES type;
public MobileVM(int id, int userId, double mips, int numberOfPes, int ram,
long bw, long size, String vmm, CloudletScheduler cloudletScheduler) {
super(id, userId, mips, numberOfPes, ram, bw, size, vmm, cloudletScheduler);
type = SimSettings.VM_TYPES.MOBILE_VM;
}
public SimSettings.VM_TYPES getVmType(){
return type;
}
}

View File

@@ -0,0 +1,132 @@
/*
* Title: EdgeCloudSim - Custom VM Allocation Policy for Mobile Devices' VMs
*
* Description:
* VmAllocationPolicy_Custom implements VmAllocationPolicy to decide which.
* VM is created on which host located on the datacenters. For those
* who wants to add another Vm Allocation Policy to EdgeCloudSim should
* provide another concrete instance of VmAllocationPolicy via ScenarioFactory
*
* Please note that the mobile processing units are simulated via
* CloudSim. It is assumed that the mobile devices operate Hosts
* and VMs like a server. That is why the class names are similar
* to other Cloud and Edge components (to provide consistency).
*
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* Copyright (c) 2017, Bogazici University, Istanbul, Turkey
*/
package edu.boun.edgecloudsim.edge_client.mobile_processing_unit;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.cloudbus.cloudsim.Host;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.Vm;
import org.cloudbus.cloudsim.VmAllocationPolicy;
import org.cloudbus.cloudsim.core.CloudSim;
import edu.boun.edgecloudsim.core.SimSettings;
/*
* Same as VmAllocationPolicySimple.
*/
public class MobileVmAllocationPolicy_Custom extends VmAllocationPolicy {
/** The vm table. */
private Map<String, Host> vmTable;
private static int createdVmNum;
private int DataCenterIndex;
public MobileVmAllocationPolicy_Custom(List<? extends Host> list, int _DataCenterIndex) {
super(list);
setVmTable(new HashMap<String, Host>());
DataCenterIndex = _DataCenterIndex;
createdVmNum = 0;
}
@Override
public boolean allocateHostForVm(Vm vm) {
boolean result = false;
if (!getVmTable().containsKey(vm.getUid()) && vm instanceof MobileVM) { // if this vm was not created
int hostIndex = vm.getId() - SimSettings.getInstance().getNumOfEdgeVMs() - SimSettings.getInstance().getNumOfCloudVMs();
if(DataCenterIndex == SimSettings.MOBILE_DATACENTER_ID){
Host host = getHostList().get(hostIndex);
result = host.vmCreate(vm);
if (result) { // if vm were succesfully created in the host
getVmTable().put(vm.getUid(), host);
createdVmNum++;
Log.formatLine("%.2f: Mobile VM #" + vm.getId() + " has been allocated to the host #" + host.getId(),CloudSim.clock());
result = true;
}
}
}
return result;
}
@Override
public boolean allocateHostForVm(Vm vm, Host host) {
if (host.vmCreate(vm)) { // if vm has been succesfully created in the host
getVmTable().put(vm.getUid(), host);
createdVmNum++;
Log.formatLine("%.2f: Mobile VM #" + vm.getId() + " has been allocated to the host #" + host.getId(),CloudSim.clock());
return true;
}
return false;
}
@Override
public List<Map<String, Object>> optimizeAllocation(
List<? extends Vm> vmList) {
// TODO Auto-generated method stub
return null;
}
@Override
public void deallocateHostForVm(Vm vm) {
Host host = getVmTable().remove(vm.getUid());
if (host != null) {
host.vmDestroy(vm);
}
}
@Override
public Host getHost(Vm vm) {
return getVmTable().get(vm.getUid());
}
@Override
public Host getHost(int vmId, int userId) {
return getVmTable().get(Vm.getUid(userId, vmId));
}
public static int getCreatedVmNum(){
return createdVmNum;
}
/**
* Gets the vm table.
*
* @return the vm table
*/
public Map<String, Host> getVmTable() {
return vmTable;
}
/**
* Sets the vm table.
*
* @param vmTable the vm table
*/
protected void setVmTable(Map<String, Host> vmTable) {
this.vmTable = vmTable;
}
}