some minor backward compatible, major backward incompatible changes and code formatting (beautification)

Minor Modifications:

* Indentation issues are fixed
* Typo errors in source code and comments are fixed
* Misspelled parameters in plotTaskFailureReason.m are corrected
* sim_results folder is added to .gitignore file

Backward compatible changes

* The exit code of the application when there is an error is changed from 0 to 1
* Default constructors are added for Location.java, LoadGeneratorModel.java, MobilityModel.java, EdgeOrchestrator.java (this change request coming from a developer)
* public TaskProperty(int mobileDeviceId, double startTime, ExponentialDistribution[] expRngList) is added to TaskProperty.java  (this change request coming from a developer to create a task without task type)
* double getCreationTime() function is added to Task.java
* void reconfigureMips(double mips) function is added to EdgeVM (for future usage)
* gsm_propagation_delay variable is added to config file. SimSettings class is also modified accordingly. You can use it if you have cellular network access in your scenario.
* wlan_range, northern_bound, southern_bound, eastern_bound, western_bound variables are added to config file; and relevant functions are added to SimSettings class. (this change request coming from a developer)

Backward incompatible changes!

 * location_check_interval variable name is changed to location_check_interval in config.properties file. Please update your config files accordingly (remove 'vm_' part)

 * Major modifications are applied in SimLogger class to decrease time complexity. Now the basic results are kept in the memory and saved to the files at the end of the simulation. As a result of this change, the signature of the SimLogger.addLog () function had to be changed. You must add the mobile device id as the first argument. Please update your MobileDeviceManager class accordingly (add task.getCloudletId () as the first argument).
This commit is contained in:
Cagatay Sonmez
2020-10-30 11:06:09 +03:00
parent 1b4a02e7e6
commit 08341c3681
39 changed files with 1089 additions and 645 deletions

View File

@@ -21,6 +21,12 @@ public class Location {
yPos = _yPos;
}
/*
* Default Constructor: Creates an empty Location
*/
public Location() {
}
@Override
public boolean equals(Object other){
boolean result = false;

View File

@@ -1,8 +1,8 @@
/*
* 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
*/
@@ -20,31 +20,31 @@ public class PoissonDistr {
Poisson poisson;
RandomEngine engine;
/**
* Creates a new exponential number generator.
*
* @param mean the mean for the distribution.
*/
public PoissonDistr(double mean) {
/**
* 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
//always sleep for some milliseconds in order not to have same seed for iterative PoissonDistr construction
try {
TimeUnit.MILLISECONDS.sleep(10);
} catch (InterruptedException e) {
SimLogger.printLine("impossible is occurred! Poisson random number cannot be created!");
SimLogger.printLine("impossible is occurred! Poisson random number cannot be created!");
e.printStackTrace();
System.exit(0);
System.exit(1);
}
}
}
/**
* Generate a new random number.
*
* @return the next random number in the sequence
*/
public double sample() {
return poisson.nextDouble();
}
/**
* 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

@@ -16,26 +16,28 @@ 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();
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();
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();
}
public static long getRandomLongNumber(long start, long 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
@@ -49,16 +51,17 @@ public class SimUtils {
if(!f.delete())
{
SimLogger.printLine("file cannot be cleared: " + f.getAbsolutePath());
System.exit(0);
System.exit(1);
}
}
}
}
else {
SimLogger.printLine("Output folder is not available: " + outputFolder);
System.exit(0);
System.exit(1);
}
}
public static String getTimeDifference(Date startDate, Date endDate){
String result = "";
long duration = endDate.getTime() - startDate.getTime();
@@ -68,7 +71,7 @@ public class SimUtils {
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)
@@ -79,7 +82,7 @@ public class SimUtils {
result += diffInSeconds % 60 + ((diffInSeconds>1 == true) ? " Seconds" : " Second");
if(diffInMilli>0 && result.isEmpty())
result += diffInMilli + ((diffInMilli>1 == true) ? " Milli Seconds" : " Milli Second");
return result;
}
}

View File

@@ -15,59 +15,69 @@ import org.apache.commons.math3.distribution.ExponentialDistribution;
import edu.boun.edgecloudsim.core.SimSettings;
public class TaskProperty {
private double startTime;
private long length, inputFileSize, outputFileSize;
private int taskType;
private int pesNumber;
private int mobileDeviceId;
public TaskProperty(double _startTime, int _mobileDeviceId, int _taskType, int _pesNumber, long _length, long _inputFileSize, long _outputFileSize) {
startTime=_startTime;
mobileDeviceId=_mobileDeviceId;
taskType=_taskType;
pesNumber = _pesNumber;
length = _length;
outputFileSize = _inputFileSize;
inputFileSize = _outputFileSize;
}
public TaskProperty(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];
}
public double getStartTime(){
return startTime;
}
public long getLength(){
return length;
}
public long getInputFileSize(){
return inputFileSize;
}
public long getOutputFileSize(){
return outputFileSize;
}
private double startTime;
private long length, inputFileSize, outputFileSize;
private int taskType;
private int pesNumber;
private int mobileDeviceId;
public int getTaskType(){
return taskType;
}
public int getPesNumber(){
return pesNumber;
}
public int getMobileDeviceId(){
return mobileDeviceId;
}
public TaskProperty(double _startTime, int _mobileDeviceId, int _taskType, int _pesNumber, long _length, long _inputFileSize, long _outputFileSize) {
startTime=_startTime;
mobileDeviceId=_mobileDeviceId;
taskType=_taskType;
pesNumber = _pesNumber;
length = _length;
outputFileSize = _inputFileSize;
inputFileSize = _outputFileSize;
}
public TaskProperty(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];
}
public TaskProperty(int mobileDeviceId, double startTime, ExponentialDistribution[] expRngList) {
this.mobileDeviceId = mobileDeviceId;
this.startTime = startTime;
taskType = 0;
inputFileSize = (long)expRngList[0].sample();
outputFileSize = (long)expRngList[1].sample();
length = (long) expRngList[2].sample();
pesNumber = (int)SimSettings.getInstance().getTaskLookUpTable()[0][8];
}
public double getStartTime(){
return startTime;
}
public long getLength(){
return length;
}
public long getInputFileSize(){
return inputFileSize;
}
public long getOutputFileSize(){
return outputFileSize;
}
public int getTaskType(){
return taskType;
}
public int getPesNumber(){
return pesNumber;
}
public int getMobileDeviceId(){
return mobileDeviceId;
}
}