Skip to content

Commit

Permalink
imrpove orchestrator, task class, settings...
Browse files Browse the repository at this point in the history
  • Loading branch information
CharafeddineMechalikh committed Nov 30, 2019
1 parent 75ec2ff commit 99e515b
Show file tree
Hide file tree
Showing 34 changed files with 97 additions and 750 deletions.
674 changes: 0 additions & 674 deletions LICENSE

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

import com.mechalikh.pureedgesim.ScenarioManager.simulationParameters;

public class MobilityManager extends Mobility {
public class DefaultMobilityModel extends Mobility {
private boolean pause = false;
private double pauseDuration = -1;
private double mobilityDuration = new Random().nextInt(100);
private int orientationAngle = new Random().nextInt(359);

public MobilityManager(Location currentLocation) {
public DefaultMobilityModel(Location currentLocation) {
super(currentLocation);
}

public MobilityManager() {
public DefaultMobilityModel() {
super();
}

Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions PureEdgeSim/com/mechalikh/pureedgesim/MainApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import com.mechalikh.pureedgesim.DataCentersManager.EnergyModel;
import com.mechalikh.pureedgesim.DataCentersManager.ServersManager;
import com.mechalikh.pureedgesim.LocationManager.Mobility;
import com.mechalikh.pureedgesim.LocationManager.MobilityManager;
import com.mechalikh.pureedgesim.LocationManager.DefaultMobilityModel;
import com.mechalikh.pureedgesim.Network.DefaultNetworkModel;
import com.mechalikh.pureedgesim.Network.NetworkModel;
import com.mechalikh.pureedgesim.ScenarioManager.FilesParser;
Expand Down Expand Up @@ -48,7 +48,7 @@ public class MainApplication {
protected int step = 1;
protected static int cpuCores;
protected static List<Scenario> Iterations = new ArrayList<Scenario>();
protected static Class<? extends Mobility> mobilityManager = MobilityManager.class;
protected static Class<? extends Mobility> mobilityManager = DefaultMobilityModel.class;
protected static Class<? extends EdgeDataCenter> edgedatacenter = DefaultEdgeDataCenter.class;
protected static Class<? extends TasksGenerator> tasksGenerator = DefaultTasksGenerator.class;
protected static Class<? extends Orchestrator> orchestrator = DefaultEdgeOrchestrator.class;
Expand Down
11 changes: 7 additions & 4 deletions PureEdgeSim/com/mechalikh/pureedgesim/Network/NetworkModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,31 @@ protected boolean sameLanIsUsed(Task task1, Task task2) {
return ((task1.getOrchestrator() == task2.getOrchestrator())
|| (task1.getOrchestrator() == task2.getVm().getHost().getDatacenter())
|| (task1.getOrchestrator() == task2.getEdgeDevice())
|| (task1.getOrchestrator() == task2.getRegistry())

// Compare origin device
|| (task1.getEdgeDevice() == task2.getOrchestrator())
|| (task1.getEdgeDevice() == task2.getVm().getHost().getDatacenter())
|| (task1.getEdgeDevice() == task2.getEdgeDevice())
|| (task1.getEdgeDevice() == task2.getEdgeDevice()) || (task1.getEdgeDevice() == task2.getRegistry())

// Compare offloading destination
|| (task1.getVm().getHost().getDatacenter() == task2.getOrchestrator())
|| (task1.getVm().getHost().getDatacenter() == task2.getVm().getHost().getDatacenter())
|| (task1.getVm().getHost().getDatacenter() == task2.getEdgeDevice()));
|| (task1.getVm().getHost().getDatacenter() == task2.getEdgeDevice())
|| (task1.getVm().getHost().getDatacenter() == task2.getRegistry()));
}

protected boolean wanIsUsed(FileTransferProgress fileTransferProgress) {
return ((fileTransferProgress.getTransferType() == FileTransferProgress.Type.TASK
&& ((EdgeVM) fileTransferProgress.getTask().getVm()).getType().equals(TYPES.CLOUD))
// If the offloading destination is the cloud

|| fileTransferProgress.getTransferType() == FileTransferProgress.Type.CONTAINER
|| (fileTransferProgress.getTransferType() == FileTransferProgress.Type.CONTAINER
&& (fileTransferProgress.getTask().getRegistry()== null || fileTransferProgress.getTask().getRegistry().getType() == TYPES.CLOUD))
// Or if containers will be downloaded from registry

|| (fileTransferProgress.getTask().getOrchestrator().getType() == simulationParameters.TYPES.CLOUD));
// Or if the orchestrator is deployed in the cloud
// Or if the orchestrator is deployed in the cloud

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

import com.mechalikh.pureedgesim.ScenarioManager.simulationParameters.TYPES;
import com.mechalikh.pureedgesim.SimulationManager.SimLog;

Expand Down Expand Up @@ -61,7 +62,8 @@ private boolean checkSimulationProperties(String simProp) {
simulationParameters.CLEAN_OUTPUT_FOLDER = Boolean
.parseBoolean(prop.getProperty("clear_output_folder").trim());
simulationParameters.WAIT_FOR_TASKS = Boolean.parseBoolean(prop.getProperty("wait_for_all_tasks").trim());
simulationParameters.ENABLE_REGISTRY = Boolean.parseBoolean(prop.getProperty("enable_registry").trim());
simulationParameters.ENABLE_REGISTRY = Boolean.parseBoolean(prop.getProperty("enable_registry").trim());
simulationParameters.registry_mode = prop.getProperty("registry_mode").trim();
simulationParameters.ENABLE_ORCHESTRATORS = Boolean
.parseBoolean(prop.getProperty("enable_orchestrators").trim());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,15 @@ public static enum TYPES { // Types of resources
public static String[] ORCHESTRATION_AlGORITHMS; // Tasks orchestration algorithms
public static String[] ORCHESTRATION_ARCHITECTURES; // The used paradigms : Cloud, Edge, Fog..
public static boolean ENABLE_REGISTRY; // To download the container image or execute the task directly
public static String registry_mode; // Where the containers will be downloaded from
public static int APPS_COUNT; // The number of the applications specified by the user in the Application.xml file
public static double[][] APPLICATIONS_TABLE; // The applications characteristics
public static String CPU_ALLOCATION_POLICY; // CPU allocation policy : TIME_SHARED (results in long simulation time) or SPACE_SHARED
public static String DEPLOY_ORCHESTRATOR=""; // The location where the orchestrators are deployed (Edge devices, Cloud, Fog servers)
public static boolean WAIT_FOR_TASKS; // After the end of the simulation time, some tasks may still not be executed yet,
// this variable will allow the user to wait for the execution of all tasks or to
// end the simulation when the predifined time ends.




Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public void processEvent(SimEvent ev) {
// Result returned to edge device
if (taskFailed(task, 0))
return;
this.edgeOrchestrator.resultsReturned(task);
tasksCount++;
break;

Expand Down Expand Up @@ -417,4 +418,8 @@ public void setOrchestrator(Orchestrator edgeOrchestrator) {
public void setNetworkModel(NetworkModel networkModel) {
this.networkModel = networkModel;
}

public List<Task> getTasksList() {
return tasksList;
}
}
19 changes: 18 additions & 1 deletion PureEdgeSim/com/mechalikh/pureedgesim/TasksGenerator/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ public class Task extends CloudletSimple {
private long containerSize;
private EdgeDataCenter orchestrator;
private double receptionTime = -1; // the time when the task, or the corresponding container has been received by the offloading destination

private EdgeDataCenter registry;
private int applicationID;
public Task(int id, long cloudletLength, long pesNumber) {
super(id, cloudletLength, pesNumber);
}
Expand Down Expand Up @@ -63,4 +64,20 @@ public void setReceptionTime(double time) {
receptionTime = time;
}

public EdgeDataCenter getRegistry() {
return registry;
}

public void setRegistry(EdgeDataCenter registry) {
this.registry = registry;
}

public int getApplicationID() {
return applicationID;
}

public void setApplicationID(int applicationID) {
this.applicationID = applicationID;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,22 @@ public DefaultEdgeOrchestrator(SimulationManager simulationManager) {
super(simulationManager);
}

protected void findVM(String[] architecture, Task task) {
protected int findVM(String[] architecture, Task task) {
if ("ROUND_ROBIN".equals(algorithm)) {
roundRobin(architecture, task);
return roundRobin(architecture, task);
} else if ("TRADE_OFF".equals(algorithm)) {
tradeOff(architecture, task);
return tradeOff(architecture, task);
} else {
SimLog.println("");
SimLog.println("Default Orchestrator- Unknnown orchestration algorithm '" + algorithm
+ "', please check the simulation parameters file...");
// Cancel the simulation
Runtime.getRuntime().exit(0);
}
return -1;
}

private void tradeOff(String[] architecture, Task task) {
private int tradeOff(String[] architecture, Task task) {
int vm = -1;
double min = -1;
double new_min;// vm with minimum assigned tasks;
Expand Down Expand Up @@ -54,11 +55,11 @@ private void tradeOff(String[] architecture, Task task) {
}
}
}
// assign the tasks to the vm found
assignTaskToVm(vm, task);
// assign the tasks to the found vm
return vm;
}

private void roundRobin(String[] architecture, Task task) {
private int roundRobin(String[] architecture, Task task) {
List<EdgeVM> vmList = simulationManager.getServersManager().getVmList();
int vm = -1;
int minTasksCount = -1; // vm with minimum assigned tasks;
Expand All @@ -77,8 +78,13 @@ private void roundRobin(String[] architecture, Task task) {
}
}
}
// assign the tasks to the vm found
assignTaskToVm(vm, task);
// assign the tasks to the found vm
return vm;
}

@Override
public void resultsReturned(Task task) {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,60 +53,60 @@ public void initialize(Task task) {
} else if ("EDGE_AND_CLOUD".equals(architecture)) {
edgeAndCloud(task);
}
// Offload it only if resources are available (i.e. the offloading distination
// is available)
if (task.getVm() != Vm.NULL)
sendTask(task);// Send the task to execute it

}

// If the orchestration scenario is EDGE_ONLY send Tasks only to
// edge virtual machines (vms)
private void edgeOnly(Task task) {
String[] Architecture = { "Edge" };
findVM(Architecture, task);

sendTask(task, findVM(Architecture, task));
}

// If the orchestration scenario is ClOUD_ONLY send Tasks (cloudlets) only to
// cloud virtual machines (vms)
private void cloudOnly(Task task) {
String[] Architecture = { "Cloud" };
findVM(Architecture, task);
sendTask(task, findVM(Architecture, task));
}

// If the orchestration scenario is FOG_AND_CLOUD send Tasks only to
// fog or cloud virtual machines (vms)
private void fogAndCloud(Task task) {
String[] Architecture = { "Cloud", "Fog" };
findVM(Architecture, task);
sendTask(task, findVM(Architecture, task));
}

// If the orchestration scenario is FOG_AND_CLOUD send Tasks only to
// fog or cloud virtual machines (vms)
private void edgeAndCloud(Task task) {
String[] Architecture = { "Cloud", "Edge" };
findVM(Architecture, task);
sendTask(task, findVM(Architecture, task));
}

// If the orchestration scenario is FOG_AND_CLOUD send Tasks only to
// fog or cloud virtual machines (vms)
private void fogOnly(Task task) {
String[] Architecture = { "Fog" };
findVM(Architecture, task);
sendTask(task, findVM(Architecture, task));
}

// If the orchestration scenario is ALL send Tasks (cloudlets) any virtual
// machine (vm)
private void all(Task task) {
String[] Architecture = { "Cloud", "Fog", "Edge" };
findVM(Architecture, task);
}
sendTask(task, findVM(Architecture, task));
}

protected abstract void findVM(String[] architecture, Task task);
protected abstract int findVM(String[] architecture, Task task);

protected void sendTask(Task task) {
task.getEdgeDevice().getVmTaskMap().add(new VmTaskMapItem((EdgeVM) task.getVm(), task));
protected void sendTask(Task task, int vm) {
// assign the tasks to the vm found
assignTaskToVm(vm, task);

// Offload it only if resources are available (i.e. the offloading distination
// is available)
if (task.getVm() != Vm.NULL) // Send the task to execute it
task.getEdgeDevice().getVmTaskMap().add(new VmTaskMapItem((EdgeVM) task.getVm(), task));
}

protected void assignTaskToVm(int vmIndex, Task task) {
Expand All @@ -123,7 +123,8 @@ protected void assignTaskToVm(int vmIndex, Task task) {
}

protected boolean sameLocation(EdgeDataCenter device1, EdgeDataCenter device2, int RANGE) {
if(device2.getType()==TYPES.CLOUD) return true;
if (device2.getType() == TYPES.CLOUD)
return true;
double distance = Math
.abs(Math.sqrt(Math.pow((device1.getLocation().getXPos() - device2.getLocation().getXPos()), 2)
+ Math.pow((device1.getLocation().getYPos() - device2.getLocation().getYPos()), 2)));
Expand Down Expand Up @@ -164,4 +165,6 @@ && sameLocation(((EdgeDataCenter) edgeVM.getHost().getDatacenter()),
&& ((EdgeDataCenter) edgeVM.getHost().getDatacenter()).isDead())));
}

public abstract void resultsReturned(Task task);

}
15 changes: 11 additions & 4 deletions PureEdgeSim/examples/CustomEdgeOrchestrator.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@ public CustomEdgeOrchestrator(SimulationManager simulationManager) {
super(simulationManager);
}

protected void findVM(String[] architecture, Task task) {
protected int findVM(String[] architecture, Task task) {
if ("INCEREASE_LIFETIME".equals(algorithm)) {
increseLifetime(architecture, task);
return increseLifetime(architecture, task);
} else {
SimLog.println("");
SimLog.println("Custom Orchestrator- Unknnown orchestration algorithm '" + algorithm
+ "', please check the simulation parameters file...");
// Cancel the simulation
Runtime.getRuntime().exit(0);
}
return -1;
}

private void increseLifetime(String[] architecture, Task task) {
private int increseLifetime(String[] architecture, Task task) {
int vm = -1;
double minTasksCount = -1; // vm with minimum assigned tasks;
double vmMips = 0;
Expand Down Expand Up @@ -71,7 +72,13 @@ private void increseLifetime(String[] architecture, Task task) {
}
}
// assign the tasks to the vm found
assignTaskToVm(vm, task);
return vm;
}

@Override
public void resultsReturned(Task task) {
// TODO Auto-generated method stub

}

}
Loading

0 comments on commit 99e515b

Please sign in to comment.