How to use vm selection policy to offload the applications from edgeServer

Description

Based on the simulation scenario (single-tier/two-tier with EO) the selection policy will be Random Fit, Worst Fit, Best Fit, First Fit and Next Fit. These policies can be implemented into the extended EdgeOrchestrator.java file to offload the vms.

package edu.boun.edgecloudsim.edge_orchestrator;

import ……;
.
import ……;

public class BasicEdgeOrchestrator extends EdgeOrchestrator

{
public BasicEdgeOrchestrator(String policy, String simScenario)
{
super(policy, simScenario);
}

@Override
public void initialize()
{
.
.
}

@Override
public int getDeviceToOffload(Task task)
{
. code to decide to use cloud or Edge VM
.
}

@Override
public Vm getVmToOffload(Task task, int deviceId)
{
Vm selectedVM = null;

if(deviceId == SimSettings.CLOUD_DATACENTER_ID)
{
. code to select VM on cloud devices
.
.

}else if (simScenario.equals(“TWO_TIER_WITH_EO”))
selectedVM = selectVmOnLoadBalancer(task);
else
selectedVM = selectVmOnHost(task);

return selectedVM;
}

public EdgeVM selectVmOnHost(Task task){
EdgeVM selectedVM = null;

Location deviceLocation = SimManager.getInstance().getMobilityModel(). getLocation(task.getMobileDeviceId(), CloudSim.clock());

int relatedHostId=deviceLocation.getServingWlanId();

List vmArray =SimManager.getInstance(). getEdgeServerManager().getVmList(relatedHostId);

if(policy.equalsIgnoreCase(“NEXT_FIT”))
{
int tries = 0;
while(tries < vmArray.size())
{
lastSelectedVmIndexes[relatedHostId] = (lastSelectedVmIndexes[relatedHostId]+1) % vmArray.size();

double requiredCapacity = ((CpuUtilizationModel_Custom)task.getUtilizationModelCpu()). predictUtilization(vmArray.get(lastSelectedVmIndexes[relatedHostId]). getVmType());

double targetVmCapacity = (double)100 – vmArray. get(lastSelectedVmIndexes[relatedHostId]). getCloudletScheduler(). getTotalUtilizationOfCpu(CloudSim.clock());
if(requiredCapacity <= targetVmCapacity)
{
selectedVM=vmArray.get(lastSelectedVmIndexes[relatedHostId]);
break;
}
tries++;
}
}

return selectedVM;
}

public EdgeVM selectVmOnLoadBalancer(Task task)
{
EdgeVM selectedVM = null;

if(policy.equalsIgnoreCase(“NEXT_FIT”))
{
int hostCheckCounter = 0;
while(selectedVM == null && hostCheckCounter < numberOfHost)
{
int tries = 0;
lastSelectedHostIndex = (lastSelectedHostIndex+1) % numberOfHost;

List vmArray = SimManager.getInstance(). getEdgeServerManager(). getVmList(lastSelectedHostIndex);

while(tries < vmArray.size())
{
lastSelectedVmIndexes[lastSelectedHostIndex] = (lastSelectedVmIndexes[lastSelectedHostIndex]+1) %
vmArray.size();

double requiredCapacity = ((CpuUtilizationModel_Custom)task.getUtilizationModelCpu()). predictUtilization(vmArray.
get(lastSelectedVmIndexes[lastSelectedHostIndex]). getVmType());

double targetVmCapacity = (double)100 – vmArray.get(lastSelectedVmIndexes[lastSelectedHostIndex]).getCloudletScheduler(). getTotalUtilizationOfCpu(CloudSim.clock());

if(requiredCapacity <= targetVmCapacity)
{
selectedVM = vmArray.get(lastSelectedVmIndexes[lastSelectedHostIndex]);
break;
}
tries++;
}
hostCheckCounter++;
}
}
return selectedVM;
}

}

Leave Comment

Your email address will not be published. Required fields are marked *

clear formSubmit