code refactoring and improvements

* saving log for each app type support
* colt library is used for poisson distribution
* Setting file structure is updated
* some bug fixes are applied
* new abstract functions are added to network manager for another
experimental study
This commit is contained in:
Cagatay Sonmez 2017-06-19 22:40:15 +03:00
parent 22b654d719
commit 138adb8f32
12 changed files with 618 additions and 360 deletions

BIN
lib/colt.jar Normal file

Binary file not shown.

View File

@ -37,7 +37,7 @@ public class SimSettings {
//if you want to add different types on your config file, //if you want to add different types on your config file,
//you may modify current types or add new types here. //you may modify current types or add new types here.
public static enum VM_TYPES { EDGE_VM, CLOUD_VM } public static enum VM_TYPES { EDGE_VM, CLOUD_VM }
public static enum APP_TYPES { FACE_REC_APP, HEALTH_APP, HEAVY_COMP_APP, VIDEO_GAME_APP, SIMPLE_SERVICE_APP } public static enum APP_TYPES { AUGMENTED_REALITY, HEALTH_APP, HEAVY_COMP_APP, INFOTAINMENT_APP }
public static enum PLACE_TYPES { ATTRACTIVENESS_L1, ATTRACTIVENESS_L2, ATTRACTIVENESS_L3 } public static enum PLACE_TYPES { ATTRACTIVENESS_L1, ATTRACTIVENESS_L2, ATTRACTIVENESS_L3 }
//predifined IDs for cloud components. //predifined IDs for cloud components.
@ -52,10 +52,10 @@ public class SimSettings {
//delimiter for output file. //delimiter for output file.
public static String DELIMITER = ";"; public static String DELIMITER = ";";
private double SIMULATION_TIME; //hours unit in properties file private double SIMULATION_TIME; //minutes unit in properties file
private double WARM_UP_PERIOD; //seconds unit in properties file private double WARM_UP_PERIOD; //minutes unit in properties file
private double INTERVAL_TO_GET_VM_LOAD_LOG; //seconds unit in properties file private double INTERVAL_TO_GET_VM_LOAD_LOG; //minutes unit in properties file
private double INTERVAL_TO_GET_VM_LOCATION_LOG; //seconds unit in properties file private double INTERVAL_TO_GET_VM_LOCATION_LOG; //minutes unit in properties file
private boolean FILE_LOG_ENABLED; //boolean to check file logging option private boolean FILE_LOG_ENABLED; //boolean to check file logging option
private boolean DEEP_FILE_LOG_ENABLED; //boolean to check deep file logging option private boolean DEEP_FILE_LOG_ENABLED; //boolean to check deep file logging option
@ -92,7 +92,7 @@ public class SimSettings {
// [7] avg task length (MI) // [7] avg task length (MI)
// [8] required # of cores // [8] required # of cores
// [9] vm utilization (%) // [9] vm utilization (%)
private double[][] taskLookUpTable = new double[APP_TYPES.values().length][10]; private double[][] taskLookUpTable = new double[APP_TYPES.values().length][11];
private SimSettings() { private SimSettings() {
} }
@ -119,10 +119,10 @@ public class SimSettings {
Properties prop = new Properties(); Properties prop = new Properties();
prop.load(input); prop.load(input);
SIMULATION_TIME = 3600 * Double.parseDouble(prop.getProperty("simulation_time")); //hours SIMULATION_TIME = (double)60 * Double.parseDouble(prop.getProperty("simulation_time")); //seconds
WARM_UP_PERIOD = Double.parseDouble(prop.getProperty("warm_up_period")); //seconds WARM_UP_PERIOD = (double)60 * Double.parseDouble(prop.getProperty("warm_up_period")); //seconds
INTERVAL_TO_GET_VM_LOAD_LOG = Double.parseDouble(prop.getProperty("vm_load_check_interval")); //seconds INTERVAL_TO_GET_VM_LOAD_LOG = (double)60 * Double.parseDouble(prop.getProperty("vm_load_check_interval")); //seconds
INTERVAL_TO_GET_VM_LOCATION_LOG = Double.parseDouble(prop.getProperty("vm_location_check_interval")); //seconds INTERVAL_TO_GET_VM_LOCATION_LOG = (double)60 * Double.parseDouble(prop.getProperty("vm_location_check_interval")); //seconds
FILE_LOG_ENABLED = Boolean.parseBoolean(prop.getProperty("file_log_enabled")); FILE_LOG_ENABLED = Boolean.parseBoolean(prop.getProperty("file_log_enabled"));
DEEP_FILE_LOG_ENABLED = Boolean.parseBoolean(prop.getProperty("deep_file_log_enabled")); DEEP_FILE_LOG_ENABLED = Boolean.parseBoolean(prop.getProperty("deep_file_log_enabled"));
@ -185,7 +185,7 @@ public class SimSettings {
/** /**
* returns simulation time (in hours unit) from properties file * returns simulation time (in seconds unit) from properties file
*/ */
public double getSimulationTime() public double getSimulationTime()
{ {
@ -430,9 +430,10 @@ public class SimSettings {
double task_length = Double.parseDouble(appElement.getElementsByTagName("task_length").item(0).getTextContent()); double task_length = Double.parseDouble(appElement.getElementsByTagName("task_length").item(0).getTextContent());
double required_core = Double.parseDouble(appElement.getElementsByTagName("required_core").item(0).getTextContent()); double required_core = Double.parseDouble(appElement.getElementsByTagName("required_core").item(0).getTextContent());
double vm_utilization = Double.parseDouble(appElement.getElementsByTagName("vm_utilization").item(0).getTextContent()); double vm_utilization = Double.parseDouble(appElement.getElementsByTagName("vm_utilization").item(0).getTextContent());
double delay_sensitivity = Double.parseDouble(appElement.getElementsByTagName("delay_sensitivity").item(0).getTextContent());
taskLookUpTable[appType.ordinal()][0] = usage_percentage; //usage percentage (%) taskLookUpTable[appType.ordinal()][0] = usage_percentage; //usage percentage [0-100]
taskLookUpTable[appType.ordinal()][1] = prob_cloud_selection; //prob. of selecting cloud (%) taskLookUpTable[appType.ordinal()][1] = prob_cloud_selection; //prob. of selecting cloud [0-100]
taskLookUpTable[appType.ordinal()][2] = poisson_interarrival; //poisson mean (sec) taskLookUpTable[appType.ordinal()][2] = poisson_interarrival; //poisson mean (sec)
taskLookUpTable[appType.ordinal()][3] = active_period; //active period (sec) taskLookUpTable[appType.ordinal()][3] = active_period; //active period (sec)
taskLookUpTable[appType.ordinal()][4] = idle_period; //idle period (sec) taskLookUpTable[appType.ordinal()][4] = idle_period; //idle period (sec)
@ -440,7 +441,8 @@ public class SimSettings {
taskLookUpTable[appType.ordinal()][6] = data_download; //avg data download (KB) taskLookUpTable[appType.ordinal()][6] = data_download; //avg data download (KB)
taskLookUpTable[appType.ordinal()][7] = task_length; //avg task length (MI) taskLookUpTable[appType.ordinal()][7] = task_length; //avg task length (MI)
taskLookUpTable[appType.ordinal()][8] = required_core; //required # of core taskLookUpTable[appType.ordinal()][8] = required_core; //required # of core
taskLookUpTable[appType.ordinal()][9] = vm_utilization; //vm utilization (%) taskLookUpTable[appType.ordinal()][9] = vm_utilization; //vm utilization [0-100]
taskLookUpTable[appType.ordinal()][10] = delay_sensitivity; //delay_sensitivity [0-1]
} }
} catch (Exception e) { } catch (Exception e) {

View File

@ -38,7 +38,7 @@ public class MobileDeviceManager extends DatacenterBroker {
private static final int REQUEST_PROCESSED_BY_CLOUD = BASE + 2; private static final int REQUEST_PROCESSED_BY_CLOUD = BASE + 2;
private static final int REQUEST_RECIVED_BY_EDGE_DEVICE = BASE + 3; private static final int REQUEST_RECIVED_BY_EDGE_DEVICE = BASE + 3;
private static final int RESPONSE_RECEIVED_BY_MOBILE_DEVICE = BASE + 4; private static final int RESPONSE_RECEIVED_BY_MOBILE_DEVICE = BASE + 4;
private static final int REQUEST_RECIVED_BY_EDGE_ORCHESTRATOR = BASE + 5; // private static final int REQUEST_RECIVED_BY_EDGE_ORCHESTRATOR = BASE + 5;
private int taskIdCounter=0; private int taskIdCounter=0;
public MobileDeviceManager() throws Exception { public MobileDeviceManager() throws Exception {
@ -70,9 +70,10 @@ public class MobileDeviceManager extends DatacenterBroker {
if(task.getSubmittedLocation().equals(currentLocation)) if(task.getSubmittedLocation().equals(currentLocation))
{ {
//SimLogger.printLine(CloudSim.clock() + ": " + getName() + ": Cloudlet " + task.getCloudletId() + " received"); //SimLogger.printLine(CloudSim.clock() + ": " + getName() + ": Cloudlet " + task.getCloudletId() + " received");
double WlanDelay = networkModel.getDownloadDelay(task.getAssociatedHostId(), task.getMobileDeviceId()); double WlanDelay = networkModel.getDownloadDelay(task.getAssociatedHostId(), task.getMobileDeviceId(), task.getCloudletOutputSize());
if(WlanDelay > 0) if(WlanDelay > 0)
{ {
networkModel.downloadStarted(currentLocation, SimSettings.GENERIC_EDGE_DEVICE_ID);
schedule(getId(), WlanDelay, RESPONSE_RECEIVED_BY_MOBILE_DEVICE, task); schedule(getId(), WlanDelay, RESPONSE_RECEIVED_BY_MOBILE_DEVICE, task);
SimLogger.getInstance().downloadStarted(task.getCloudletId(), WlanDelay); SimLogger.getInstance().downloadStarted(task.getCloudletId(), WlanDelay);
} }
@ -103,9 +104,9 @@ public class MobileDeviceManager extends DatacenterBroker {
{ {
Task task = (Task) ev.getData(); Task task = (Task) ev.getData();
Location currentLocation = SimManager.getInstance().getMobilityModel().getLocation(task.getMobileDeviceId(),CloudSim.clock()); networkModel.uploadFinished(task.getSubmittedLocation(), SimSettings.CLOUD_DATACENTER_ID);
task.setSubmittedLocation(currentLocation); //save related host id
task.setAssociatedHostId(SimSettings.CLOUD_HOST_ID); task.setAssociatedHostId(SimSettings.CLOUD_HOST_ID);
SimLogger.getInstance().uploaded(task.getCloudletId(), SimLogger.getInstance().uploaded(task.getCloudletId(),
@ -125,54 +126,70 @@ public class MobileDeviceManager extends DatacenterBroker {
{ {
Task task = (Task) ev.getData(); Task task = (Task) ev.getData();
Location currentLocation = SimManager.getInstance().getMobilityModel().getLocation(task.getMobileDeviceId(),CloudSim.clock());
if(task.getSubmittedLocation().equals(currentLocation))
{
//SimLogger.printLine(CloudSim.clock() + ": " + getName() + ": Cloudlet " + task.getCloudletId() + " received"); //SimLogger.printLine(CloudSim.clock() + ": " + getName() + ": Cloudlet " + task.getCloudletId() + " received");
double WanDelay = networkModel.getDownloadDelay(SimSettings.CLOUD_DATACENTER_ID, task.getMobileDeviceId()); double WanDelay = networkModel.getDownloadDelay(SimSettings.CLOUD_DATACENTER_ID, task.getMobileDeviceId(), task.getCloudletOutputSize());
if(WanDelay > 0) if(WanDelay > 0)
{ {
Location currentLocation = SimManager.getInstance().getMobilityModel().getLocation(task.getMobileDeviceId(),CloudSim.clock()+WanDelay);
if(task.getSubmittedLocation().equals(currentLocation))
{
networkModel.downloadStarted(task.getSubmittedLocation(), SimSettings.CLOUD_DATACENTER_ID);
schedule(getId(), WanDelay, RESPONSE_RECEIVED_BY_MOBILE_DEVICE, task); schedule(getId(), WanDelay, RESPONSE_RECEIVED_BY_MOBILE_DEVICE, task);
SimLogger.getInstance().downloadStarted(task.getCloudletId(), WanDelay); SimLogger.getInstance().downloadStarted(task.getCloudletId(), WanDelay);
} }
else else
{
SimLogger.getInstance().failedDueToBandwidth(task.getCloudletId(), CloudSim.clock());
}
}
else
{ {
//SimLogger.printLine("task cannot be finished due to mobility of user!"); //SimLogger.printLine("task cannot be finished due to mobility of user!");
//SimLogger.printLine("device: " +task.getMobileDeviceId()+" - submitted " + task.getSubmissionTime() + " @ " + task.getSubmittedLocation().getXPos() + " handled " + CloudSim.clock() + " @ " + currentLocation.getXPos()); //SimLogger.printLine("device: " +task.getMobileDeviceId()+" - submitted " + task.getSubmissionTime() + " @ " + task.getSubmittedLocation().getXPos() + " handled " + CloudSim.clock() + " @ " + currentLocation.getXPos());
SimLogger.getInstance().failedDueToMobility(task.getCloudletId(), CloudSim.clock()); SimLogger.getInstance().failedDueToMobility(task.getCloudletId(), CloudSim.clock());
} }
}
else
{
SimLogger.getInstance().failedDueToBandwidth(task.getCloudletId(), CloudSim.clock());
}
break; break;
} }
/*
case REQUEST_RECIVED_BY_EDGE_ORCHESTRATOR: case REQUEST_RECIVED_BY_EDGE_ORCHESTRATOR:
{ {
Task task = (Task) ev.getData(); Task task = (Task) ev.getData();
double internalDelay = networkModel.getDownloadDelay( double internalDelay = networkModel.getDownloadDelay(
SimSettings.EDGE_ORCHESTRATOR_ID, SimSettings.EDGE_ORCHESTRATOR_ID,
SimSettings.GENERIC_EDGE_DEVICE_ID); SimSettings.GENERIC_EDGE_DEVICE_ID,
task.getCloudletOutputSize());
networkModel.downloadStarted(
SimSettings.EDGE_ORCHESTRATOR_ID,
SimSettings.GENERIC_EDGE_DEVICE_ID,
task.getCloudletOutputSize());
submitTaskToEdgeDevice(task,internalDelay); submitTaskToEdgeDevice(task,internalDelay);
break; break;
} }
*/
case REQUEST_RECIVED_BY_EDGE_DEVICE: case REQUEST_RECIVED_BY_EDGE_DEVICE:
{ {
Task task = (Task) ev.getData(); Task task = (Task) ev.getData();
networkModel.uploadFinished(task.getSubmittedLocation(), SimSettings.GENERIC_EDGE_DEVICE_ID);
submitTaskToEdgeDevice(task,0); submitTaskToEdgeDevice(task,0);
break; break;
} }
case RESPONSE_RECEIVED_BY_MOBILE_DEVICE: case RESPONSE_RECEIVED_BY_MOBILE_DEVICE:
{ {
Cloudlet cloudlet = (Cloudlet) ev.getData(); Task task = (Task) ev.getData();
if(task.getAssociatedHostId() == SimSettings.CLOUD_HOST_ID)
networkModel.downloadFinished(task.getSubmittedLocation(), SimSettings.CLOUD_DATACENTER_ID);
else
networkModel.downloadFinished(task.getSubmittedLocation(), SimSettings.GENERIC_EDGE_DEVICE_ID);
//SimLogger.printLine(CloudSim.clock() + ": " + getName() + ": Cloudlet " + cloudlet.getCloudletId() + " is received"); //SimLogger.printLine(CloudSim.clock() + ": " + getName() + ": Cloudlet " + cloudlet.getCloudletId() + " is received");
SimLogger.getInstance().downloaded(cloudlet.getCloudletId(), CloudSim.clock()); SimLogger.getInstance().downloaded(task.getCloudletId(), CloudSim.clock());
break; break;
} }
default: default:
@ -187,11 +204,7 @@ public class MobileDeviceManager extends DatacenterBroker {
EdgeVM selectedVM = SimManager.getInstance().getEdgeOrchestrator().getVmToOffload(task); EdgeVM selectedVM = SimManager.getInstance().getEdgeOrchestrator().getVmToOffload(task);
if(selectedVM != null){ if(selectedVM != null){
Location currentLocation = SimManager.getInstance().getMobilityModel(). //save related host id
getLocation(task.getMobileDeviceId(),CloudSim.clock());
//save task info
task.setSubmittedLocation(currentLocation);
task.setAssociatedHostId(selectedVM.getHost().getId()); task.setAssociatedHostId(selectedVM.getHost().getId());
//bind task to related VM //bind task to related VM
@ -219,6 +232,12 @@ public class MobileDeviceManager extends DatacenterBroker {
//create a task //create a task
Task task = createTask(edgeTask); Task task = createTask(edgeTask);
Location currentLocation = SimManager.getInstance().getMobilityModel().
getLocation(task.getMobileDeviceId(),CloudSim.clock());
//set location of the mobile device which generates this task
task.setSubmittedLocation(currentLocation);
//add related task to log list //add related task to log list
SimLogger.getInstance().addLog(CloudSim.clock(), SimLogger.getInstance().addLog(CloudSim.clock(),
task.getCloudletId(), task.getCloudletId(),
@ -230,38 +249,50 @@ public class MobileDeviceManager extends DatacenterBroker {
int nextHopId = SimManager.getInstance().getEdgeOrchestrator().getDeviceToOffload(task); int nextHopId = SimManager.getInstance().getEdgeOrchestrator().getDeviceToOffload(task);
if(nextHopId == SimSettings.CLOUD_DATACENTER_ID){ if(nextHopId == SimSettings.CLOUD_DATACENTER_ID){
double WanDelay = networkModel.getUploadDelay(task.getMobileDeviceId(), nextHopId); double WanDelay = networkModel.getUploadDelay(task.getMobileDeviceId(), nextHopId, task.getCloudletFileSize());
if(WanDelay>0){ if(WanDelay>0){
networkModel.uploadStarted(currentLocation, nextHopId);
schedule(getId(), WanDelay, REQUEST_RECEIVED_BY_CLOUD, task); schedule(getId(), WanDelay, REQUEST_RECEIVED_BY_CLOUD, task);
SimLogger.getInstance().uploadStarted(task.getCloudletId(),WanDelay); SimLogger.getInstance().uploadStarted(task.getCloudletId(),WanDelay);
} }
else else
{ {
//SimLogger.printLine("Task #" + task.getCloudletId() + " cannot assign to any VM"); //SimLogger.printLine("Task #" + task.getCloudletId() + " cannot assign to any VM");
SimLogger.getInstance().rejectedDueToBandwidth(task.getCloudletId(), CloudSim.clock()); SimLogger.getInstance().rejectedDueToBandwidth(
} task.getCloudletId(),
} CloudSim.clock(),
else if(nextHopId == SimSettings.EDGE_ORCHESTRATOR_ID){ SimSettings.VM_TYPES.CLOUD_VM.ordinal());
double WlanDelay = networkModel.getUploadDelay(task.getMobileDeviceId(), nextHopId);
if(WlanDelay > 0){
schedule(getId(), WlanDelay, REQUEST_RECIVED_BY_EDGE_ORCHESTRATOR, task);
SimLogger.getInstance().uploadStarted(task.getCloudletId(),WlanDelay);
}
else {
SimLogger.getInstance().rejectedDueToBandwidth(task.getCloudletId(), CloudSim.clock());
} }
} }
// else if(nextHopId == SimSettings.EDGE_ORCHESTRATOR_ID){
// double WlanDelay = networkModel.getUploadDelay(task.getMobileDeviceId(), nextHopId, task.getCloudletFileSize());
//
// if(WlanDelay > 0){
// networkModel.uploadStarted(task.getMobileDeviceId(), nextHopId, task.getCloudletFileSize());
// schedule(getId(), WlanDelay, REQUEST_RECIVED_BY_EDGE_ORCHESTRATOR, task);
// SimLogger.getInstance().uploadStarted(task.getCloudletId(),WlanDelay);
// }
// else {
// SimLogger.getInstance().rejectedDueToBandwidth(
// task.getCloudletId(),
// CloudSim.clock(),
// SimSettings.VM_TYPES.EDGE_VM.ordinal());
// }
// }
else if(nextHopId == SimSettings.GENERIC_EDGE_DEVICE_ID) { else if(nextHopId == SimSettings.GENERIC_EDGE_DEVICE_ID) {
double WlanDelay = networkModel.getUploadDelay(task.getMobileDeviceId(), nextHopId); double WlanDelay = networkModel.getUploadDelay(task.getMobileDeviceId(), nextHopId, task.getCloudletFileSize());
if(WlanDelay > 0){ if(WlanDelay > 0){
networkModel.uploadStarted(currentLocation, nextHopId);
schedule(getId(), WlanDelay, REQUEST_RECIVED_BY_EDGE_DEVICE, task); schedule(getId(), WlanDelay, REQUEST_RECIVED_BY_EDGE_DEVICE, task);
SimLogger.getInstance().uploadStarted(task.getCloudletId(),WlanDelay); SimLogger.getInstance().uploadStarted(task.getCloudletId(),WlanDelay);
} }
else { else {
SimLogger.getInstance().rejectedDueToBandwidth(task.getCloudletId(), CloudSim.clock()); SimLogger.getInstance().rejectedDueToBandwidth(
task.getCloudletId(),
CloudSim.clock(),
SimSettings.VM_TYPES.EDGE_VM.ordinal());
} }
} }
else { else {

View File

@ -53,7 +53,7 @@ public class BasicEdgeOrchestrator extends EdgeOrchestrator {
if(CloudVmPicker <= SimSettings.getInstance().getTaskLookUpTable()[task.getTaskType().ordinal()][1]) if(CloudVmPicker <= SimSettings.getInstance().getTaskLookUpTable()[task.getTaskType().ordinal()][1])
result = SimSettings.CLOUD_DATACENTER_ID; result = SimSettings.CLOUD_DATACENTER_ID;
else else
result = SimSettings.EDGE_ORCHESTRATOR_ID; result = SimSettings.GENERIC_EDGE_DEVICE_ID;
} }
return result; return result;

View File

@ -17,6 +17,7 @@ import java.util.List;
import java.util.TreeMap; import java.util.TreeMap;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.apache.commons.math3.distribution.ExponentialDistribution;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.w3c.dom.Node; import org.w3c.dom.Node;
@ -24,7 +25,6 @@ import org.w3c.dom.NodeList;
import edu.boun.edgecloudsim.core.SimSettings; import edu.boun.edgecloudsim.core.SimSettings;
import edu.boun.edgecloudsim.utils.Location; import edu.boun.edgecloudsim.utils.Location;
import edu.boun.edgecloudsim.utils.PoissonDistr;
import edu.boun.edgecloudsim.utils.SimLogger; import edu.boun.edgecloudsim.utils.SimLogger;
import edu.boun.edgecloudsim.utils.SimUtils; import edu.boun.edgecloudsim.utils.SimUtils;
@ -40,7 +40,7 @@ public class NomadicMobility extends MobilityModel {
public void initialize() { public void initialize() {
treeMapArray = new ArrayList<TreeMap<Double, Location>>(); treeMapArray = new ArrayList<TreeMap<Double, Location>>();
PoissonDistr[] poissonRngList = new PoissonDistr[SimSettings.getInstance().getNumOfEdgeDatacenters()]; ExponentialDistribution[] expRngList = new ExponentialDistribution[SimSettings.getInstance().getNumOfEdgeDatacenters()];
//create random number generator for each place //create random number generator for each place
Document doc = SimSettings.getInstance().getEdgeDevicesDocument(); Document doc = SimSettings.getInstance().getEdgeDevicesDocument();
@ -52,7 +52,7 @@ public class NomadicMobility extends MobilityModel {
String attractiveness = location.getElementsByTagName("attractiveness").item(0).getTextContent(); String attractiveness = location.getElementsByTagName("attractiveness").item(0).getTextContent();
SimSettings.PLACE_TYPES placeType = SimUtils.stringToPlace(attractiveness); SimSettings.PLACE_TYPES placeType = SimUtils.stringToPlace(attractiveness);
poissonRngList[i] = new PoissonDistr(SimSettings.getInstance().getMobilityLookUpTable()[placeType.ordinal()]); expRngList[i] = new ExponentialDistribution(SimSettings.getInstance().getMobilityLookUpTable()[placeType.ordinal()]);
} }
//initialize tree maps and position of mobile devices //initialize tree maps and position of mobile devices
@ -79,7 +79,7 @@ public class NomadicMobility extends MobilityModel {
while(treeMap.lastKey() < SimSettings.getInstance().getSimulationTime()) { while(treeMap.lastKey() < SimSettings.getInstance().getSimulationTime()) {
boolean placeFound = false; boolean placeFound = false;
int currentLocationId = treeMap.lastEntry().getValue().getServingWlanId(); int currentLocationId = treeMap.lastEntry().getValue().getServingWlanId();
double waitingTime = poissonRngList[currentLocationId].sample() * 60; double waitingTime = expRngList[currentLocationId].sample();
while(placeFound == false){ while(placeFound == false){
int newDatacenterId = SimUtils.getRandomNumber(0,SimSettings.getInstance().getNumOfEdgeDatacenters()-1); int newDatacenterId = SimUtils.getRandomNumber(0,SimSettings.getInstance().getNumOfEdgeDatacenters()-1);

View File

@ -65,7 +65,7 @@ public class MM1Queue extends NetworkModel {
* source device is always mobile device in our simulation scenarios! * source device is always mobile device in our simulation scenarios!
*/ */
@Override @Override
public double getUploadDelay(int sourceDeviceId, int destDeviceId) { public double getUploadDelay(int sourceDeviceId, int destDeviceId, double dataSize) {
double delay = 0; double delay = 0;
Location accessPointLocation = SimManager.getInstance().getMobilityModel().getLocation(sourceDeviceId,CloudSim.clock()); Location accessPointLocation = SimManager.getInstance().getMobilityModel().getLocation(sourceDeviceId,CloudSim.clock());
@ -93,7 +93,7 @@ public class MM1Queue extends NetworkModel {
* destination device is always mobile device in our simulation scenarios! * destination device is always mobile device in our simulation scenarios!
*/ */
@Override @Override
public double getDownloadDelay(int sourceDeviceId, int destDeviceId) { public double getDownloadDelay(int sourceDeviceId, int destDeviceId, double dataSize) {
//Special Case -> edge orchestrator to edge device //Special Case -> edge orchestrator to edge device
if(sourceDeviceId == SimSettings.EDGE_ORCHESTRATOR_ID && if(sourceDeviceId == SimSettings.EDGE_ORCHESTRATOR_ID &&
destDeviceId == SimSettings.GENERIC_EDGE_DEVICE_ID){ destDeviceId == SimSettings.GENERIC_EDGE_DEVICE_ID){
@ -159,7 +159,9 @@ public class MM1Queue extends NetworkModel {
mu = Bps / avgTaskSize ; //task per seconds mu = Bps / avgTaskSize ; //task per seconds
double result = (double)1 / (mu-lamda*(double)deviceCount); double result = (double)1 / (mu-lamda*(double)deviceCount);
return result + propogationDelay; result += propogationDelay;
return (result > 5) ? -1 : result;
} }
private double getWlanDownloadDelay(Location accessPointLocation, double time) { private double getWlanDownloadDelay(Location accessPointLocation, double time) {
@ -193,4 +195,28 @@ public class MM1Queue extends NetworkModel {
avgTaskInputSize, avgTaskInputSize,
getDeviceCount(accessPointLocation, time)); getDeviceCount(accessPointLocation, time));
} }
@Override
public void uploadStarted(Location accessPointLocation, int destDeviceId) {
// TODO Auto-generated method stub
}
@Override
public void uploadFinished(Location accessPointLocation, int destDeviceId) {
// TODO Auto-generated method stub
}
@Override
public void downloadStarted(Location accessPointLocation, int sourceDeviceId) {
// TODO Auto-generated method stub
}
@Override
public void downloadFinished(Location accessPointLocation, int sourceDeviceId) {
// TODO Auto-generated method stub
}
} }

View File

@ -13,6 +13,8 @@
package edu.boun.edgecloudsim.network; package edu.boun.edgecloudsim.network;
import edu.boun.edgecloudsim.utils.Location;
public abstract class NetworkModel { public abstract class NetworkModel {
protected int numberOfMobileDevices; protected int numberOfMobileDevices;
@ -28,10 +30,19 @@ public abstract class NetworkModel {
/** /**
* calculates the upload delay from source to destination device * calculates the upload delay from source to destination device
*/ */
public abstract double getUploadDelay(int sourceDeviceId, int destDeviceId); public abstract double getUploadDelay(int sourceDeviceId, int destDeviceId, double dataSize);
/** /**
* calculates the download delay from source to destination device * calculates the download delay from source to destination device
*/ */
public abstract double getDownloadDelay(int sourceDeviceId, int destDeviceId); public abstract double getDownloadDelay(int sourceDeviceId, int destDeviceId, double dataSize);
/**
* Mobile device manager should inform network manager about the network operation
* This information may be important for some network delay models
*/
public abstract void uploadStarted(Location accessPointLocation, int destDeviceId);
public abstract void uploadFinished(Location accessPointLocation, int destDeviceId);
public abstract void downloadStarted(Location accessPointLocation, int sourceDeviceId);
public abstract void downloadFinished(Location accessPointLocation, int sourceDeviceId);
} }

View File

@ -50,9 +50,9 @@ public class mainApp {
else{ else{
SimLogger.printLine("Simulation setting file, output folder and iteration number are not provided! Using default ones..."); SimLogger.printLine("Simulation setting file, output folder and iteration number are not provided! Using default ones...");
String configName = "default_config"; String configName = "default_config";
configFile = "config/" + configName + ".properties"; configFile = "config/sample_application/" + configName + ".properties";
applicationsFile = "config/applications.xml"; applicationsFile = "config/sample_application/applications.xml";
edgeDevicesFile = "config/edge_devices.xml"; edgeDevicesFile = "config/sample_application/edge_devices.xml";
outputFolder = "D:/" + configName + "/ite" + iterationNumber; outputFolder = "D:/" + configName + "/ite" + iterationNumber;
} }
@ -101,9 +101,13 @@ public class mainApp {
// Initialize the CloudSim library // Initialize the CloudSim library
CloudSim.init(num_user, calendar, trace_flag, 0.01); CloudSim.init(num_user, calendar, trace_flag, 0.01);
// Generate EdgeCloudsim Scenario Factory
ScenarioFactory sampleFactory = new SampleScenarioFactory(j,SS.getSimulationTime(), orchestratorPolicy, simScenario); ScenarioFactory sampleFactory = new SampleScenarioFactory(j,SS.getSimulationTime(), orchestratorPolicy, simScenario);
// Generate EdgeCloudSim Simulation Manager
SimManager manager = new SimManager(sampleFactory, j, simScenario); SimManager manager = new SimManager(sampleFactory, j, simScenario);
// Start simulation
manager.startSimulation(); manager.startSimulation();
} }
catch (Exception e) catch (Exception e)

View File

@ -20,7 +20,6 @@ import org.apache.commons.math3.distribution.ExponentialDistribution;
import edu.boun.edgecloudsim.core.SimSettings; import edu.boun.edgecloudsim.core.SimSettings;
import edu.boun.edgecloudsim.core.SimSettings.APP_TYPES; import edu.boun.edgecloudsim.core.SimSettings.APP_TYPES;
import edu.boun.edgecloudsim.utils.EdgeTask; import edu.boun.edgecloudsim.utils.EdgeTask;
import edu.boun.edgecloudsim.utils.PoissonDistr;
import edu.boun.edgecloudsim.utils.SimLogger; import edu.boun.edgecloudsim.utils.SimLogger;
import edu.boun.edgecloudsim.utils.SimUtils; import edu.boun.edgecloudsim.utils.SimUtils;
@ -35,16 +34,16 @@ public class IdleActiveLoadGenerator extends LoadGeneratorModel{
taskList = new ArrayList<EdgeTask>(); taskList = new ArrayList<EdgeTask>();
//exponential number generator for file input size, file output size and task length //exponential number generator for file input size, file output size and task length
PoissonDistr[][] poissonRngList = new PoissonDistr[SimSettings.APP_TYPES.values().length][3]; ExponentialDistribution[][] expRngList = new ExponentialDistribution[SimSettings.APP_TYPES.values().length][3];
//create random number generator for each place //create random number generator for each place
for(int i=0; i<SimSettings.APP_TYPES.values().length; i++) { for(int i=0; i<SimSettings.APP_TYPES.values().length; i++) {
if(SimSettings.getInstance().getTaskLookUpTable()[i][0] ==0) if(SimSettings.getInstance().getTaskLookUpTable()[i][0] ==0)
break; continue;
poissonRngList[i][0] = new PoissonDistr(SimSettings.getInstance().getTaskLookUpTable()[i][5]); expRngList[i][0] = new ExponentialDistribution(SimSettings.getInstance().getTaskLookUpTable()[i][5]);
poissonRngList[i][1] = new PoissonDistr(SimSettings.getInstance().getTaskLookUpTable()[i][6]); expRngList[i][1] = new ExponentialDistribution(SimSettings.getInstance().getTaskLookUpTable()[i][6]);
poissonRngList[i][2] = new PoissonDistr(SimSettings.getInstance().getTaskLookUpTable()[i][7]); expRngList[i][2] = new ExponentialDistribution(SimSettings.getInstance().getTaskLookUpTable()[i][7]);
} }
//Each mobile device utilizes an app type (task type) //Each mobile device utilizes an app type (task type)
@ -87,7 +86,7 @@ public class IdleActiveLoadGenerator extends LoadGeneratorModel{
continue; continue;
} }
taskList.add(new EdgeTask(i,randomTaskType, virtualTime, poissonRngList)); taskList.add(new EdgeTask(i,randomTaskType, virtualTime, expRngList));
} }
} }
} }

View File

@ -10,6 +10,8 @@
package edu.boun.edgecloudsim.utils; package edu.boun.edgecloudsim.utils;
import org.apache.commons.math3.distribution.ExponentialDistribution;
import edu.boun.edgecloudsim.core.SimSettings; import edu.boun.edgecloudsim.core.SimSettings;
import edu.boun.edgecloudsim.core.SimSettings.APP_TYPES; import edu.boun.edgecloudsim.core.SimSettings.APP_TYPES;
@ -20,14 +22,14 @@ public class EdgeTask {
public int pesNumber; public int pesNumber;
public int mobileDeviceId; public int mobileDeviceId;
public EdgeTask(int _mobileDeviceId, APP_TYPES _taskType, double _startTime, PoissonDistr[][] poissonRngList) { public EdgeTask(int _mobileDeviceId, APP_TYPES _taskType, double _startTime, ExponentialDistribution[][] expRngList) {
mobileDeviceId=_mobileDeviceId; mobileDeviceId=_mobileDeviceId;
startTime=_startTime; startTime=_startTime;
taskType=_taskType; taskType=_taskType;
inputFileSize = (long)poissonRngList[_taskType.ordinal()][0].sample(); inputFileSize = (long)expRngList[_taskType.ordinal()][0].sample();
outputFileSize =(long)poissonRngList[_taskType.ordinal()][1].sample(); outputFileSize =(long)expRngList[_taskType.ordinal()][1].sample();
length = (long)poissonRngList[_taskType.ordinal()][2].sample(); length = (long)expRngList[_taskType.ordinal()][2].sample();
pesNumber = (int)SimSettings.getInstance().getTaskLookUpTable()[_taskType.ordinal()][8]; pesNumber = (int)SimSettings.getInstance().getTaskLookUpTable()[_taskType.ordinal()][8];
} }

View File

@ -1,7 +1,7 @@
/* /*
* Title: EdgeCloudSim - Poisson Distribution * Title: EdgeCloudSim - Poisson Distribution
* *
* Description: Poisson Distribution implementation * Description: Wrapper class for colt Poisson Distribution
* *
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html * Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* Copyright (c) 2017, Bogazici University, Istanbul, Turkey * Copyright (c) 2017, Bogazici University, Istanbul, Turkey
@ -9,28 +9,16 @@
package edu.boun.edgecloudsim.utils; package edu.boun.edgecloudsim.utils;
import java.util.Random; import java.util.Date;
import java.util.concurrent.TimeUnit;
import cern.jet.random.Poisson;
import cern.jet.random.engine.MersenneTwister;
import cern.jet.random.engine.RandomEngine;
public class PoissonDistr { public class PoissonDistr {
/** The num gen. */ Poisson poisson;
private final Random numGen; RandomEngine engine;
/** The mean. */
private final double mean;
/**
* Creates a new exponential number generator.
*
* @param seed the seed to be used.
* @param mean the mean for the distribution.
*/
public PoissonDistr(long seed, double mean) {
if (mean <= 0.0) {
throw new IllegalArgumentException("Mean must be greater than 0.0");
}
numGen = new Random(seed);
this.mean = mean;
}
/** /**
* Creates a new exponential number generator. * Creates a new exponential number generator.
@ -38,11 +26,17 @@ public class PoissonDistr {
* @param mean the mean for the distribution. * @param mean the mean for the distribution.
*/ */
public PoissonDistr(double mean) { public PoissonDistr(double mean) {
if (mean <= 0.0) { engine = new MersenneTwister(new Date());
throw new IllegalArgumentException("Mean must be greated than 0.0"); poisson = new Poisson(mean, engine);
//always sleep for some milliseconds in order not to have same seed for iterative PoissonDistr contruction
try {
TimeUnit.MILLISECONDS.sleep(10);
} catch (InterruptedException e) {
SimLogger.printLine("impossible is occured! Poisson random number cannot be created!");
e.printStackTrace();
System.exit(0);
} }
numGen = new Random(System.currentTimeMillis());
this.mean = mean;
} }
/** /**
@ -51,13 +45,6 @@ public class PoissonDistr {
* @return the next random number in the sequence * @return the next random number in the sequence
*/ */
public double sample() { public double sample() {
double L = Math.exp(-mean); return poisson.nextDouble();
int k = 0;
double p = 1.0;
do {
p = p * numGen.nextDouble();
k++;
} while (p > L);
return k - 1;
} }
} }

View File

@ -21,20 +21,15 @@ import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Map; import java.util.Map;
import java.util.stream.DoubleStream;
import java.util.stream.IntStream;
import edu.boun.edgecloudsim.core.SimManager; import edu.boun.edgecloudsim.core.SimManager;
import edu.boun.edgecloudsim.core.SimSettings; import edu.boun.edgecloudsim.core.SimSettings;
public class SimLogger { public class SimLogger {
public static enum TASK_STATUS {CREATED, public static enum TASK_STATUS {
UPLOADING, CREATED, UPLOADING, PROCESSING, DOWNLOADING, COMLETED, REJECTED_DUE_TO_VM_CAPACITY, REJECTED_DUE_TO_BANDWIDTH, UNFINISHED_DUE_TO_BANDWIDTH, UNFINISHED_DUE_TO_MOBILITY
PROCESSING,
DOWNLOADING,
COMLETED,
REJECTED_DUE_TO_VM_CAPACITY,
REJECTED_DUE_TO_BANDWIDTH,
UNFINISHED_DUE_TO_BANDWIDTH,
UNFINISHED_DUE_TO_MOBILITY
} }
private static boolean fileLogEnabled; private static boolean fileLogEnabled;
@ -46,8 +41,8 @@ public class SimLogger {
private static SimLogger singleton = new SimLogger(); private static SimLogger singleton = new SimLogger();
/* A private Constructor prevents any other /*
* class from instantiating. * A private Constructor prevents any other class from instantiating.
*/ */
private SimLogger() { private SimLogger() {
fileLogEnabled = false; fileLogEnabled = false;
@ -97,7 +92,8 @@ public class SimLogger {
vmLoadList = new LinkedList<VmLoadLogItem>(); vmLoadList = new LinkedList<VmLoadLogItem>();
} }
public void addLog(double taskStartTime, int taskId, int taskType, int taskLenght, int taskInputType, int taskOutputSize) { public void addLog(double taskStartTime, int taskId, int taskType, int taskLenght, int taskInputType,
int taskOutputSize) {
// printLine(taskId+"->"+taskStartTime); // printLine(taskId+"->"+taskStartTime);
taskMap.put(taskId, new LogItem(taskStartTime, taskType, taskLenght, taskInputType, taskOutputSize)); taskMap.put(taskId, new LogItem(taskStartTime, taskType, taskLenght, taskInputType, taskOutputSize));
} }
@ -122,8 +118,8 @@ public class SimLogger {
taskMap.get(taskId).taskRejectedDueToVMCapacity(taskRejectTime); taskMap.get(taskId).taskRejectedDueToVMCapacity(taskRejectTime);
} }
public void rejectedDueToBandwidth(int taskId, double taskRejectTime) { public void rejectedDueToBandwidth(int taskId, double taskRejectTime, int vmType) {
taskMap.get(taskId).taskRejectedDueToBandwidth(taskRejectTime); taskMap.get(taskId).taskRejectedDueToBandwidth(taskRejectTime, vmType);
} }
public void failedDueToBandwidth(int taskId, double taskRejectTime) { public void failedDueToBandwidth(int taskId, double taskRejectTime) {
@ -139,60 +135,96 @@ public class SimLogger {
} }
public void simStopped() throws IOException { public void simStopped() throws IOException {
File file1=null,file2=null,file3=null,file4=null,file5=null; int numOfAppTypes = SimSettings.getInstance().getTaskLookUpTable().length;
FileWriter fileWriter1=null,fileWriter2=null,fileWriter3=null,fileWriter4=null,fileWriter5=null;
BufferedWriter bufferedWriter1=null,bufferedWriter2=null,bufferedWriter3=null,bufferedWriter4=null,bufferedWriter5=null;
int uncompletedTaskOnCloudlet = 0; File successFile = null, failFile = null, vmLoadFile = null, locationFile = null;
int completedTaskOnCloudlet = 0; FileWriter successFW = null, failFW = null, vmLoadFW = null, locationFW = null;
int uncompletedTaskOnCloud = 0; BufferedWriter successBW = null, failBW = null, vmLoadBW = null, locationBW = null;
int completedTaskOnCloud = 0;
int rejectedTaskDoToVmCapacity = 0; // Save generic results to file for each app type. last index is average
int rejectedTaskDoToBandwidth = 0; // of all app types
int failedTaskDuetoBandwidth = 0; File[] genericFiles = new File[numOfAppTypes + 1];
int failedTaskDuetoMobility = 0; FileWriter[] genericFWs = new FileWriter[numOfAppTypes + 1];
int totalCompletedTask = 0; BufferedWriter[] genericBWs = new BufferedWriter[numOfAppTypes + 1];
int totalFailedTask = 0;
double totalCost = 0; // extract following values for each app type. last index is average of
double totalLanDelay = 0; // all app types
double totalWanDelay = 0; int[] uncompletedTask = new int[numOfAppTypes + 1];
double totalServiceTime = 0; int[] uncompletedTaskOnCloud = new int[numOfAppTypes + 1];
double totalNetworkDelay = 0; int[] uncompletedTaskOnCloudlet = new int[numOfAppTypes + 1];
double totalProcessingTime = 0;
double totalVmLoad = 0; int[] completedTask = new int[numOfAppTypes + 1];
int[] completedTaskOnCloud = new int[numOfAppTypes + 1];
int[] completedTaskOnCloudlet = new int[numOfAppTypes + 1];
int[] failedTask = new int[numOfAppTypes + 1];
int[] failedTaskOnCloud = new int[numOfAppTypes + 1];
int[] failedTaskOnCloudlet = new int[numOfAppTypes + 1];
double[] networkDelay = new double[numOfAppTypes + 1];
double[] wanDelay = new double[numOfAppTypes + 1];
double[] lanDelay = new double[numOfAppTypes + 1];
double[] serviceTime = new double[numOfAppTypes + 1];
double[] serviceTimeOnCloud = new double[numOfAppTypes + 1];
double[] serviceTimeOnCloudlet = new double[numOfAppTypes + 1];
double[] processingTime = new double[numOfAppTypes + 1];
double[] processingTimeOnCloud = new double[numOfAppTypes + 1];
double[] processingTimeOnCloudlet = new double[numOfAppTypes + 1];
double[] cost = new double[numOfAppTypes + 1];
int[] failedTaskDuetoBw = new int[numOfAppTypes + 1];
int[] failedTaskDuetoLanBw = new int[numOfAppTypes + 1];
int[] failedTaskDuetoWanBw = new int[numOfAppTypes + 1];
int[] failedTaskDuetoMobility = new int[numOfAppTypes + 1];
int[] rejectedTaskDoToVmCapacity = new int[numOfAppTypes + 1];
// open all files and prepare them for write // open all files and prepare them for write
if (fileLogEnabled) { if (fileLogEnabled) {
if (SimSettings.getInstance().getDeepFileLoggingEnabled()) { if (SimSettings.getInstance().getDeepFileLoggingEnabled()) {
file1 = new File(outputFolder, filePrefix+"_SUCCESS.log"); successFile = new File(outputFolder, filePrefix + "_SUCCESS.log");
fileWriter1 = new FileWriter(file1, true); successFW = new FileWriter(successFile, true);
bufferedWriter1 = new BufferedWriter(fileWriter1); successBW = new BufferedWriter(successFW);
file2 = new File(outputFolder, filePrefix+"_FAIL.log"); failFile = new File(outputFolder, filePrefix + "_FAIL.log");
fileWriter2 = new FileWriter(file2, true); failFW = new FileWriter(failFile, true);
bufferedWriter2 = new BufferedWriter(fileWriter2); failBW = new BufferedWriter(failFW);
} }
file3 = new File(outputFolder, filePrefix+"_VM_LOAD.log"); vmLoadFile = new File(outputFolder, filePrefix + "_VM_LOAD.log");
fileWriter3 = new FileWriter(file3, true); vmLoadFW = new FileWriter(vmLoadFile, true);
bufferedWriter3 = new BufferedWriter(fileWriter3); vmLoadBW = new BufferedWriter(vmLoadFW);
file4 = new File(outputFolder, filePrefix+"_GENERIC.log"); locationFile = new File(outputFolder, filePrefix + "_LOCATION.log");
fileWriter4 = new FileWriter(file4, true); locationFW = new FileWriter(locationFile, true);
bufferedWriter4 = new BufferedWriter(fileWriter4); locationBW = new BufferedWriter(locationFW);
file5 = new File(outputFolder, filePrefix+"_LOCATION.log"); for (int i = 0; i < numOfAppTypes + 1; i++) {
fileWriter5 = new FileWriter(file5, true); String fileName = "ALL_APPS_GENERIC.log";
bufferedWriter5 = new BufferedWriter(fileWriter5);
if (i < numOfAppTypes) {
// if related app is not used in this simulation, just
// discard it
if (SimSettings.getInstance().getTaskLookUpTable()[i][0] == 0)
continue;
fileName = SimSettings.APP_TYPES.values()[i] + "_GENERIC.log";
}
genericFiles[i] = new File(outputFolder, filePrefix + "_" + fileName);
genericFWs[i] = new FileWriter(genericFiles[i], true);
genericBWs[i] = new BufferedWriter(genericFWs[i]);
appendToFile(genericBWs[i], "#auto generated file!");
}
if (SimSettings.getInstance().getDeepFileLoggingEnabled()) { if (SimSettings.getInstance().getDeepFileLoggingEnabled()) {
appendToFile(bufferedWriter1, "# taskId;dataCenterId;hostId;vmId;vmType;taskType;taskLenght;taskInputType;taskOutputSize;taskStartTime;taskEndTime;nwDelay"); appendToFile(successBW, "#auto generated file!");
appendToFile(bufferedWriter2, "# taskId;dataCenterId;hostId;vmId;vmType;taskType;taskLenght;taskInputType;taskOutputSize;taskStartTime;taskEndTime;failReason"); appendToFile(failBW, "#auto generated file!");
} }
appendToFile(bufferedWriter3, "# time;load"); appendToFile(vmLoadBW, "#auto generated file!");
appendToFile(bufferedWriter4, "# completedTask;uncompletedTask;rejectedTask;failedDueToMobilityTask;avgFailure;avgServiceTime;avgNetworkDelay;avgServerLoad;avgCost"); appendToFile(locationBW, "#auto generated file!");
appendToFile(bufferedWriter5, "# time;#ofClient@PlaceType1;#ofClient@PlaceTypen");
} }
// extract the result of each task and write it to the file if required // extract the result of each task and write it to the file if required
@ -204,123 +236,275 @@ public class SimLogger {
continue; continue;
if (value.getStatus() == SimLogger.TASK_STATUS.COMLETED) { if (value.getStatus() == SimLogger.TASK_STATUS.COMLETED) {
completedTask[value.getTaskType()]++;
if (value.getVmType() == SimSettings.VM_TYPES.CLOUD_VM.ordinal())
completedTaskOnCloud[value.getTaskType()]++;
else
completedTaskOnCloudlet[value.getTaskType()]++;
} else {
failedTask[value.getTaskType()]++;
if (value.getVmType() == SimSettings.VM_TYPES.CLOUD_VM.ordinal())
failedTaskOnCloud[value.getTaskType()]++;
else
failedTaskOnCloudlet[value.getTaskType()]++;
}
if (value.getStatus() == SimLogger.TASK_STATUS.COMLETED) {
cost[value.getTaskType()] += value.getCost();
serviceTime[value.getTaskType()] += value.getServiceTime();
networkDelay[value.getTaskType()] += value.getNetworkDelay();
processingTime[value.getTaskType()] += (value.getServiceTime() - value.getNetworkDelay());
if (value.getVmType() == SimSettings.VM_TYPES.CLOUD_VM.ordinal()) { if (value.getVmType() == SimSettings.VM_TYPES.CLOUD_VM.ordinal()) {
completedTaskOnCloud++; wanDelay[value.getTaskType()] += value.getNetworkDelay();
totalWanDelay += value.getNetworkDelay(); serviceTimeOnCloud[value.getTaskType()] += value.getServiceTime();
processingTimeOnCloud[value.getTaskType()] += (value.getServiceTime() - value.getNetworkDelay());
} else {
lanDelay[value.getTaskType()] += value.getNetworkDelay();
serviceTimeOnCloudlet[value.getTaskType()] += value.getServiceTime();
processingTimeOnCloudlet[value.getTaskType()] += (value.getServiceTime() - value.getNetworkDelay());
} }
else{
completedTaskOnCloudlet++;
totalLanDelay += value.getNetworkDelay();
}
totalCost += value.getCost();
totalServiceTime += value.getServiceTime();
totalNetworkDelay += value.getNetworkDelay();
totalProcessingTime += (value.getServiceTime() - value.getNetworkDelay());
if (fileLogEnabled && SimSettings.getInstance().getDeepFileLoggingEnabled()) if (fileLogEnabled && SimSettings.getInstance().getDeepFileLoggingEnabled())
appendToFile(bufferedWriter1, value.toString(key)); appendToFile(successBW, value.toString(key));
} } else if (value.getStatus() == SimLogger.TASK_STATUS.REJECTED_DUE_TO_VM_CAPACITY) {
else if(value.getStatus() == SimLogger.TASK_STATUS.REJECTED_DUE_TO_VM_CAPACITY){ rejectedTaskDoToVmCapacity[value.getTaskType()]++;
rejectedTaskDoToVmCapacity++;
if(fileLogEnabled && SimSettings.getInstance().getDeepFileLoggingEnabled())
appendToFile(bufferedWriter2, value.toString(key));
}
else if(value.getStatus() == SimLogger.TASK_STATUS.REJECTED_DUE_TO_BANDWIDTH){
rejectedTaskDoToBandwidth++;
if(fileLogEnabled && SimSettings.getInstance().getDeepFileLoggingEnabled())
appendToFile(bufferedWriter2, value.toString(key));
}
else if(value.getStatus() == SimLogger.TASK_STATUS.UNFINISHED_DUE_TO_BANDWIDTH){
failedTaskDuetoBandwidth++;
if(fileLogEnabled && SimSettings.getInstance().getDeepFileLoggingEnabled())
appendToFile(bufferedWriter2, value.toString(key));
}
else if(value.getStatus() == SimLogger.TASK_STATUS.UNFINISHED_DUE_TO_MOBILITY){
failedTaskDuetoMobility++;
if(fileLogEnabled && SimSettings.getInstance().getDeepFileLoggingEnabled())
appendToFile(bufferedWriter2, value.toString(key));
}
else {
if (value.getVmType() == SimSettings.VM_TYPES.CLOUD_VM.ordinal()) if (value.getVmType() == SimSettings.VM_TYPES.CLOUD_VM.ordinal())
uncompletedTaskOnCloud++; if (fileLogEnabled && SimSettings.getInstance().getDeepFileLoggingEnabled())
appendToFile(failBW, value.toString(key));
} else if (value.getStatus() == SimLogger.TASK_STATUS.REJECTED_DUE_TO_BANDWIDTH
|| value.getStatus() == SimLogger.TASK_STATUS.UNFINISHED_DUE_TO_BANDWIDTH) {
failedTaskDuetoBw[value.getTaskType()]++;
if (value.getVmType() == SimSettings.VM_TYPES.CLOUD_VM.ordinal())
failedTaskDuetoWanBw[value.getTaskType()]++;
else else
uncompletedTaskOnCloudlet++; failedTaskDuetoLanBw[value.getTaskType()]++;
if (fileLogEnabled && SimSettings.getInstance().getDeepFileLoggingEnabled())
appendToFile(failBW, value.toString(key));
} else if (value.getStatus() == SimLogger.TASK_STATUS.UNFINISHED_DUE_TO_MOBILITY) {
failedTaskDuetoMobility[value.getTaskType()]++;
if (fileLogEnabled && SimSettings.getInstance().getDeepFileLoggingEnabled())
appendToFile(failBW, value.toString(key));
} else {
uncompletedTask[value.getTaskType()]++;
if (value.getVmType() == SimSettings.VM_TYPES.CLOUD_VM.ordinal())
uncompletedTaskOnCloud[value.getTaskType()]++;
else
uncompletedTaskOnCloudlet[value.getTaskType()]++;
} }
} }
totalFailedTask = rejectedTaskDoToVmCapacity+rejectedTaskDoToBandwidth+failedTaskDuetoBandwidth;
totalCompletedTask = completedTaskOnCloudlet+completedTaskOnCloud; // calculate total values
uncompletedTask[numOfAppTypes] = IntStream.of(uncompletedTask).sum();
uncompletedTaskOnCloud[numOfAppTypes] = IntStream.of(uncompletedTaskOnCloud).sum();
uncompletedTaskOnCloudlet[numOfAppTypes] = IntStream.of(uncompletedTaskOnCloudlet).sum();
completedTask[numOfAppTypes] = IntStream.of(completedTask).sum();
completedTaskOnCloud[numOfAppTypes] = IntStream.of(completedTaskOnCloud).sum();
completedTaskOnCloudlet[numOfAppTypes] = IntStream.of(completedTaskOnCloudlet).sum();
failedTask[numOfAppTypes] = IntStream.of(failedTask).sum();
failedTaskOnCloud[numOfAppTypes] = IntStream.of(failedTaskOnCloud).sum();
failedTaskOnCloudlet[numOfAppTypes] = IntStream.of(failedTaskOnCloudlet).sum();
networkDelay[numOfAppTypes] = DoubleStream.of(networkDelay).sum();
lanDelay[numOfAppTypes] = DoubleStream.of(lanDelay).sum();
wanDelay[numOfAppTypes] = DoubleStream.of(wanDelay).sum();
serviceTime[numOfAppTypes] = DoubleStream.of(serviceTime).sum();
serviceTimeOnCloud[numOfAppTypes] = DoubleStream.of(serviceTimeOnCloud).sum();
serviceTimeOnCloudlet[numOfAppTypes] = DoubleStream.of(serviceTimeOnCloudlet).sum();
processingTime[numOfAppTypes] = DoubleStream.of(processingTime).sum();
processingTimeOnCloud[numOfAppTypes] = DoubleStream.of(processingTimeOnCloud).sum();
processingTimeOnCloudlet[numOfAppTypes] = DoubleStream.of(processingTimeOnCloudlet).sum();
cost[numOfAppTypes] = DoubleStream.of(cost).sum();
failedTaskDuetoBw[numOfAppTypes] = IntStream.of(failedTaskDuetoBw).sum();
failedTaskDuetoWanBw[numOfAppTypes] = IntStream.of(failedTaskDuetoWanBw).sum();
failedTaskDuetoLanBw[numOfAppTypes] = IntStream.of(failedTaskDuetoLanBw).sum();
failedTaskDuetoMobility[numOfAppTypes] = IntStream.of(failedTaskDuetoMobility).sum();
rejectedTaskDoToVmCapacity[numOfAppTypes] = IntStream.of(rejectedTaskDoToVmCapacity).sum();
// calculate server load // calculate server load
double totalVmLoad = 0;
for (VmLoadLogItem entry : vmLoadList) { for (VmLoadLogItem entry : vmLoadList) {
totalVmLoad += entry.getLoad(); totalVmLoad += entry.getLoad();
if (fileLogEnabled) if (fileLogEnabled)
appendToFile(bufferedWriter3, entry.toString()); appendToFile(vmLoadBW, entry.toString());
} }
if (fileLogEnabled) { if (fileLogEnabled) {
// write location info to file // write location info to file
for(int t=1; t<(SimSettings.getInstance().getSimulationTime()/SimSettings.getInstance().getVmLocationLogInterval()); t++){ for (int t = 1; t < (SimSettings.getInstance().getSimulationTime()
/ SimSettings.getInstance().getVmLocationLogInterval()); t++) {
int[] locationInfo = new int[SimSettings.PLACE_TYPES.values().length]; int[] locationInfo = new int[SimSettings.PLACE_TYPES.values().length];
Double time = t * SimSettings.getInstance().getVmLocationLogInterval();
if (time < SimSettings.getInstance().getWarmUpPeriod())
continue;
for (int i = 0; i < SimManager.getInstance().getNumOfMobileDevice(); i++) { for (int i = 0; i < SimManager.getInstance().getNumOfMobileDevice(); i++) {
Location loc = SimManager.getInstance().getMobilityModel().getLocation(i, t*SimSettings.getInstance().getVmLocationLogInterval()); Location loc = SimManager.getInstance().getMobilityModel().getLocation(i, time);
SimSettings.PLACE_TYPES placeType = loc.getPlaceType(); SimSettings.PLACE_TYPES placeType = loc.getPlaceType();
locationInfo[placeType.ordinal()]++; locationInfo[placeType.ordinal()]++;
} }
Double time=t*SimSettings.getInstance().getVmLocationLogInterval(); locationBW.write(time.toString());
bufferedWriter5.write(time.toString());
for (int i = 0; i < locationInfo.length; i++) for (int i = 0; i < locationInfo.length; i++)
bufferedWriter5.write(SimSettings.DELIMITER + locationInfo[i]); locationBW.write(SimSettings.DELIMITER + locationInfo[i]);
bufferedWriter5.newLine(); locationBW.newLine();
} }
//write generic results for (int i = 0; i < numOfAppTypes + 1; i++) {
String genericResult = Integer.toString(completedTaskOnCloudlet) + SimSettings.DELIMITER +
Integer.toString(uncompletedTaskOnCloudlet) + SimSettings.DELIMITER +
Integer.toString(completedTaskOnCloud) + SimSettings.DELIMITER +
Integer.toString(uncompletedTaskOnCloud) + SimSettings.DELIMITER +
Integer.toString(rejectedTaskDoToVmCapacity) + SimSettings.DELIMITER +
Integer.toString(rejectedTaskDoToBandwidth) + SimSettings.DELIMITER +
Integer.toString(failedTaskDuetoBandwidth) + SimSettings.DELIMITER +
Integer.toString(failedTaskDuetoMobility) + SimSettings.DELIMITER +
Double.toString(((double)totalFailedTask*(double)100)/(double)(totalCompletedTask+totalFailedTask)) + SimSettings.DELIMITER +
Double.toString(totalServiceTime/(double)totalCompletedTask) + SimSettings.DELIMITER +
Double.toString(totalNetworkDelay/(double)totalCompletedTask) + SimSettings.DELIMITER +
Double.toString(totalLanDelay/(double)totalCompletedTask) + SimSettings.DELIMITER +
Double.toString(totalWanDelay/(double)totalCompletedTask) + SimSettings.DELIMITER +
Double.toString(totalProcessingTime/(double)totalCompletedTask) + SimSettings.DELIMITER +
Double.toString(totalVmLoad/(double)vmLoadList.size()) + SimSettings.DELIMITER +
Double.toString(totalCost/(double)totalCompletedTask);
appendToFile(bufferedWriter4,genericResult); if (i < numOfAppTypes) {
// if related app is not used in this simulation, just
// discard it
if (SimSettings.getInstance().getTaskLookUpTable()[i][0] == 0)
continue;
}
// check if the divisor is zero in order to avoid division by
// zero problem
double _serviceTime = (completedTask[i] == 0) ? 0.0 : (serviceTime[i] / (double) completedTask[i]);
double _networkDelay = (completedTask[i] == 0) ? 0.0 : (networkDelay[i] / (double) completedTask[i]);
double _processingTime = (completedTask[i] == 0) ? 0.0 : (processingTime[i] / (double) completedTask[i]);
double _vmLoad = (vmLoadList.size() == 0) ? 0.0 : (totalVmLoad / (double) vmLoadList.size());
double _cost = (completedTask[i] == 0) ? 0.0 : (cost[i] / (double) completedTask[i]);
// write generic results
String genericResult1 = Integer.toString(completedTask[i]) + SimSettings.DELIMITER
+ Integer.toString(failedTask[i]) + SimSettings.DELIMITER
+ Integer.toString(uncompletedTask[i]) + SimSettings.DELIMITER
+ Integer.toString(failedTaskDuetoBw[i]) + SimSettings.DELIMITER
+ Double.toString(_serviceTime) + SimSettings.DELIMITER
+ Double.toString(_processingTime) + SimSettings.DELIMITER
+ Double.toString(_networkDelay) + SimSettings.DELIMITER
+ Double.toString(_vmLoad) + SimSettings.DELIMITER
+ Double.toString(_cost) + SimSettings.DELIMITER
+ Integer.toString(rejectedTaskDoToVmCapacity[i]) + SimSettings.DELIMITER
+ Integer.toString(failedTaskDuetoMobility[i]);
// check if the divisor is zero in order to avoid division by
// zero problem
double _lanDelay = (completedTaskOnCloudlet[i] == 0) ? 0.0
: (lanDelay[i] / (double) completedTaskOnCloudlet[i]);
double _serviceTimeOnCloudlet = (completedTaskOnCloudlet[i] == 0) ? 0.0
: (serviceTimeOnCloudlet[i] / (double) completedTaskOnCloudlet[i]);
double _processingTimeOnCloudlet = (completedTaskOnCloudlet[i] == 0) ? 0.0
: (processingTimeOnCloudlet[i] / (double) completedTaskOnCloudlet[i]);
String genericResult2 = Integer.toString(completedTaskOnCloudlet[i]) + SimSettings.DELIMITER
+ Integer.toString(failedTaskOnCloudlet[i]) + SimSettings.DELIMITER
+ Integer.toString(uncompletedTaskOnCloudlet[i]) + SimSettings.DELIMITER
+ Integer.toString(failedTaskDuetoLanBw[i]) + SimSettings.DELIMITER
+ Double.toString(_serviceTimeOnCloudlet) + SimSettings.DELIMITER
+ Double.toString(_processingTimeOnCloudlet) + SimSettings.DELIMITER
+ Double.toString(_lanDelay);
// check if the divisor is zero in order to avoid division by
// zero problem
double _wanDelay = (completedTaskOnCloud[i] == 0) ? 0.0
: (wanDelay[i] / (double) completedTaskOnCloud[i]);
double _serviceTimeOnCloud = (completedTaskOnCloud[i] == 0) ? 0.0
: (serviceTimeOnCloud[i] / (double) completedTaskOnCloud[i]);
double _processingTimeOnCloud = (completedTaskOnCloud[i] == 0) ? 0.0
: (processingTimeOnCloud[i] / (double) completedTaskOnCloud[i]);
String genericResult3 = Integer.toString(completedTaskOnCloud[i]) + SimSettings.DELIMITER
+ Integer.toString(failedTaskOnCloud[i]) + SimSettings.DELIMITER
+ Integer.toString(uncompletedTaskOnCloud[i]) + SimSettings.DELIMITER
+ Integer.toString(failedTaskDuetoWanBw[i]) + SimSettings.DELIMITER
+ Double.toString(_serviceTimeOnCloud) + SimSettings.DELIMITER
+ Double.toString(_processingTimeOnCloud) + SimSettings.DELIMITER
+ Double.toString(_wanDelay);
appendToFile(genericBWs[i], genericResult1);
appendToFile(genericBWs[i], genericResult2);
appendToFile(genericBWs[i], genericResult3);
}
// close open files // close open files
if (SimSettings.getInstance().getDeepFileLoggingEnabled()) { if (SimSettings.getInstance().getDeepFileLoggingEnabled()) {
bufferedWriter1.close(); successBW.close();
bufferedWriter2.close(); failBW.close();
}
vmLoadBW.close();
locationBW.close();
for (int i = 0; i < numOfAppTypes + 1; i++) {
if (i < numOfAppTypes) {
// if related app is not used in this simulation, just
// discard it
if (SimSettings.getInstance().getTaskLookUpTable()[i][0] == 0)
continue;
}
genericBWs[i].close();
} }
bufferedWriter3.close();
bufferedWriter4.close();
bufferedWriter5.close();
} }
// printout important results // printout important results
printLine("# of uncompleted tasks on Cloudlet/Cloud: " + uncompletedTaskOnCloudlet + "/" + uncompletedTaskOnCloud); printLine("# of tasks (Cloudlet/Cloud): "
printLine("# of completed task on Cloudlet/Cloud: " + (completedTaskOnCloudlet+uncompletedTaskOnCloudlet) + "/" + (completedTaskOnCloud+uncompletedTaskOnCloud)); + (failedTask[numOfAppTypes] + completedTask[numOfAppTypes]) + "("
printLine("# of rejected tasks (due to vm capacity): " + rejectedTaskDoToVmCapacity); + (failedTaskOnCloudlet[numOfAppTypes] + completedTaskOnCloudlet[numOfAppTypes]) + "/"
printLine("# of rejected tasks (due to bandwidth): " + rejectedTaskDoToBandwidth); + (failedTaskOnCloud[numOfAppTypes]+ completedTaskOnCloud[numOfAppTypes]) + ")");
printLine("# of failed tasks (due to bandwidth): " + failedTaskDuetoBandwidth);
printLine("# of failed tasks (due to mobility): " + failedTaskDuetoMobility); printLine("# of failed tasks (Cloudlet/Cloud): "
printLine("percentage of failed task: " + String.format("%.6f", ((double)totalFailedTask*(double)100)/(double)(totalCompletedTask+totalFailedTask)) + "%"); + failedTask[numOfAppTypes] + "("
printLine("average service time: " + String.format("%.6f", totalServiceTime/(double)totalCompletedTask) + " seconds. (" + failedTaskOnCloudlet[numOfAppTypes]
+ "processing time: " + String.format("%.6f", totalProcessingTime/(double)totalCompletedTask) + ")"); + "/" + failedTaskOnCloud[numOfAppTypes] + ")");
printLine("average netwrok delay: " + String.format("%.6f", totalNetworkDelay/(double)totalCompletedTask) + " seconds. ("
+ "LAN delay: " + String.format("%.6f", totalLanDelay/(double)totalCompletedTask) + ", " printLine("# of completed tasks (Cloudlet/Cloud): "
+ "WAN delay: " + String.format("%.6f", totalWanDelay/(double)totalCompletedTask) + ")"); + completedTask[numOfAppTypes] + "("
printLine("average server utilization: " + String.format("%.6f", totalVmLoad/(double)vmLoadList.size()) + "%"); + completedTaskOnCloudlet[numOfAppTypes]
printLine("average cost: " + totalCost/totalCompletedTask + "$"); + "/" + completedTaskOnCloud[numOfAppTypes] + ")");
printLine("# of uncompleted tasks (Cloudlet/Cloud): "
+ uncompletedTask[numOfAppTypes] + "("
+ uncompletedTaskOnCloudlet[numOfAppTypes]
+ "/" + uncompletedTaskOnCloud[numOfAppTypes] + ")");
printLine("# of failed tasks due to vm capacity/LAN bw/WAN bw/mobility: "
+ rejectedTaskDoToVmCapacity[numOfAppTypes]
+ "/" + +failedTaskDuetoLanBw[numOfAppTypes]
+ "/" + +failedTaskDuetoWanBw[numOfAppTypes]
+ "/" + failedTaskDuetoMobility[numOfAppTypes]);
printLine("percentage of failed tasks: "
+ String.format("%.6f", ((double) failedTask[numOfAppTypes] * (double) 100)
/ (double) (completedTask[numOfAppTypes] + failedTask[numOfAppTypes]))
+ "%");
printLine("average service time: "
+ String.format("%.6f", serviceTime[numOfAppTypes] / (double) completedTask[numOfAppTypes])
+ " seconds. (" + "on Cloudlet: "
+ String.format("%.6f", serviceTimeOnCloudlet[numOfAppTypes] / (double) completedTaskOnCloudlet[numOfAppTypes])
+ ", " + "on Cloud: "
+ String.format("%.6f", serviceTimeOnCloud[numOfAppTypes] / (double) completedTaskOnCloud[numOfAppTypes])
+ ")");
printLine("average processing time: "
+ String.format("%.6f", processingTime[numOfAppTypes] / (double) completedTask[numOfAppTypes])
+ " seconds. (" + "on Cloudlet: "
+ String.format("%.6f", processingTimeOnCloudlet[numOfAppTypes] / (double) completedTaskOnCloudlet[numOfAppTypes])
+ ", " + "on Cloud: "
+ String.format("%.6f", processingTimeOnCloud[numOfAppTypes] / (double) completedTaskOnCloud[numOfAppTypes])
+ ")");
printLine("average netwrok delay: "
+ String.format("%.6f", networkDelay[numOfAppTypes] / (double) completedTask[numOfAppTypes])
+ " seconds. (" + "LAN delay: "
+ String.format("%.6f", lanDelay[numOfAppTypes] / (double) completedTaskOnCloudlet[numOfAppTypes])
+ ", " + "WAN delay: "
+ String.format("%.6f", wanDelay[numOfAppTypes] / (double) completedTaskOnCloud[numOfAppTypes]) + ")");
printLine("average server utilization: "
+ String.format("%.6f", totalVmLoad / (double) vmLoadList.size()) + "%");
printLine("average cost: " + cost[numOfAppTypes] / completedTask[numOfAppTypes] + "$");
// clear related collections (map list etc.) // clear related collections (map list etc.)
taskMap.clear(); taskMap.clear();
@ -328,27 +512,25 @@ public class SimLogger {
} }
} }
class VmLoadLogItem class VmLoadLogItem {
{
private double time; private double time;
private double vmLoad; private double vmLoad;
VmLoadLogItem(double _time, double _vmLoad) VmLoadLogItem(double _time, double _vmLoad) {
{
time = _time; time = _time;
vmLoad = _vmLoad; vmLoad = _vmLoad;
} }
public double getLoad()
{ public double getLoad() {
return vmLoad; return vmLoad;
} }
public String toString()
{ public String toString() {
return time + SimSettings.DELIMITER + vmLoad; return time + SimSettings.DELIMITER + vmLoad;
} }
} }
class LogItem
{ class LogItem {
private SimLogger.TASK_STATUS status; private SimLogger.TASK_STATUS status;
private int datacenterId; private int datacenterId;
private int hostId; private int hostId;
@ -364,8 +546,8 @@ class LogItem
private double bwCost; private double bwCost;
private double cpuCost; private double cpuCost;
private boolean isInWarmUpPeriod; private boolean isInWarmUpPeriod;
LogItem (double _taskStartTime, int _taskType, int _taskLenght, int _taskInputType, int _taskOutputSize)
{ LogItem(double _taskStartTime, int _taskType, int _taskLenght, int _taskInputType, int _taskOutputSize) {
taskStartTime = _taskStartTime; taskStartTime = _taskStartTime;
taskType = _taskType; taskType = _taskType;
taskLenght = _taskLenght; taskLenght = _taskLenght;
@ -379,10 +561,12 @@ class LogItem
else else
isInWarmUpPeriod = false; isInWarmUpPeriod = false;
} }
public void taskUploadStarted(double taskUploadTime) { public void taskUploadStarted(double taskUploadTime) {
networkDelay += taskUploadTime; networkDelay += taskUploadTime;
status = SimLogger.TASK_STATUS.UPLOADING; status = SimLogger.TASK_STATUS.UPLOADING;
} }
public void taskUploaded(int _datacenterId, int _hostId, int _vmId, int _vmType) { public void taskUploaded(int _datacenterId, int _hostId, int _vmId, int _vmType) {
status = SimLogger.TASK_STATUS.PROCESSING; status = SimLogger.TASK_STATUS.PROCESSING;
datacenterId = _datacenterId; datacenterId = _datacenterId;
@ -390,65 +574,77 @@ class LogItem
vmId = _vmId; vmId = _vmId;
vmType = _vmType; vmType = _vmType;
} }
public void taskDownloadStarted(double taskDownloadTime) { public void taskDownloadStarted(double taskDownloadTime) {
networkDelay += taskDownloadTime; networkDelay += taskDownloadTime;
status = SimLogger.TASK_STATUS.DOWNLOADING; status = SimLogger.TASK_STATUS.DOWNLOADING;
} }
public void taskDownloaded(double _taskEndTime) { public void taskDownloaded(double _taskEndTime) {
taskEndTime = _taskEndTime; taskEndTime = _taskEndTime;
status = SimLogger.TASK_STATUS.COMLETED; status = SimLogger.TASK_STATUS.COMLETED;
} }
public void taskRejectedDueToVMCapacity(double _taskRejectTime) { public void taskRejectedDueToVMCapacity(double _taskRejectTime) {
taskEndTime = _taskRejectTime; taskEndTime = _taskRejectTime;
status = SimLogger.TASK_STATUS.REJECTED_DUE_TO_VM_CAPACITY; status = SimLogger.TASK_STATUS.REJECTED_DUE_TO_VM_CAPACITY;
} }
public void taskRejectedDueToBandwidth(double _taskRejectTime) {
public void taskRejectedDueToBandwidth(double _taskRejectTime, int _vmType) {
vmType = _vmType;
taskEndTime = _taskRejectTime; taskEndTime = _taskRejectTime;
status = SimLogger.TASK_STATUS.REJECTED_DUE_TO_BANDWIDTH; status = SimLogger.TASK_STATUS.REJECTED_DUE_TO_BANDWIDTH;
} }
public void taskFailedDueToBandwidth(double _time) { public void taskFailedDueToBandwidth(double _time) {
taskEndTime = _time; taskEndTime = _time;
status = SimLogger.TASK_STATUS.UNFINISHED_DUE_TO_BANDWIDTH; status = SimLogger.TASK_STATUS.UNFINISHED_DUE_TO_BANDWIDTH;
} }
public void taskFailedDueToMobility(double _time) { public void taskFailedDueToMobility(double _time) {
taskEndTime = _time; taskEndTime = _time;
status = SimLogger.TASK_STATUS.UNFINISHED_DUE_TO_MOBILITY; status = SimLogger.TASK_STATUS.UNFINISHED_DUE_TO_MOBILITY;
} }
public void setCost(double _bwCost, double _cpuCos) { public void setCost(double _bwCost, double _cpuCos) {
bwCost = _bwCost; bwCost = _bwCost;
cpuCost = _cpuCos; cpuCost = _cpuCos;
} }
public boolean isInWarmUpPeriod() { public boolean isInWarmUpPeriod() {
return isInWarmUpPeriod; return isInWarmUpPeriod;
} }
public double getCost() { public double getCost() {
return bwCost + cpuCost; return bwCost + cpuCost;
} }
public double getNetworkDelay() { public double getNetworkDelay() {
return networkDelay; return networkDelay;
} }
public double getServiceTime() { public double getServiceTime() {
return taskEndTime - taskStartTime; return taskEndTime - taskStartTime;
} }
public SimLogger.TASK_STATUS getStatus() { public SimLogger.TASK_STATUS getStatus() {
return status; return status;
} }
public int getVmType() { public int getVmType() {
return vmType; return vmType;
} }
public String toString (int taskId)
{ public int getTaskType() {
String result = taskId + SimSettings.DELIMITER + return taskType;
datacenterId + SimSettings.DELIMITER + }
hostId + SimSettings.DELIMITER +
vmId + SimSettings.DELIMITER + public String toString(int taskId) {
vmType + SimSettings.DELIMITER + String result = taskId + SimSettings.DELIMITER + datacenterId + SimSettings.DELIMITER + hostId
taskType + SimSettings.DELIMITER + + SimSettings.DELIMITER + vmId + SimSettings.DELIMITER + vmType + SimSettings.DELIMITER + taskType
taskLenght + SimSettings.DELIMITER + + SimSettings.DELIMITER + taskLenght + SimSettings.DELIMITER + taskInputType + SimSettings.DELIMITER
taskInputType + SimSettings.DELIMITER + + taskOutputSize + SimSettings.DELIMITER + taskStartTime + SimSettings.DELIMITER + taskEndTime
taskOutputSize + SimSettings.DELIMITER + + SimSettings.DELIMITER;
taskStartTime + SimSettings.DELIMITER +
taskEndTime + SimSettings.DELIMITER;
if (status == SimLogger.TASK_STATUS.COMLETED) if (status == SimLogger.TASK_STATUS.COMLETED)
result += networkDelay; result += networkDelay;