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
This commit is contained in:
Cagatay Sonmez 2017-02-25 15:10:13 +03:00
parent 19c4b9de40
commit 81fed10dd0
9 changed files with 72 additions and 58 deletions

View File

@ -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

View File

@ -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;

View File

@ -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;
}
/**

View File

@ -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);

View File

@ -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;
}

View File

@ -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);
}
}

View File

@ -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<SS.getSimulationScenarios().length; k++)
{
Date ScenarioStartDate = Calendar.getInstance().getTime();
now = df.format(ScenarioStartDate);
SimLogger.printLine("Scenario started at " + now);
SimLogger.printLine(scenario + "(" + SS.getOrchestratorPolicy() + ")" + " - duration: " + SS.getSimulationTime()/3600 + " hour(s) - poisson: " + SS.getTaskLookUpTable()[0][2] + " - #devices: " + j + " - ite: " + iterationNumber);
SimLogger.getInstance().simStarted(outputFolder,"SIMRESULT_" + scenario + "_" + j + "DEVICES");
try
for(int i=0; i<SS.getOrchestratorPolicies().length; i++)
{
// First step: Initialize the CloudSim package. It should be called
// before creating any entities.
int num_user = 2; // number of grid users
Calendar calendar = Calendar.getInstance();
boolean trace_flag = false; // mean trace events
// Initialize the CloudSim library
CloudSim.init(num_user, calendar, trace_flag, 0.01);
String simScenario = SS.getSimulationScenarios()[k];
String orchestratorPolicy = SS.getOrchestratorPolicies()[i];
Date ScenarioStartDate = Calendar.getInstance().getTime();
now = df.format(ScenarioStartDate);
ScenarioFactory sampleFactory = new SampleScenarioFactory(j,SS.getSimulationTime(), SS.getOrchestratorPolicy(), scenario);
SimLogger.printLine("Scenario started at " + now);
SimLogger.printLine("Scenario: " + simScenario + " - Policy: " + orchestratorPolicy + " - #iteration: " + iterationNumber);
SimLogger.printLine("Duration: " + SS.getSimulationTime()/3600 + " hour(s) - Poisson: " + SS.getTaskLookUpTable()[0][2] + " - #devices: " + j);
SimLogger.getInstance().simStarted(outputFolder,"SIMRESULT_" + simScenario + "_" + orchestratorPolicy + "_" + j + "DEVICES");
SimManager manager = new SimManager(sampleFactory, j, scenario);
manager.startSimulation();
}
catch (Exception e)
{
SimLogger.printLine("The simulation has been terminated due to an unexpected error");
e.printStackTrace();
System.exit(0);
}
try
{
// First step: Initialize the CloudSim package. It should be called
// before creating any entities.
int num_user = 2; // number of grid users
Calendar calendar = Calendar.getInstance();
boolean trace_flag = false; // mean trace events
Date ScenarioEndDate = Calendar.getInstance().getTime();
now = df.format(ScenarioEndDate);
SimLogger.printLine("Scenario finished at " + now + ". It took " + SimUtils.getTimeDifference(ScenarioStartDate,ScenarioEndDate));
SimLogger.printLine("----------------------------------------------------------------------");
}//End of SCENARIO_TYPES loop
}//End of NUMBER_OF_MOBILE_DEVICE loop
// Initialize the CloudSim library
CloudSim.init(num_user, calendar, trace_flag, 0.01);
ScenarioFactory sampleFactory = new SampleScenarioFactory(j,SS.getSimulationTime(), orchestratorPolicy, simScenario);
SimManager manager = new SimManager(sampleFactory, j, simScenario);
manager.startSimulation();
}
catch (Exception e)
{
SimLogger.printLine("The simulation has been terminated due to an unexpected error");
e.printStackTrace();
System.exit(0);
}
Date ScenarioEndDate = Calendar.getInstance().getTime();
now = df.format(ScenarioEndDate);
SimLogger.printLine("Scenario finished at " + now + ". It took " + SimUtils.getTimeDifference(ScenarioStartDate,ScenarioEndDate));
SimLogger.printLine("----------------------------------------------------------------------");
}//End of orchestrators loop
}//End of scenarios loop
}//End of mobile devices loop
Date SimulationEndDate = Calendar.getInstance().getTime();
now = df.format(SimulationEndDate);

View File

@ -26,7 +26,7 @@ import edu.boun.edgecloudsim.utils.SimUtils;
public class IdleActiveLoadGenerator extends LoadGeneratorModel{
public IdleActiveLoadGenerator(int _numberOfMobileDevices, double _simulationTime, SimSettings.SCENARIO_TYPES _simScenario) {
public IdleActiveLoadGenerator(int _numberOfMobileDevices, double _simulationTime, String _simScenario) {
super(_numberOfMobileDevices, _simulationTime, _simScenario);
}
@ -88,7 +88,7 @@ public class IdleActiveLoadGenerator extends LoadGeneratorModel{
}
boolean requireCloud = false;
if(simScenario != SimSettings.SCENARIO_TYPES.SINGLE_TIER){
if(!simScenario.equals("SINGLE_TIER")){
//decide to use cloud or cloudlet VM
int CloudVmPicker = SimUtils.getRandomNumber(0, 100);

View File

@ -15,16 +15,15 @@ package edu.boun.edgecloudsim.task_generator;
import java.util.List;
import edu.boun.edgecloudsim.core.SimSettings;
import edu.boun.edgecloudsim.utils.EdgeTask;
public abstract class LoadGeneratorModel {
protected List<EdgeTask> 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;