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:
Cagatay Sonmez
2018-09-10 14:22:27 +03:00
parent e01833bda6
commit d4545f009f
89 changed files with 10699 additions and 4689 deletions

View File

@@ -1,36 +1,35 @@
/*
* Title: EdgeCloudSim - EdgeTask
*
* Description:
* A custom class used in Load Generator Model to store tasks information
*
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* Copyright (c) 2017, Bogazici University, Istanbul, Turkey
*/
package edu.boun.edgecloudsim.utils;
import org.apache.commons.math3.distribution.ExponentialDistribution;
import edu.boun.edgecloudsim.core.SimSettings;
import edu.boun.edgecloudsim.core.SimSettings.APP_TYPES;
public class EdgeTask {
public APP_TYPES taskType;
public double startTime;
public long length, inputFileSize, outputFileSize;
public int pesNumber;
public int mobileDeviceId;
public EdgeTask(int _mobileDeviceId, APP_TYPES _taskType, double _startTime, ExponentialDistribution[][] expRngList) {
mobileDeviceId=_mobileDeviceId;
startTime=_startTime;
taskType=_taskType;
inputFileSize = (long)expRngList[_taskType.ordinal()][0].sample();
outputFileSize =(long)expRngList[_taskType.ordinal()][1].sample();
length = (long)expRngList[_taskType.ordinal()][2].sample();
pesNumber = (int)SimSettings.getInstance().getTaskLookUpTable()[_taskType.ordinal()][8];
}
}
/*
* Title: EdgeCloudSim - EdgeTask
*
* Description:
* A custom class used in Load Generator Model to store tasks information
*
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* Copyright (c) 2017, Bogazici University, Istanbul, Turkey
*/
package edu.boun.edgecloudsim.utils;
import org.apache.commons.math3.distribution.ExponentialDistribution;
import edu.boun.edgecloudsim.core.SimSettings;
public class EdgeTask {
public double startTime;
public long length, inputFileSize, outputFileSize;
public int taskType;
public int pesNumber;
public int mobileDeviceId;
public EdgeTask(int _mobileDeviceId, int _taskType, double _startTime, ExponentialDistribution[][] expRngList) {
mobileDeviceId=_mobileDeviceId;
startTime=_startTime;
taskType=_taskType;
inputFileSize = (long)expRngList[_taskType][0].sample();
outputFileSize =(long)expRngList[_taskType][1].sample();
length = (long)expRngList[_taskType][2].sample();
pesNumber = (int)SimSettings.getInstance().getTaskLookUpTable()[_taskType][8];
}
}

View File

@@ -1,55 +1,53 @@
/*
* Title: EdgeCloudSim - Location
*
* Description: Location class used in EdgeCloudSim
*
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* Copyright (c) 2017, Bogazici University, Istanbul, Turkey
*/
package edu.boun.edgecloudsim.utils;
import edu.boun.edgecloudsim.core.SimSettings;
public class Location {
private int xPos;
private int yPos;
private int servingWlanId;
SimSettings.PLACE_TYPES placeType;
public Location(SimSettings.PLACE_TYPES _placeType, int _servingWlanId, int _xPos, int _yPos){
servingWlanId = _servingWlanId;
placeType=_placeType;
xPos = _xPos;
yPos = _yPos;
}
@Override
public boolean equals(Object other){
boolean result = false;
if (other == null) return false;
if (!(other instanceof Location))return false;
if (other == this) return true;
Location otherLocation = (Location)other;
if(this.xPos == otherLocation.xPos && this.yPos == otherLocation.yPos)
result = true;
return result;
}
public int getServingWlanId(){
return servingWlanId;
}
public SimSettings.PLACE_TYPES getPlaceType(){
return placeType;
}
public int getXPos(){
return xPos;
}
public int getYPos(){
return yPos;
}
}
/*
* Title: EdgeCloudSim - Location
*
* Description: Location class used in EdgeCloudSim
*
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* Copyright (c) 2017, Bogazici University, Istanbul, Turkey
*/
package edu.boun.edgecloudsim.utils;
public class Location {
private int xPos;
private int yPos;
private int servingWlanId;
private int placeTypeIndex;
public Location(int _placeTypeIndex, int _servingWlanId, int _xPos, int _yPos){
servingWlanId = _servingWlanId;
placeTypeIndex=_placeTypeIndex;
xPos = _xPos;
yPos = _yPos;
}
@Override
public boolean equals(Object other){
boolean result = false;
if (other == null) return false;
if (!(other instanceof Location))return false;
if (other == this) return true;
Location otherLocation = (Location)other;
if(this.xPos == otherLocation.xPos && this.yPos == otherLocation.yPos)
result = true;
return result;
}
public int getServingWlanId(){
return servingWlanId;
}
public int getPlaceTypeIndex(){
return placeTypeIndex;
}
public int getXPos(){
return xPos;
}
public int getYPos(){
return yPos;
}
}

