From 81fed10dd03910bcbc3d1e0a8f10bdce5a098ed6 Mon Sep 17 00:00:00 2001 From: Cagatay Sonmez Date: Sat, 25 Feb 2017 15:10:13 +0300 Subject: [PATCH] modification on reading settings from config file 1- simulation scenarios are defined in config file instead of static enumarations 2- defining multiple edge orchestrator policy in config file support is added --- config/default_config.properties | 6 +- .../boun/edgecloudsim/core/SimManager.java | 2 +- .../boun/edgecloudsim/core/SimSettings.java | 24 +++++-- .../BasicEdgeOrchestrator.java | 6 +- .../edge_orchestrator/EdgeOrchestrator.java | 5 +- .../SampleScenarioFactory.java | 6 +- .../sample_application/mainApp.java | 72 ++++++++++--------- .../IdleActiveLoadGenerator.java | 4 +- .../task_generator/LoadGeneratorModel.java | 5 +- 9 files changed, 72 insertions(+), 58 deletions(-) diff --git a/config/default_config.properties b/config/default_config.properties index 5ddd672..893e763 100644 --- a/config/default_config.properties +++ b/config/default_config.properties @@ -17,7 +17,11 @@ gsm_bandwidth=10 mips_for_cloud=20000 -task_provisioning=NEXT_FIT +#use ',' for multiple values +orchestrator_policies=NEXT_FIT + +#use ',' for multiple values +simulation_scenarios=SINGLE_TIER,TWO_TIER,TWO_TIER_WITH_EO attractiveness_L1_mean_waiting_time=60 attractiveness_L2_mean_waiting_time=30 diff --git a/src/edu/boun/edgecloudsim/core/SimManager.java b/src/edu/boun/edgecloudsim/core/SimManager.java index bc7cdd3..c8d40e1 100644 --- a/src/edu/boun/edgecloudsim/core/SimManager.java +++ b/src/edu/boun/edgecloudsim/core/SimManager.java @@ -47,7 +47,7 @@ public class SimManager extends SimEntity { private static SimManager instance = null; - public SimManager(ScenarioFactory _scenarioFactory, int _numOfMobileDevice, SimSettings.SCENARIO_TYPES _simScenario) throws Exception { + public SimManager(ScenarioFactory _scenarioFactory, int _numOfMobileDevice, String _simScenario) throws Exception { super("SimManager"); scenarioFactory = _scenarioFactory; numOfMobileDevice = _numOfMobileDevice; diff --git a/src/edu/boun/edgecloudsim/core/SimSettings.java b/src/edu/boun/edgecloudsim/core/SimSettings.java index 5acfb2d..eea8e3b 100644 --- a/src/edu/boun/edgecloudsim/core/SimSettings.java +++ b/src/edu/boun/edgecloudsim/core/SimSettings.java @@ -33,13 +33,12 @@ public class SimSettings { private static SimSettings instance = null; private Document edgeDevicesDoc = null; - //enumarations for the scenarion, VM, appplication, and place. + //enumarations for the VM, appplication, and place. //if you want to add different types on your config file, //you may modify current types or add new types here. 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 PLACE_TYPES { ATTRACTIVENESS_L1, ATTRACTIVENESS_L2, ATTRACTIVENESS_L3 } - public static enum SCENARIO_TYPES { SINGLE_TIER, TWO_TIER, TWO_TIER_WITH_EO } //predifined ID for cloud components. public static int CLOUD_DATACENTER_ID = 1000; @@ -71,7 +70,8 @@ public class SimSettings { private int MIPS_FOR_CLOUD; //MIPS - private String ORCHESTRATOR_POLICY; + private String[] SIMULATION_SCENARIOS; + private String[] ORCHESTRATOR_POLICIES; // mean waiting time (minute) is stored for each place types private double[] mobilityLookUpTable; @@ -135,7 +135,9 @@ public class SimSettings { //-Each task is executed with maximum capacity (as if there is no task in the cloud) MIPS_FOR_CLOUD = Integer.parseInt(prop.getProperty("mips_for_cloud")); - ORCHESTRATOR_POLICY = prop.getProperty("task_provisioning"); + ORCHESTRATOR_POLICIES = prop.getProperty("orchestrator_policies").split(","); + + SIMULATION_SCENARIOS = prop.getProperty("simulation_scenarios").split(","); //avg waiting time in a place (min) double place1_mean_waiting_time = Double.parseDouble(prop.getProperty("attractiveness_L1_mean_waiting_time")); @@ -314,11 +316,19 @@ public class SimSettings { } /** - * returns orchestrator policy as string + * returns simulation screnarios as string */ - public String getOrchestratorPolicy() + public String[] getSimulationScenarios() { - return ORCHESTRATOR_POLICY; + return SIMULATION_SCENARIOS; + } + + /** + * returns orchestrator policies as string + */ + public String[] getOrchestratorPolicies() + { + return ORCHESTRATOR_POLICIES; } /** diff --git a/src/edu/boun/edgecloudsim/edge_orchestrator/BasicEdgeOrchestrator.java b/src/edu/boun/edgecloudsim/edge_orchestrator/BasicEdgeOrchestrator.java index 88f6dc9..d315175 100644 --- a/src/edu/boun/edgecloudsim/edge_orchestrator/BasicEdgeOrchestrator.java +++ b/src/edu/boun/edgecloudsim/edge_orchestrator/BasicEdgeOrchestrator.java @@ -18,7 +18,6 @@ import org.cloudbus.cloudsim.core.CloudSim; import edu.boun.edgecloudsim.core.SimManager; import edu.boun.edgecloudsim.core.SimSettings; -import edu.boun.edgecloudsim.core.SimSettings.SCENARIO_TYPES; import edu.boun.edgecloudsim.edge_server.EdgeVM; import edu.boun.edgecloudsim.edge_client.CpuUtilizationModel_Custom; import edu.boun.edgecloudsim.edge_client.Task; @@ -30,8 +29,7 @@ public class BasicEdgeOrchestrator extends EdgeOrchestrator { private int lastSelectedHostIndex; //used by load balancer private int[] lastSelectedVmIndexes; //used by each host individually - public BasicEdgeOrchestrator(String _policy, - SCENARIO_TYPES _simScenario) { + public BasicEdgeOrchestrator(String _policy, String _simScenario) { super(_policy, _simScenario); } @@ -47,7 +45,7 @@ public class BasicEdgeOrchestrator extends EdgeOrchestrator { @Override public EdgeVM selectVm(Task task) { - if(simScenario == SimSettings.SCENARIO_TYPES.TWO_TIER_WITH_EO) + if(simScenario.equals("TWO_TIER_WITH_EO")) return selectVmOnLoadBalancer(task); else return selectVmOnHost(task); diff --git a/src/edu/boun/edgecloudsim/edge_orchestrator/EdgeOrchestrator.java b/src/edu/boun/edgecloudsim/edge_orchestrator/EdgeOrchestrator.java index 927cead..d08de88 100644 --- a/src/edu/boun/edgecloudsim/edge_orchestrator/EdgeOrchestrator.java +++ b/src/edu/boun/edgecloudsim/edge_orchestrator/EdgeOrchestrator.java @@ -13,15 +13,14 @@ package edu.boun.edgecloudsim.edge_orchestrator; -import edu.boun.edgecloudsim.core.SimSettings; import edu.boun.edgecloudsim.edge_server.EdgeVM; import edu.boun.edgecloudsim.edge_client.Task; public abstract class EdgeOrchestrator { protected String policy; - protected SimSettings.SCENARIO_TYPES simScenario; + protected String simScenario; - public EdgeOrchestrator(String _policy, SimSettings.SCENARIO_TYPES _simScenario){ + public EdgeOrchestrator(String _policy, String _simScenario){ policy = _policy; simScenario = _simScenario; } diff --git a/src/edu/boun/edgecloudsim/sample_application/SampleScenarioFactory.java b/src/edu/boun/edgecloudsim/sample_application/SampleScenarioFactory.java index 292901d..d2dac07 100644 --- a/src/edu/boun/edgecloudsim/sample_application/SampleScenarioFactory.java +++ b/src/edu/boun/edgecloudsim/sample_application/SampleScenarioFactory.java @@ -17,7 +17,6 @@ import org.cloudbus.cloudsim.UtilizationModel; import org.cloudbus.cloudsim.VmAllocationPolicy; import edu.boun.edgecloudsim.core.ScenarioFactory; -import edu.boun.edgecloudsim.core.SimSettings; import edu.boun.edgecloudsim.core.SimSettings.APP_TYPES; import edu.boun.edgecloudsim.edge_orchestrator.BasicEdgeOrchestrator; import edu.boun.edgecloudsim.edge_orchestrator.EdgeOrchestrator; @@ -34,12 +33,12 @@ public class SampleScenarioFactory implements ScenarioFactory { private int numOfMobileDevice; private double simulationTime; private String orchestratorPolicy; - private SimSettings.SCENARIO_TYPES simScenario; + private String simScenario; SampleScenarioFactory(int _numOfMobileDevice, double _simulationTime, String _orchestratorPolicy, - SimSettings.SCENARIO_TYPES _simScenario){ + String _simScenario){ orchestratorPolicy = _orchestratorPolicy; numOfMobileDevice = _numOfMobileDevice; simulationTime = _simulationTime; @@ -75,5 +74,4 @@ public class SampleScenarioFactory implements ScenarioFactory { public UtilizationModel getCpuUtilizationModel(APP_TYPES _taskType) { return new CpuUtilizationModel_Custom(_taskType); } - } diff --git a/src/edu/boun/edgecloudsim/sample_application/mainApp.java b/src/edu/boun/edgecloudsim/sample_application/mainApp.java index 41adbd1..c83d84a 100644 --- a/src/edu/boun/edgecloudsim/sample_application/mainApp.java +++ b/src/edu/boun/edgecloudsim/sample_application/mainApp.java @@ -75,44 +75,50 @@ public class mainApp { for(int j=SS.getMinNumOfMobileDev(); j<=SS.getMaxNumOfMobileDev(); j+=SS.getMobileDevCounterSize()) { - for (SimSettings.SCENARIO_TYPES scenario : SimSettings.SCENARIO_TYPES.values()) + for(int k=0; k taskList; protected int numberOfMobileDevices; protected double simulationTime; - protected SimSettings.SCENARIO_TYPES simScenario; + protected String simScenario; - public LoadGeneratorModel(int _numberOfMobileDevices, double _simulationTime, SimSettings.SCENARIO_TYPES _simScenario){ + public LoadGeneratorModel(int _numberOfMobileDevices, double _simulationTime, String _simScenario){ numberOfMobileDevices=_numberOfMobileDevices; simulationTime=_simulationTime; simScenario=_simScenario;