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:
@@ -1,94 +1,104 @@
|
||||
/*
|
||||
* Title: EdgeCloudSim - Idle/Active Load Generator implementation
|
||||
*
|
||||
* Description:
|
||||
* IdleActiveLoadGenerator implements basic load generator model where the
|
||||
* mobile devices generate task in active period and waits in idle period.
|
||||
* Task interarrival time (load generation period), Idle and active periods
|
||||
* are defined in the configuration file.
|
||||
*
|
||||
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
|
||||
* Copyright (c) 2017, Bogazici University, Istanbul, Turkey
|
||||
*/
|
||||
|
||||
package edu.boun.edgecloudsim.task_generator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.apache.commons.math3.distribution.ExponentialDistribution;
|
||||
|
||||
import edu.boun.edgecloudsim.core.SimSettings;
|
||||
import edu.boun.edgecloudsim.core.SimSettings.APP_TYPES;
|
||||
import edu.boun.edgecloudsim.utils.EdgeTask;
|
||||
import edu.boun.edgecloudsim.utils.SimLogger;
|
||||
import edu.boun.edgecloudsim.utils.SimUtils;
|
||||
|
||||
public class IdleActiveLoadGenerator extends LoadGeneratorModel{
|
||||
|
||||
public IdleActiveLoadGenerator(int _numberOfMobileDevices, double _simulationTime, String _simScenario) {
|
||||
super(_numberOfMobileDevices, _simulationTime, _simScenario);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeModel() {
|
||||
taskList = new ArrayList<EdgeTask>();
|
||||
|
||||
//exponential number generator for file input size, file output size and task length
|
||||
ExponentialDistribution[][] expRngList = new ExponentialDistribution[SimSettings.APP_TYPES.values().length][3];
|
||||
|
||||
//create random number generator for each place
|
||||
for(int i=0; i<SimSettings.APP_TYPES.values().length; i++) {
|
||||
if(SimSettings.getInstance().getTaskLookUpTable()[i][0] ==0)
|
||||
continue;
|
||||
|
||||
expRngList[i][0] = new ExponentialDistribution(SimSettings.getInstance().getTaskLookUpTable()[i][5]);
|
||||
expRngList[i][1] = new ExponentialDistribution(SimSettings.getInstance().getTaskLookUpTable()[i][6]);
|
||||
expRngList[i][2] = new ExponentialDistribution(SimSettings.getInstance().getTaskLookUpTable()[i][7]);
|
||||
}
|
||||
|
||||
//Each mobile device utilizes an app type (task type)
|
||||
for(int i=0; i<numberOfMobileDevices; i++) {
|
||||
APP_TYPES randomTaskType = null;
|
||||
double taskTypeSelector = SimUtils.getRandomDoubleNumber(0,100);
|
||||
double taskTypePercentage = 0;
|
||||
for (SimSettings.APP_TYPES taskType : SimSettings.APP_TYPES.values()) {
|
||||
taskTypePercentage += SimSettings.getInstance().getTaskLookUpTable()[taskType.ordinal()][0];
|
||||
if(taskTypeSelector <= taskTypePercentage){
|
||||
randomTaskType = taskType;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(randomTaskType == null){
|
||||
SimLogger.printLine("Impossible is occured! no random task type!");
|
||||
continue;
|
||||
}
|
||||
|
||||
double poissonMean = SimSettings.getInstance().getTaskLookUpTable()[randomTaskType.ordinal()][2];
|
||||
double activePeriod = SimSettings.getInstance().getTaskLookUpTable()[randomTaskType.ordinal()][3];
|
||||
double idlePeriod = SimSettings.getInstance().getTaskLookUpTable()[randomTaskType.ordinal()][4];
|
||||
double activePeriodStartTime = SimUtils.getRandomDoubleNumber(10, 10+activePeriod); //start from 10th seconds
|
||||
double virtualTime = activePeriodStartTime; //start from 10th seconds
|
||||
|
||||
ExponentialDistribution rng = new ExponentialDistribution(poissonMean);
|
||||
while(virtualTime < simulationTime) {
|
||||
double interval = rng.sample();
|
||||
|
||||
if(interval <= 0){
|
||||
SimLogger.printLine("Impossible is occured! interval is " + interval + " for device " + i + " time " + virtualTime);
|
||||
continue;
|
||||
}
|
||||
//SimLogger.printLine(virtualTime + " -> " + interval + " for device " + i + " time ");
|
||||
virtualTime += interval;
|
||||
|
||||
if(virtualTime > activePeriodStartTime + activePeriod){
|
||||
activePeriodStartTime = activePeriodStartTime + activePeriod + idlePeriod;
|
||||
virtualTime = activePeriodStartTime;
|
||||
continue;
|
||||
}
|
||||
|
||||
taskList.add(new EdgeTask(i,randomTaskType, virtualTime, expRngList));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* Title: EdgeCloudSim - Idle/Active Load Generator implementation
|
||||
*
|
||||
* Description:
|
||||
* IdleActiveLoadGenerator implements basic load generator model where the
|
||||
* mobile devices generate task in active period and waits in idle period.
|
||||
* Task interarrival time (load generation period), Idle and active periods
|
||||
* are defined in the configuration file.
|
||||
*
|
||||
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
|
||||
* Copyright (c) 2017, Bogazici University, Istanbul, Turkey
|
||||
*/
|
||||
|
||||
package edu.boun.edgecloudsim.task_generator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.apache.commons.math3.distribution.ExponentialDistribution;
|
||||
|
||||
import edu.boun.edgecloudsim.core.SimSettings;
|
||||
import edu.boun.edgecloudsim.utils.EdgeTask;
|
||||
import edu.boun.edgecloudsim.utils.SimLogger;
|
||||
import edu.boun.edgecloudsim.utils.SimUtils;
|
||||
|
||||
public class IdleActiveLoadGenerator extends LoadGeneratorModel{
|
||||
int taskTypeOfDevices[];
|
||||
public IdleActiveLoadGenerator(int _numberOfMobileDevices, double _simulationTime, String _simScenario) {
|
||||
super(_numberOfMobileDevices, _simulationTime, _simScenario);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeModel() {
|
||||
taskList = new ArrayList<EdgeTask>();
|
||||
|
||||
//exponential number generator for file input size, file output size and task length
|
||||
ExponentialDistribution[][] expRngList = new ExponentialDistribution[SimSettings.getInstance().getTaskLookUpTable().length][3];
|
||||
|
||||
//create random number generator for each place
|
||||
for(int i=0; i<SimSettings.getInstance().getTaskLookUpTable().length; i++) {
|
||||
if(SimSettings.getInstance().getTaskLookUpTable()[i][0] ==0)
|
||||
continue;
|
||||
|
||||
expRngList[i][0] = new ExponentialDistribution(SimSettings.getInstance().getTaskLookUpTable()[i][5]);
|
||||
expRngList[i][1] = new ExponentialDistribution(SimSettings.getInstance().getTaskLookUpTable()[i][6]);
|
||||
expRngList[i][2] = new ExponentialDistribution(SimSettings.getInstance().getTaskLookUpTable()[i][7]);
|
||||
}
|
||||
|
||||
//Each mobile device utilizes an app type (task type)
|
||||
taskTypeOfDevices = new int[numberOfMobileDevices];
|
||||
for(int i=0; i<numberOfMobileDevices; i++) {
|
||||
int randomTaskType = -1;
|
||||
double taskTypeSelector = SimUtils.getRandomDoubleNumber(0,100);
|
||||
double taskTypePercentage = 0;
|
||||
for (int j=0; j<SimSettings.getInstance().getTaskLookUpTable().length; j++) {
|
||||
taskTypePercentage += SimSettings.getInstance().getTaskLookUpTable()[j][0];
|
||||
if(taskTypeSelector <= taskTypePercentage){
|
||||
randomTaskType = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(randomTaskType == -1){
|
||||
SimLogger.printLine("Impossible is occured! no random task type!");
|
||||
continue;
|
||||
}
|
||||
|
||||
taskTypeOfDevices[i] = randomTaskType;
|
||||
|
||||
double poissonMean = SimSettings.getInstance().getTaskLookUpTable()[randomTaskType][2];
|
||||
double activePeriod = SimSettings.getInstance().getTaskLookUpTable()[randomTaskType][3];
|
||||
double idlePeriod = SimSettings.getInstance().getTaskLookUpTable()[randomTaskType][4];
|
||||
double activePeriodStartTime = SimUtils.getRandomDoubleNumber(
|
||||
SimSettings.CLIENT_ACTIVITY_START_TIME,
|
||||
SimSettings.CLIENT_ACTIVITY_START_TIME + activePeriod); //active period starts shortly after the simulation started (e.g. 10 seconds)
|
||||
double virtualTime = activePeriodStartTime;
|
||||
|
||||
ExponentialDistribution rng = new ExponentialDistribution(poissonMean);
|
||||
while(virtualTime < simulationTime) {
|
||||
double interval = rng.sample();
|
||||
|
||||
if(interval <= 0){
|
||||
SimLogger.printLine("Impossible is occured! interval is " + interval + " for device " + i + " time " + virtualTime);
|
||||
continue;
|
||||
}
|
||||
//SimLogger.printLine(virtualTime + " -> " + interval + " for device " + i + " time ");
|
||||
virtualTime += interval;
|
||||
|
||||
if(virtualTime > activePeriodStartTime + activePeriod){
|
||||
activePeriodStartTime = activePeriodStartTime + activePeriod + idlePeriod;
|
||||
virtualTime = activePeriodStartTime;
|
||||
continue;
|
||||
}
|
||||
|
||||
taskList.add(new EdgeTask(i,randomTaskType, virtualTime, expRngList));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTaskTypeOfDevice(int deviceId) {
|
||||
// TODO Auto-generated method stub
|
||||
return taskTypeOfDevices[deviceId];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,44 +1,49 @@
|
||||
/*
|
||||
* Title: EdgeCloudSim - Load Generator Model
|
||||
*
|
||||
* Description:
|
||||
* LoadGeneratorModel is an abstract class which is used for
|
||||
* deciding task generation pattern via a task list. For those who
|
||||
* wants to add a custom Load Generator Model to EdgeCloudSim should
|
||||
* extend this class and provide a concreate instance via ScenarioFactory
|
||||
*
|
||||
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
|
||||
* Copyright (c) 2017, Bogazici University, Istanbul, Turkey
|
||||
*/
|
||||
|
||||
package edu.boun.edgecloudsim.task_generator;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import edu.boun.edgecloudsim.utils.EdgeTask;
|
||||
|
||||
public abstract class LoadGeneratorModel {
|
||||
protected List<EdgeTask> taskList;
|
||||
protected int numberOfMobileDevices;
|
||||
protected double simulationTime;
|
||||
protected String simScenario;
|
||||
|
||||
public LoadGeneratorModel(int _numberOfMobileDevices, double _simulationTime, String _simScenario){
|
||||
numberOfMobileDevices=_numberOfMobileDevices;
|
||||
simulationTime=_simulationTime;
|
||||
simScenario=_simScenario;
|
||||
};
|
||||
|
||||
/*
|
||||
* each task has a virtual start time
|
||||
* it will be used while generating task
|
||||
*/
|
||||
public List<EdgeTask> getTaskList() {
|
||||
return taskList;
|
||||
}
|
||||
|
||||
/*
|
||||
* fill task list according to related task generation model
|
||||
*/
|
||||
public abstract void initializeModel();
|
||||
}
|
||||
/*
|
||||
* Title: EdgeCloudSim - Load Generator Model
|
||||
*
|
||||
* Description:
|
||||
* LoadGeneratorModel is an abstract class which is used for
|
||||
* deciding task generation pattern via a task list. For those who
|
||||
* wants to add a custom Load Generator Model to EdgeCloudSim should
|
||||
* extend this class and provide a concreate instance via ScenarioFactory
|
||||
*
|
||||
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
|
||||
* Copyright (c) 2017, Bogazici University, Istanbul, Turkey
|
||||
*/
|
||||
|
||||
package edu.boun.edgecloudsim.task_generator;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import edu.boun.edgecloudsim.utils.EdgeTask;
|
||||
|
||||
public abstract class LoadGeneratorModel {
|
||||
protected List<EdgeTask> taskList;
|
||||
protected int numberOfMobileDevices;
|
||||
protected double simulationTime;
|
||||
protected String simScenario;
|
||||
|
||||
public LoadGeneratorModel(int _numberOfMobileDevices, double _simulationTime, String _simScenario){
|
||||
numberOfMobileDevices=_numberOfMobileDevices;
|
||||
simulationTime=_simulationTime;
|
||||
simScenario=_simScenario;
|
||||
};
|
||||
|
||||
/*
|
||||
* each task has a virtual start time
|
||||
* it will be used while generating task
|
||||
*/
|
||||
public List<EdgeTask> getTaskList() {
|
||||
return taskList;
|
||||
}
|
||||
|
||||
/*
|
||||
* fill task list according to related task generation model
|
||||
*/
|
||||
public abstract void initializeModel();
|
||||
|
||||
/*
|
||||
* returns the task type (index) that the mobile device uses
|
||||
*/
|
||||
public abstract int getTaskTypeOfDevice(int deviceId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user