View File

@@ -1,50 +1,50 @@
/*
* Title: EdgeCloudSim - Poisson Distribution
*
* Description: Wrapper class for colt Poisson Distribution
*
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* Copyright (c) 2017, Bogazici University, Istanbul, Turkey
*/
package edu.boun.edgecloudsim.utils;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import cern.jet.random.Poisson;
import cern.jet.random.engine.MersenneTwister;
import cern.jet.random.engine.RandomEngine;
public class PoissonDistr {
Poisson poisson;
RandomEngine engine;
/**
* Creates a new exponential number generator.
*
* @param mean the mean for the distribution.
*/
public PoissonDistr(double mean) {
engine = new MersenneTwister(new Date());
poisson = new Poisson(mean, engine);
//always sleep for some milliseconds in order not to have same seed for iterative PoissonDistr contruction
try {
TimeUnit.MILLISECONDS.sleep(10);
} catch (InterruptedException e) {
SimLogger.printLine("impossible is occured! Poisson random number cannot be created!");
e.printStackTrace();
System.exit(0);
}
}
/**
* Generate a new random number.
*
* @return the next random number in the sequence
*/
public double sample() {
return poisson.nextDouble();
}
}
/*
* Title: EdgeCloudSim - Poisson Distribution
*
* Description: Wrapper class for colt Poisson Distribution
*
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* Copyright (c) 2017, Bogazici University, Istanbul, Turkey
*/
package edu.boun.edgecloudsim.utils;
import java.util.Date;
import java.util.concurrent.TimeUnit;
import cern.jet.random.Poisson;
import cern.jet.random.engine.MersenneTwister;
import cern.jet.random.engine.RandomEngine;
public class PoissonDistr {
Poisson poisson;
RandomEngine engine;
/**
* Creates a new exponential number generator.
*
* @param mean the mean for the distribution.
*/
public PoissonDistr(double mean) {
engine = new MersenneTwister(new Date());
poisson = new Poisson(mean, engine);
//always sleep for some milliseconds in order not to have same seed for iterative PoissonDistr contruction
try {
TimeUnit.MILLISECONDS.sleep(10);
} catch (InterruptedException e) {
SimLogger.printLine("impossible is occured! Poisson random number cannot be created!");
e.printStackTrace();
System.exit(0);
}
}
/**
* Generate a new random number.
*
* @return the next random number in the sequence
*/
public double sample() {
return poisson.nextDouble();
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,103 +1,85 @@
/*
* Title: EdgeCloudSim - Simulation Utils
*
* Description: Utility class providing helper functions
*
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* Copyright (c) 2017, Bogazici University, Istanbul, Turkey
*/
package edu.boun.edgecloudsim.utils;
import java.io.File;
import java.util.Date;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import edu.boun.edgecloudsim.core.SimSettings;
public class SimUtils {
public static final Random RNG = new Random(System.currentTimeMillis());
public static int getRandomNumber(int start, int end) {
//return pd.sample();
long range = (long)end - (long)start + 1;
long fraction = (long)(range * RNG.nextDouble());
return (int)(fraction + start);
}
public static double getRandomDoubleNumber(double start, double end) {
//return pd.sample();
double range = end - start;
double fraction = (range * RNG.nextDouble());
return (fraction + start);
}
public static long getRandomLongNumber(int start, int end) {
//return pd.sample();
long range = (long)end - (long)start + 1;
long fraction = (long)(range * RNG.nextDouble());
return (fraction + start);
}
public static void cleanOutputFolder(String outputFolder){
//clean the folder where the result files will be saved
File dir = new File(outputFolder);
if(dir.exists() && dir.isDirectory())
{
for (File f: dir.listFiles())
{
if (f.exists() && f.isFile())
{
if(!f.delete())
{
SimLogger.printLine("file cannot be cleared: " + f.getAbsolutePath());
System.exit(0);
}
}
}
}
else {
SimLogger.printLine("Output folder is not available: " + outputFolder);
System.exit(0);
}
}
public static String getTimeDifference(Date startDate, Date endDate){
String result = "";
long duration = endDate.getTime() - startDate.getTime();
long diffInMilli = TimeUnit.MILLISECONDS.toMillis(duration);
long diffInSeconds = TimeUnit.MILLISECONDS.toSeconds(duration);
long diffInMinutes = TimeUnit.MILLISECONDS.toMinutes(duration);
long diffInHours = TimeUnit.MILLISECONDS.toHours(duration);
long diffInDays = TimeUnit.MILLISECONDS.toDays(duration);
if(diffInDays>0)
result += diffInDays + ((diffInDays>1 == true) ? " Days " : " Day ");
if(diffInHours>0)
result += diffInHours % 24 + ((diffInHours>1 == true) ? " Hours " : " Hour ");
if(diffInMinutes>0)
result += diffInMinutes % 60 + ((diffInMinutes>1 == true) ? " Minutes " : " Minute ");
if(diffInSeconds>0)
result += diffInSeconds % 60 + ((diffInSeconds>1 == true) ? " Seconds" : " Second");
if(diffInMilli>0 && result.isEmpty())
result += diffInMilli + ((diffInMilli>1 == true) ? " Milli Seconds" : " Milli Second");
return result;
}
public static SimSettings.PLACE_TYPES stringToPlace(String attractiveness){
SimSettings.PLACE_TYPES placeType = null;
if(attractiveness.equals("1"))
placeType = SimSettings.PLACE_TYPES.ATTRACTIVENESS_L1;
else if(attractiveness.equals("2"))
placeType = SimSettings.PLACE_TYPES.ATTRACTIVENESS_L2;
else if(attractiveness.equals("3"))
placeType = SimSettings.PLACE_TYPES.ATTRACTIVENESS_L3;
else{
SimLogger.printLine("Unknown attractiveness level! Terminating simulation...");
System.exit(0);
}
return placeType;
}
}
/*
* Title: EdgeCloudSim - Simulation Utils
*
* Description: Utility class providing helper functions
*
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
* Copyright (c) 2017, Bogazici University, Istanbul, Turkey
*/
package edu.boun.edgecloudsim.utils;
import java.io.File;
import java.util.Date;
import java.util.Random;
import java.util.concurrent.TimeUnit;
public class SimUtils {
public static final Random RNG = new Random(System.currentTimeMillis());
public static int getRandomNumber(int start, int end) {
//return pd.sample();
long range = (long)end - (long)start + 1;
long fraction = (long)(range * RNG.nextDouble());
return (int)(fraction + start);
}
public static double getRandomDoubleNumber(double start, double end) {
//return pd.sample();
double range = end - start;
double fraction = (range * RNG.nextDouble());
return (fraction + start);
}
public static long getRandomLongNumber(int start, int end) {
//return pd.sample();
long range = (long)end - (long)start + 1;
long fraction = (long)(range * RNG.nextDouble());
return (fraction + start);
}
public static void cleanOutputFolder(String outputFolder){
//clean the folder where the result files will be saved
File dir = new File(outputFolder);
if(dir.exists() && dir.isDirectory())
{
for (File f: dir.listFiles())
{
if (f.exists() && f.isFile())
{
if(!f.delete())
{
SimLogger.printLine("file cannot be cleared: " + f.getAbsolutePath());
System.exit(0);
}
}
}
}
else {
SimLogger.printLine("Output folder is not available: " + outputFolder);
System.exit(0);
}
}
public static String getTimeDifference(Date startDate, Date endDate){
String result = "";
long duration = endDate.getTime() - startDate.getTime();
long diffInMilli = TimeUnit.MILLISECONDS.toMillis(duration);
long diffInSeconds = TimeUnit.MILLISECONDS.toSeconds(duration);
long diffInMinutes = TimeUnit.MILLISECONDS.toMinutes(duration);
long diffInHours = TimeUnit.MILLISECONDS.toHours(duration);
long diffInDays = TimeUnit.MILLISECONDS.toDays(duration);
if(diffInDays>0)
result += diffInDays + ((diffInDays>1 == true) ? " Days " : " Day ");
if(diffInHours>0)
result += diffInHours % 24 + ((diffInHours>1 == true) ? " Hours " : " Hour ");
if(diffInMinutes>0)
result += diffInMinutes % 60 + ((diffInMinutes>1 == true) ? " Minutes " : " Minute ");
if(diffInSeconds>0)
result += diffInSeconds % 60 + ((diffInSeconds>1 == true) ? " Seconds" : " Second");
if(diffInMilli>0 && result.isEmpty())
result += diffInMilli + ((diffInMilli>1 == true) ? " Milli Seconds" : " Milli Second");
return result;
}
}