From 22b654d7194f39068c438cea679508ca315d8937 Mon Sep 17 00:00:00 2001 From: Cagatay Sonmez Date: Sun, 26 Feb 2017 14:07:47 +0300 Subject: [PATCH] task flow and network from mobile device to edge orchestrator is modified 1- finding which device to offlod is decided in edge orchestrator (EdgeOrchestrator), instead of deciding while generating task (LoadGeneratorModel) 2- file logging option is now read from config file 3- minor modification on the network delay calculation --- config/default_config.properties | 1 + .../boun/edgecloudsim/core/SimSettings.java | 18 +++- .../edge_client/MobileDeviceManager.java | 99 +++++++++++++------ .../BasicEdgeOrchestrator.java | 18 +++- .../edge_orchestrator/EdgeOrchestrator.java | 7 +- .../boun/edgecloudsim/network/MM1Queue.java | 22 +++-- .../sample_application/mainApp.java | 5 +- .../IdleActiveLoadGenerator.java | 11 +-- src/edu/boun/edgecloudsim/utils/EdgeTask.java | 4 +- 9 files changed, 128 insertions(+), 57 deletions(-) diff --git a/config/default_config.properties b/config/default_config.properties index 893e763..541b1d7 100644 --- a/config/default_config.properties +++ b/config/default_config.properties @@ -3,6 +3,7 @@ simulation_time=2 warm_up_period=1200 vm_load_check_interval=30 vm_location_check_interval=30 +basic_file_log_enabled=false deep_file_log_enabled=false min_number_of_mobile_devices=50 diff --git a/src/edu/boun/edgecloudsim/core/SimSettings.java b/src/edu/boun/edgecloudsim/core/SimSettings.java index eea8e3b..3867859 100644 --- a/src/edu/boun/edgecloudsim/core/SimSettings.java +++ b/src/edu/boun/edgecloudsim/core/SimSettings.java @@ -40,10 +40,14 @@ public class SimSettings { public static enum APP_TYPES { FACE_REC_APP, HEALTH_APP, HEAVY_COMP_APP, VIDEO_GAME_APP, SIMPLE_SERVICE_APP } public static enum PLACE_TYPES { ATTRACTIVENESS_L1, ATTRACTIVENESS_L2, ATTRACTIVENESS_L3 } - //predifined ID for cloud components. + //predifined IDs for cloud components. public static int CLOUD_DATACENTER_ID = 1000; public static int CLOUD_HOST_ID = CLOUD_DATACENTER_ID + 1; public static int CLOUD_VM_ID = CLOUD_DATACENTER_ID + 2; + + //predifined IDs for edge devices + public static int EDGE_ORCHESTRATOR_ID = 2000; + public static int GENERIC_EDGE_DEVICE_ID = EDGE_ORCHESTRATOR_ID + 1; //delimiter for output file. public static String DELIMITER = ";"; @@ -52,7 +56,8 @@ public class SimSettings { private double WARM_UP_PERIOD; //seconds unit in properties file private double INTERVAL_TO_GET_VM_LOAD_LOG; //seconds unit in properties file private double INTERVAL_TO_GET_VM_LOCATION_LOG; //seconds unit in properties file - private boolean DEEP_FILE_LOG_ENABLED; //used for each success failed task + 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 int MIN_NUM_OF_MOBILE_DEVICES; private int MAX_NUM_OF_MOBILE_DEVICES; @@ -118,6 +123,7 @@ public class SimSettings { WARM_UP_PERIOD = 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_LOCATION_LOG = Double.parseDouble(prop.getProperty("vm_location_check_interval")); //seconds + FILE_LOG_ENABLED = Boolean.parseBoolean(prop.getProperty("file_log_enabled")); DEEP_FILE_LOG_ENABLED = Boolean.parseBoolean(prop.getProperty("deep_file_log_enabled")); MIN_NUM_OF_MOBILE_DEVICES = Integer.parseInt(prop.getProperty("min_number_of_mobile_devices")); @@ -218,6 +224,14 @@ public class SimSettings { return DEEP_FILE_LOG_ENABLED; } + /** + * returns deep statistics logging status from properties file + */ + public boolean getFileLoggingEnabled() + { + return FILE_LOG_ENABLED; + } + /** * returns WAN propogation delay (in second unit) from properties file */ diff --git a/src/edu/boun/edgecloudsim/edge_client/MobileDeviceManager.java b/src/edu/boun/edgecloudsim/edge_client/MobileDeviceManager.java index a4fc27f..e2e5b50 100644 --- a/src/edu/boun/edgecloudsim/edge_client/MobileDeviceManager.java +++ b/src/edu/boun/edgecloudsim/edge_client/MobileDeviceManager.java @@ -38,6 +38,7 @@ public class MobileDeviceManager extends DatacenterBroker { 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 RESPONSE_RECEIVED_BY_MOBILE_DEVICE = BASE + 4; + private static final int REQUEST_RECIVED_BY_EDGE_ORCHESTRATOR = BASE + 5; private int taskIdCounter=0; public MobileDeviceManager() throws Exception { @@ -149,37 +150,21 @@ public class MobileDeviceManager extends DatacenterBroker { break; } + case REQUEST_RECIVED_BY_EDGE_ORCHESTRATOR: + { + Task task = (Task) ev.getData(); + double internalDelay = networkModel.getDownloadDelay( + SimSettings.EDGE_ORCHESTRATOR_ID, + SimSettings.GENERIC_EDGE_DEVICE_ID); + + submitTaskToEdgeDevice(task,internalDelay); + + break; + } case REQUEST_RECIVED_BY_EDGE_DEVICE: { Task task = (Task) ev.getData(); - - Location currentLocation = SimManager.getInstance().getMobilityModel().getLocation(task.getMobileDeviceId(),CloudSim.clock()); - - //select a VM - EdgeVM selectedVM = SimManager.getInstance().getEdgeOrchestrator().selectVm(task); - - if(selectedVM != null){ - //save task info - task.setSubmittedLocation(currentLocation); - task.setAssociatedHostId(selectedVM.getHost().getId()); - - //bind task to related VM - getCloudletList().add(task); - bindCloudletToVm(task.getCloudletId(),selectedVM.getId()); - - //SimLogger.printLine(CloudSim.clock() + ": Cloudlet#" + task.getCloudletId() + " is submitted to VM#" + task.getVmId()); - sendNow(getVmsToDatacentersMap().get(task.getVmId()), CloudSimTags.CLOUDLET_SUBMIT, task); - - SimLogger.getInstance().uploaded(task.getCloudletId(), - selectedVM.getHost().getDatacenter().getId(), - selectedVM.getHost().getId(), - selectedVM.getId(), - selectedVM.getVmType().ordinal()); - } - else{ - //SimLogger.printLine("Task #" + task.getCloudletId() + " cannot assign to any VM"); - SimLogger.getInstance().rejectedDueToVMCapacity(task.getCloudletId(), CloudSim.clock()); - } + submitTaskToEdgeDevice(task,0); break; } @@ -197,6 +182,37 @@ public class MobileDeviceManager extends DatacenterBroker { } } + public void submitTaskToEdgeDevice(Task task, double delay) { + //select a VM + EdgeVM selectedVM = SimManager.getInstance().getEdgeOrchestrator().getVmToOffload(task); + + if(selectedVM != null){ + Location currentLocation = SimManager.getInstance().getMobilityModel(). + getLocation(task.getMobileDeviceId(),CloudSim.clock()); + + //save task info + task.setSubmittedLocation(currentLocation); + task.setAssociatedHostId(selectedVM.getHost().getId()); + + //bind task to related VM + getCloudletList().add(task); + bindCloudletToVm(task.getCloudletId(),selectedVM.getId()); + + //SimLogger.printLine(CloudSim.clock() + ": Cloudlet#" + task.getCloudletId() + " is submitted to VM#" + task.getVmId()); + schedule(getVmsToDatacentersMap().get(task.getVmId()), delay, CloudSimTags.CLOUDLET_SUBMIT, task); + + SimLogger.getInstance().uploaded(task.getCloudletId(), + selectedVM.getHost().getDatacenter().getId(), + selectedVM.getHost().getId(), + selectedVM.getId(), + selectedVM.getVmType().ordinal()); + } + else{ + //SimLogger.printLine("Task #" + task.getCloudletId() + " cannot assign to any VM"); + SimLogger.getInstance().rejectedDueToVMCapacity(task.getCloudletId(), CloudSim.clock()); + } + } + public void submitTask(EdgeTask edgeTask) { NetworkModel networkModel = SimManager.getInstance().getNetworkModel(); @@ -210,9 +226,12 @@ public class MobileDeviceManager extends DatacenterBroker { (int)task.getCloudletLength(), (int)task.getCloudletFileSize(), (int)task.getCloudletOutputSize()); + + int nextHopId = SimManager.getInstance().getEdgeOrchestrator().getDeviceToOffload(task); - if(edgeTask.requireCloud){ - double WanDelay = networkModel.getUploadDelay(task.getMobileDeviceId(),SimSettings.CLOUD_DATACENTER_ID); + if(nextHopId == SimSettings.CLOUD_DATACENTER_ID){ + double WanDelay = networkModel.getUploadDelay(task.getMobileDeviceId(), nextHopId); + if(WanDelay>0){ schedule(getId(), WanDelay, REQUEST_RECEIVED_BY_CLOUD, task); SimLogger.getInstance().uploadStarted(task.getCloudletId(),WanDelay); @@ -223,8 +242,20 @@ public class MobileDeviceManager extends DatacenterBroker { SimLogger.getInstance().rejectedDueToBandwidth(task.getCloudletId(), CloudSim.clock()); } } - else { - double WlanDelay = networkModel.getUploadDelay(task.getMobileDeviceId(),0); + else if(nextHopId == SimSettings.EDGE_ORCHESTRATOR_ID){ + 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.GENERIC_EDGE_DEVICE_ID) { + double WlanDelay = networkModel.getUploadDelay(task.getMobileDeviceId(), nextHopId); + if(WlanDelay > 0){ schedule(getId(), WlanDelay, REQUEST_RECIVED_BY_EDGE_DEVICE, task); SimLogger.getInstance().uploadStarted(task.getCloudletId(),WlanDelay); @@ -233,6 +264,10 @@ public class MobileDeviceManager extends DatacenterBroker { SimLogger.getInstance().rejectedDueToBandwidth(task.getCloudletId(), CloudSim.clock()); } } + else { + SimLogger.printLine("Unknown nextHopId! Terminating simulation..."); + System.exit(0); + } } public Task createTask(EdgeTask edgeTask){ diff --git a/src/edu/boun/edgecloudsim/edge_orchestrator/BasicEdgeOrchestrator.java b/src/edu/boun/edgecloudsim/edge_orchestrator/BasicEdgeOrchestrator.java index d315175..9e8ba36 100644 --- a/src/edu/boun/edgecloudsim/edge_orchestrator/BasicEdgeOrchestrator.java +++ b/src/edu/boun/edgecloudsim/edge_orchestrator/BasicEdgeOrchestrator.java @@ -44,7 +44,23 @@ public class BasicEdgeOrchestrator extends EdgeOrchestrator { } @Override - public EdgeVM selectVm(Task task) { + public int getDeviceToOffload(Task task) { + int result = SimSettings.GENERIC_EDGE_DEVICE_ID; + if(!simScenario.equals("SINGLE_TIER")){ + //decide to use cloud or cloudlet VM + int CloudVmPicker = SimUtils.getRandomNumber(0, 100); + + if(CloudVmPicker <= SimSettings.getInstance().getTaskLookUpTable()[task.getTaskType().ordinal()][1]) + result = SimSettings.CLOUD_DATACENTER_ID; + else + result = SimSettings.EDGE_ORCHESTRATOR_ID; + } + + return result; + } + + @Override + public EdgeVM getVmToOffload(Task task) { if(simScenario.equals("TWO_TIER_WITH_EO")) return selectVmOnLoadBalancer(task); else diff --git a/src/edu/boun/edgecloudsim/edge_orchestrator/EdgeOrchestrator.java b/src/edu/boun/edgecloudsim/edge_orchestrator/EdgeOrchestrator.java index d08de88..1fd1cf9 100644 --- a/src/edu/boun/edgecloudsim/edge_orchestrator/EdgeOrchestrator.java +++ b/src/edu/boun/edgecloudsim/edge_orchestrator/EdgeOrchestrator.java @@ -30,8 +30,13 @@ public abstract class EdgeOrchestrator { */ public abstract void initialize(); + /* + * decides where to offload + */ + public abstract int getDeviceToOffload(Task task); + /* * returns proper VM from the related edge orchestrator point of view */ - public abstract EdgeVM selectVm(Task task); + public abstract EdgeVM getVmToOffload(Task task); } diff --git a/src/edu/boun/edgecloudsim/network/MM1Queue.java b/src/edu/boun/edgecloudsim/network/MM1Queue.java index 1a88b93..55d9eaf 100644 --- a/src/edu/boun/edgecloudsim/network/MM1Queue.java +++ b/src/edu/boun/edgecloudsim/network/MM1Queue.java @@ -69,18 +69,21 @@ public class MM1Queue extends NetworkModel { double delay = 0; Location accessPointLocation = SimManager.getInstance().getMobilityModel().getLocation(sourceDeviceId,CloudSim.clock()); - //if destination device is the cloud datacenter, both wan and wlan delay should be considered + //mobile device to cloud server if(destDeviceId == SimSettings.CLOUD_DATACENTER_ID){ double wlanDelay = getWlanUploadDelay(accessPointLocation, CloudSim.clock()); double wanDelay = getWanUploadDelay(accessPointLocation, CloudSim.clock() + wlanDelay); if(wlanDelay > 0 && wanDelay >0) delay = wlanDelay + wanDelay; } - else{ + //mobile device to edge orchestrator + else if(destDeviceId == SimSettings.EDGE_ORCHESTRATOR_ID){ + delay = getWlanUploadDelay(accessPointLocation, CloudSim.clock()) + + SimSettings.getInstance().getInternalLanDelay(); + } + //mobile device to edge device (wifi access point) + else if (destDeviceId == SimSettings.GENERIC_EDGE_DEVICE_ID) { delay = getWlanUploadDelay(accessPointLocation, CloudSim.clock()); - - //all requests are send to edge orchestrator first than redirected related VM - delay += (SimSettings.getInstance().getInternalLanDelay() * 2); } return delay; @@ -91,16 +94,23 @@ public class MM1Queue extends NetworkModel { */ @Override public double getDownloadDelay(int sourceDeviceId, int destDeviceId) { + //Special Case -> edge orchestrator to edge device + if(sourceDeviceId == SimSettings.EDGE_ORCHESTRATOR_ID && + destDeviceId == SimSettings.GENERIC_EDGE_DEVICE_ID){ + return SimSettings.getInstance().getInternalLanDelay(); + } + double delay = 0; Location accessPointLocation = SimManager.getInstance().getMobilityModel().getLocation(destDeviceId,CloudSim.clock()); - //if source device is the cloud datacenter, both wan and wlan delay should be considered + //cloud server to mobile device if(sourceDeviceId == SimSettings.CLOUD_DATACENTER_ID){ double wlanDelay = getWlanDownloadDelay(accessPointLocation, CloudSim.clock()); double wanDelay = getWanDownloadDelay(accessPointLocation, CloudSim.clock() + wlanDelay); if(wlanDelay > 0 && wanDelay >0) delay = wlanDelay + wanDelay; } + //edge device (wifi access point) to mobile device else{ delay = getWlanDownloadDelay(accessPointLocation, CloudSim.clock()); diff --git a/src/edu/boun/edgecloudsim/sample_application/mainApp.java b/src/edu/boun/edgecloudsim/sample_application/mainApp.java index c83d84a..70768f0 100644 --- a/src/edu/boun/edgecloudsim/sample_application/mainApp.java +++ b/src/edu/boun/edgecloudsim/sample_application/mainApp.java @@ -34,7 +34,6 @@ public class mainApp { //enable console ourput and file output of this application SimLogger.enablePrintLog(); - SimLogger.enableFileLog(); int iterationNumber = 1; String configFile = ""; @@ -64,8 +63,10 @@ public class mainApp { System.exit(0); } - if(SimLogger.isFileLogEnabled()) + if(SS.getFileLoggingEnabled()){ + SimLogger.enableFileLog(); SimUtils.cleanOutputFolder(outputFolder); + } DateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss"); Date SimulationStartDate = Calendar.getInstance().getTime(); diff --git a/src/edu/boun/edgecloudsim/task_generator/IdleActiveLoadGenerator.java b/src/edu/boun/edgecloudsim/task_generator/IdleActiveLoadGenerator.java index 373a1d0..4deab85 100644 --- a/src/edu/boun/edgecloudsim/task_generator/IdleActiveLoadGenerator.java +++ b/src/edu/boun/edgecloudsim/task_generator/IdleActiveLoadGenerator.java @@ -86,17 +86,8 @@ public class IdleActiveLoadGenerator extends LoadGeneratorModel{ virtualTime = activePeriodStartTime; continue; } - - boolean requireCloud = false; - if(!simScenario.equals("SINGLE_TIER")){ - //decide to use cloud or cloudlet VM - int CloudVmPicker = SimUtils.getRandomNumber(0, 100); - - if(CloudVmPicker <= SimSettings.getInstance().getTaskLookUpTable()[randomTaskType.ordinal()][1]) - requireCloud = true; - } - taskList.add(new EdgeTask(i,randomTaskType, virtualTime, requireCloud, poissonRngList)); + taskList.add(new EdgeTask(i,randomTaskType, virtualTime, poissonRngList)); } } } diff --git a/src/edu/boun/edgecloudsim/utils/EdgeTask.java b/src/edu/boun/edgecloudsim/utils/EdgeTask.java index dc844b3..94a2030 100644 --- a/src/edu/boun/edgecloudsim/utils/EdgeTask.java +++ b/src/edu/boun/edgecloudsim/utils/EdgeTask.java @@ -15,15 +15,13 @@ import edu.boun.edgecloudsim.core.SimSettings.APP_TYPES; public class EdgeTask { public APP_TYPES taskType; - public boolean requireCloud; public double startTime; public long length, inputFileSize, outputFileSize; public int pesNumber; public int mobileDeviceId; - public EdgeTask(int _mobileDeviceId, APP_TYPES _taskType, double _startTime, boolean _requireCloud, PoissonDistr[][] poissonRngList) { + public EdgeTask(int _mobileDeviceId, APP_TYPES _taskType, double _startTime, PoissonDistr[][] poissonRngList) { mobileDeviceId=_mobileDeviceId; - requireCloud=_requireCloud; startTime=_startTime; taskType=_taskType;