major modifications for v2.0 release
Release notes 1- Cloud server processing was simplified in the initial version, it is handled via cloudsim components now. 2- Cloud server manager, edge server manager, mobile device manager and vm allocation policy are used as abstract class in factory pattern to allow developers to use different business logic without modifying EdgeCloudSim source code. 3- The task and place types are no longer defined as enumeration. They are used as integer value in order to manipulate more place type without modifying enum variable. 4- Two sample applications (one of them is simple and the other one extended application) are added along with the corresponding matlab files to plot statistics. 5- Cloud server properties are added to the simulation settings file 6- New log items are added to simulation result files 7- Code refactoring is applied including the modification of comments
This commit is contained in:
131
src/edu/boun/edgecloudsim/applications/sample_app1/MainApp.java
Normal file
131
src/edu/boun/edgecloudsim/applications/sample_app1/MainApp.java
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Title: EdgeCloudSim - Main Application
|
||||
*
|
||||
* Description: Main application for Simple App
|
||||
*
|
||||
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
|
||||
* Copyright (c) 2017, Bogazici University, Istanbul, Turkey
|
||||
*/
|
||||
|
||||
package edu.boun.edgecloudsim.applications.sample_app1;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
import org.cloudbus.cloudsim.Log;
|
||||
import org.cloudbus.cloudsim.core.CloudSim;
|
||||
|
||||
import edu.boun.edgecloudsim.core.ScenarioFactory;
|
||||
import edu.boun.edgecloudsim.core.SimManager;
|
||||
import edu.boun.edgecloudsim.core.SimSettings;
|
||||
import edu.boun.edgecloudsim.utils.SimLogger;
|
||||
import edu.boun.edgecloudsim.utils.SimUtils;
|
||||
|
||||
public class MainApp {
|
||||
|
||||
/**
|
||||
* Creates main() to run this example
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
//disable console output of cloudsim library
|
||||
Log.disable();
|
||||
|
||||
//enable console ourput and file output of this application
|
||||
SimLogger.enablePrintLog();
|
||||
|
||||
int iterationNumber = 1;
|
||||
String configFile = "";
|
||||
String outputFolder = "";
|
||||
String edgeDevicesFile = "";
|
||||
String applicationsFile = "";
|
||||
if (args.length == 5){
|
||||
configFile = args[0];
|
||||
edgeDevicesFile = args[1];
|
||||
applicationsFile = args[2];
|
||||
outputFolder = args[3];
|
||||
iterationNumber = Integer.parseInt(args[4]);
|
||||
}
|
||||
else{
|
||||
SimLogger.printLine("Simulation setting file, output folder and iteration number are not provided! Using default ones...");
|
||||
configFile = "scripts/sample_app1/config/default_config.properties";
|
||||
applicationsFile = "scripts/sample_app1/config/applications.xml";
|
||||
edgeDevicesFile = "scripts/sample_app1/config/edge_devices.xml";
|
||||
outputFolder = "sim_results/ite" + iterationNumber;
|
||||
}
|
||||
|
||||
//load settings from configuration file
|
||||
SimSettings SS = SimSettings.getInstance();
|
||||
if(SS.initialize(configFile, edgeDevicesFile, applicationsFile) == false){
|
||||
SimLogger.printLine("cannot initialize simulation settings!");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
if(SS.getFileLoggingEnabled()){
|
||||
SimLogger.enableFileLog();
|
||||
SimUtils.cleanOutputFolder(outputFolder);
|
||||
}
|
||||
|
||||
DateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
|
||||
Date SimulationStartDate = Calendar.getInstance().getTime();
|
||||
String now = df.format(SimulationStartDate);
|
||||
SimLogger.printLine("Simulation started at " + now);
|
||||
SimLogger.printLine("----------------------------------------------------------------------");
|
||||
|
||||
for(int j=SS.getMinNumOfMobileDev(); j<=SS.getMaxNumOfMobileDev(); j+=SS.getMobileDevCounterSize())
|
||||
{
|
||||
for(int k=0; k<SS.getSimulationScenarios().length; k++)
|
||||
{
|
||||
for(int i=0; i<SS.getOrchestratorPolicies().length; i++)
|
||||
{
|
||||
String simScenario = SS.getSimulationScenarios()[k];
|
||||
String orchestratorPolicy = SS.getOrchestratorPolicies()[i];
|
||||
Date ScenarioStartDate = Calendar.getInstance().getTime();
|
||||
now = df.format(ScenarioStartDate);
|
||||
|
||||
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");
|
||||
|
||||
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
|
||||
|
||||
// Initialize the CloudSim library
|
||||
CloudSim.init(num_user, calendar, trace_flag, 0.01);
|
||||
|
||||
// Generate EdgeCloudsim Scenario Factory
|
||||
ScenarioFactory sampleFactory = new SampleScenarioFactory(j,SS.getSimulationTime(), orchestratorPolicy, simScenario);
|
||||
|
||||
// Generate EdgeCloudSim Simulation Manager
|
||||
SimManager manager = new SimManager(sampleFactory, j, simScenario, orchestratorPolicy);
|
||||
|
||||
// Start simulation
|
||||
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);
|
||||
SimLogger.printLine("Simulation finished at " + now + ". It took " + SimUtils.getTimeDifference(SimulationStartDate,SimulationEndDate));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Title: EdgeCloudSim - Scenario Factory
|
||||
*
|
||||
* Description: Sample scenario factory providing the default
|
||||
* instances of required abstract classes
|
||||
*
|
||||
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
|
||||
* Copyright (c) 2017, Bogazici University, Istanbul, Turkey
|
||||
*/
|
||||
|
||||
package edu.boun.edgecloudsim.applications.sample_app1;
|
||||
|
||||
import edu.boun.edgecloudsim.cloud_server.CloudServerManager;
|
||||
import edu.boun.edgecloudsim.cloud_server.DefaultCloudServerManager;
|
||||
import edu.boun.edgecloudsim.core.ScenarioFactory;
|
||||
import edu.boun.edgecloudsim.edge_orchestrator.BasicEdgeOrchestrator;
|
||||
import edu.boun.edgecloudsim.edge_orchestrator.EdgeOrchestrator;
|
||||
import edu.boun.edgecloudsim.edge_server.DefaultEdgeServerManager;
|
||||
import edu.boun.edgecloudsim.edge_server.EdgeServerManager;
|
||||
import edu.boun.edgecloudsim.edge_client.DefaultMobileDeviceManager;
|
||||
import edu.boun.edgecloudsim.edge_client.MobileDeviceManager;
|
||||
import edu.boun.edgecloudsim.mobility.MobilityModel;
|
||||
import edu.boun.edgecloudsim.mobility.NomadicMobility;
|
||||
import edu.boun.edgecloudsim.task_generator.IdleActiveLoadGenerator;
|
||||
import edu.boun.edgecloudsim.task_generator.LoadGeneratorModel;
|
||||
import edu.boun.edgecloudsim.network.MM1Queue;
|
||||
import edu.boun.edgecloudsim.network.NetworkModel;
|
||||
|
||||
public class SampleScenarioFactory implements ScenarioFactory {
|
||||
private int numOfMobileDevice;
|
||||
private double simulationTime;
|
||||
private String orchestratorPolicy;
|
||||
private String simScenario;
|
||||
|
||||
SampleScenarioFactory(int _numOfMobileDevice,
|
||||
double _simulationTime,
|
||||
String _orchestratorPolicy,
|
||||
String _simScenario){
|
||||
orchestratorPolicy = _orchestratorPolicy;
|
||||
numOfMobileDevice = _numOfMobileDevice;
|
||||
simulationTime = _simulationTime;
|
||||
simScenario = _simScenario;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoadGeneratorModel getLoadGeneratorModel() {
|
||||
return new IdleActiveLoadGenerator(numOfMobileDevice, simulationTime, simScenario);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EdgeOrchestrator getEdgeOrchestrator() {
|
||||
return new BasicEdgeOrchestrator(orchestratorPolicy, simScenario);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MobilityModel getMobilityModel() {
|
||||
return new NomadicMobility(numOfMobileDevice,simulationTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkModel getNetworkModel() {
|
||||
return new MM1Queue(numOfMobileDevice, simScenario);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EdgeServerManager getEdgeServerManager() {
|
||||
return new DefaultEdgeServerManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CloudServerManager getCloudServerManager() {
|
||||
return new DefaultCloudServerManager();
|
||||
}
|
||||
|
||||
public MobileDeviceManager getMobileDeviceManager() throws Exception {
|
||||
return new DefaultMobileDeviceManager();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user