initial commit of EdgeCloudSim
EdgeCloudSim with default network model, mobility model, load generator model, edge orchestrator, and VM CPU utilization model
This commit is contained in:
57
src/edu/boun/edgecloudsim/core/ScenarioFactory.java
Normal file
57
src/edu/boun/edgecloudsim/core/ScenarioFactory.java
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Title: EdgeCloudSim - Scenarion Factory interface
|
||||
*
|
||||
* Description:
|
||||
* ScenarioFactory responsible for providing customizable components
|
||||
* such as Network Model, Mobility Model, Edge Orchestrator.
|
||||
* This interface is very critical for using custom models on EdgeCloudSim
|
||||
* This interface should be implemented by EdgeCloudSim users
|
||||
*
|
||||
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
|
||||
* Copyright (c) 2017, Bogazici University, Istanbul, Turkey
|
||||
*/
|
||||
|
||||
package edu.boun.edgecloudsim.core;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.cloudbus.cloudsim.Host;
|
||||
import org.cloudbus.cloudsim.UtilizationModel;
|
||||
import org.cloudbus.cloudsim.VmAllocationPolicy;
|
||||
|
||||
import edu.boun.edgecloudsim.edge_orchestrator.EdgeOrchestrator;
|
||||
import edu.boun.edgecloudsim.mobility.MobilityModel;
|
||||
import edu.boun.edgecloudsim.task_generator.LoadGeneratorModel;
|
||||
import edu.boun.edgecloudsim.network.NetworkModel;
|
||||
|
||||
public interface ScenarioFactory {
|
||||
/**
|
||||
* provides abstract Load Generator Model
|
||||
*/
|
||||
public LoadGeneratorModel getLoadGeneratorModel();
|
||||
|
||||
/**
|
||||
* provides abstract Edge Orchestrator
|
||||
*/
|
||||
public EdgeOrchestrator getEdgeOrchestrator();
|
||||
|
||||
/**
|
||||
* provides abstract Mobility Model
|
||||
*/
|
||||
public MobilityModel getMobilityModel();
|
||||
|
||||
/**
|
||||
* provides abstract Network Model
|
||||
*/
|
||||
public NetworkModel getNetworkModel();
|
||||
|
||||
/**
|
||||
* provides abstract CPU Utilization Model
|
||||
*/
|
||||
public UtilizationModel getCpuUtilizationModel(SimSettings.APP_TYPES _taskType);
|
||||
|
||||
/**
|
||||
* provides abstract Vm Allocation Policy
|
||||
*/
|
||||
public VmAllocationPolicy getVmAllocationPolicy(List<? extends Host> list, int dataCenterIndex);
|
||||
}
|
||||
200
src/edu/boun/edgecloudsim/core/SimManager.java
Normal file
200
src/edu/boun/edgecloudsim/core/SimManager.java
Normal file
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
* Title: EdgeCloudSim - Simulation Manager
|
||||
*
|
||||
* Description:
|
||||
* SimManager is an singleton class providing many abstract classeses such as
|
||||
* Network Model, Mobility Model, Edge Orchestrator to other modules
|
||||
* Critical simulation related information would be gathered via this class
|
||||
*
|
||||
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
|
||||
* Copyright (c) 2017, Bogazici University, Istanbul, Turkey
|
||||
*/
|
||||
|
||||
package edu.boun.edgecloudsim.core;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.cloudbus.cloudsim.Log;
|
||||
import org.cloudbus.cloudsim.core.CloudSim;
|
||||
import org.cloudbus.cloudsim.core.SimEntity;
|
||||
import org.cloudbus.cloudsim.core.SimEvent;
|
||||
|
||||
import edu.boun.edgecloudsim.edge_orchestrator.EdgeOrchestrator;
|
||||
import edu.boun.edgecloudsim.edge_server.EdgeServerManager;
|
||||
import edu.boun.edgecloudsim.edge_server.VmAllocationPolicy_Custom;
|
||||
import edu.boun.edgecloudsim.edge_client.MobileDeviceManager;
|
||||
import edu.boun.edgecloudsim.mobility.MobilityModel;
|
||||
import edu.boun.edgecloudsim.task_generator.LoadGeneratorModel;
|
||||
import edu.boun.edgecloudsim.network.NetworkModel;
|
||||
import edu.boun.edgecloudsim.utils.EdgeTask;
|
||||
import edu.boun.edgecloudsim.utils.SimLogger;
|
||||
|
||||
public class SimManager extends SimEntity {
|
||||
private static final int CREATE_TASK = 0;
|
||||
private static final int CHECK_ALL_VM = 1;
|
||||
private static final int GET_LOAD_LOG = 2;
|
||||
private static final int PRINT_PROGRESS = 3;
|
||||
private static final int STOP_SIMULATION = 4;
|
||||
|
||||
private int numOfMobileDevice;
|
||||
private NetworkModel networkModel;
|
||||
private MobilityModel mobilityModel;
|
||||
private ScenarioFactory scenarioFactory;
|
||||
private EdgeOrchestrator edgeOrchestrator;
|
||||
private EdgeServerManager edgeServerManager;
|
||||
private LoadGeneratorModel loadGeneratorModel;
|
||||
private MobileDeviceManager mobileDeviceManager;
|
||||
|
||||
private static SimManager instance = null;
|
||||
|
||||
public SimManager(ScenarioFactory _scenarioFactory, int _numOfMobileDevice, SimSettings.SCENARIO_TYPES _simScenario) throws Exception {
|
||||
super("SimManager");
|
||||
scenarioFactory = _scenarioFactory;
|
||||
numOfMobileDevice = _numOfMobileDevice;
|
||||
|
||||
SimLogger.print("Creating tasks...");
|
||||
loadGeneratorModel = scenarioFactory.getLoadGeneratorModel();
|
||||
loadGeneratorModel.initializeModel();
|
||||
SimLogger.printLine("Done, ");
|
||||
|
||||
SimLogger.print("Creating device locations...");
|
||||
mobilityModel = scenarioFactory.getMobilityModel();
|
||||
mobilityModel.initialize();
|
||||
SimLogger.printLine("Done.");
|
||||
|
||||
//Generate network model
|
||||
networkModel = scenarioFactory.getNetworkModel();
|
||||
networkModel.initialize();
|
||||
|
||||
//Generate edge orchestrator
|
||||
edgeOrchestrator = scenarioFactory.getEdgeOrchestrator();
|
||||
edgeOrchestrator.initialize();
|
||||
|
||||
//Create Physical Servers
|
||||
edgeServerManager = new EdgeServerManager();
|
||||
|
||||
//Create Client Manager
|
||||
mobileDeviceManager = new MobileDeviceManager();
|
||||
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public static SimManager getInstance(){
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggering CloudSim to start simulation
|
||||
*/
|
||||
public void startSimulation() throws Exception{
|
||||
//Starts the simulation
|
||||
SimLogger.print(super.getName()+" is starting...");
|
||||
|
||||
//Start Edge Servers & Generate VMs
|
||||
edgeServerManager.startDatacenters();
|
||||
edgeServerManager.createVmList(mobileDeviceManager.getId());
|
||||
|
||||
CloudSim.startSimulation();
|
||||
}
|
||||
|
||||
public ScenarioFactory getScenarioFactory(){
|
||||
return scenarioFactory;
|
||||
}
|
||||
|
||||
public int getNumOfMobileDevice(){
|
||||
return numOfMobileDevice;
|
||||
}
|
||||
|
||||
public NetworkModel getNetworkModel(){
|
||||
return networkModel;
|
||||
}
|
||||
|
||||
public MobilityModel getMobilityModel(){
|
||||
return mobilityModel;
|
||||
}
|
||||
|
||||
public EdgeOrchestrator getEdgeOrchestrator(){
|
||||
return edgeOrchestrator;
|
||||
}
|
||||
|
||||
public EdgeServerManager getLocalServerManager(){
|
||||
return edgeServerManager;
|
||||
}
|
||||
|
||||
public MobileDeviceManager getMobileDeviceManager(){
|
||||
return mobileDeviceManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startEntity() {
|
||||
for(int i=0; i<edgeServerManager.getDatacenterList().size(); i++)
|
||||
mobileDeviceManager.submitVmList(edgeServerManager.getVmList(i));
|
||||
|
||||
//Creation of tasks are scheduled here!
|
||||
for(int i=0; i< loadGeneratorModel.getTaskList().size(); i++)
|
||||
schedule(getId(), loadGeneratorModel.getTaskList().get(i).startTime, CREATE_TASK, loadGeneratorModel.getTaskList().get(i));
|
||||
|
||||
//Periodic event loops starts from here!
|
||||
schedule(getId(), 5, CHECK_ALL_VM);
|
||||
schedule(getId(), SimSettings.getInstance().getSimulationTime()/100, PRINT_PROGRESS);
|
||||
schedule(getId(), SimSettings.getInstance().getVmLoadLogInterval(), GET_LOAD_LOG);
|
||||
schedule(getId(), SimSettings.getInstance().getSimulationTime(), STOP_SIMULATION);
|
||||
|
||||
SimLogger.printLine("Done.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processEvent(SimEvent ev) {
|
||||
synchronized(this){
|
||||
switch (ev.getTag()) {
|
||||
case CREATE_TASK:
|
||||
try {
|
||||
EdgeTask edgeTask = (EdgeTask) ev.getData();
|
||||
mobileDeviceManager.submitTask(edgeTask);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(0);
|
||||
}
|
||||
break;
|
||||
case CHECK_ALL_VM:
|
||||
int totalNumOfVm = SimSettings.getInstance().getNumOfEdgeVMs();
|
||||
if(VmAllocationPolicy_Custom.getCreatedVmNum() != totalNumOfVm){
|
||||
SimLogger.printLine("All VMs cannot be created! Terminating simulation...");
|
||||
System.exit(0);
|
||||
}
|
||||
break;
|
||||
case GET_LOAD_LOG:
|
||||
SimLogger.getInstance().addVmUtilizationLog(CloudSim.clock(),edgeServerManager.getAvgUtilization());
|
||||
schedule(getId(), SimSettings.getInstance().getVmLoadLogInterval(), GET_LOAD_LOG);
|
||||
break;
|
||||
case PRINT_PROGRESS:
|
||||
int progress = (int)((CloudSim.clock()*100)/SimSettings.getInstance().getSimulationTime());
|
||||
if(progress % 10 == 0)
|
||||
SimLogger.print(Integer.toString(progress));
|
||||
else
|
||||
SimLogger.print(".");
|
||||
if(CloudSim.clock() < SimSettings.getInstance().getSimulationTime())
|
||||
schedule(getId(), SimSettings.getInstance().getSimulationTime()/100, PRINT_PROGRESS);
|
||||
break;
|
||||
case STOP_SIMULATION:
|
||||
SimLogger.printLine("100");
|
||||
CloudSim.terminateSimulation();
|
||||
try {
|
||||
SimLogger.getInstance().simStopped();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
System.exit(0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Log.printLine(getName() + ": unknown event type");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdownEntity() {
|
||||
edgeServerManager.terminateDatacenters();
|
||||
}
|
||||
}
|
||||
490
src/edu/boun/edgecloudsim/core/SimSettings.java
Normal file
490
src/edu/boun/edgecloudsim/core/SimSettings.java
Normal file
@@ -0,0 +1,490 @@
|
||||
/*
|
||||
* Title: EdgeCloudSim - Simulation Settings class
|
||||
*
|
||||
* Description:
|
||||
* SimSettings provides system wide simulation settings. It is a
|
||||
* singleton class and provides all necessary information to other modules.
|
||||
* If you need to use another simulation setting variable in your
|
||||
* config file, add related getter methot in this class.
|
||||
*
|
||||
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
|
||||
* Copyright (c) 2017, Bogazici University, Istanbul, Turkey
|
||||
*/
|
||||
|
||||
package edu.boun.edgecloudsim.core;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import edu.boun.edgecloudsim.utils.SimLogger;
|
||||
|
||||
public class SimSettings {
|
||||
private static SimSettings instance = null;
|
||||
private Document edgeDevicesDoc = null;
|
||||
|
||||
//enumarations for the scenarion, VM, appplication, and place.
|
||||
//if you want to add different types on your config file,
|
||||
//you may modify current types or add new types here.
|
||||
public static enum VM_TYPES { EDGE_VM, CLOUD_VM }
|
||||
public static enum APP_TYPES { FACE_REC_APP, HEALTH_APP, HEAVY_COMP_APP, VIDEO_GAME_APP, SIMPLE_SERVICE_APP }
|
||||
public static enum PLACE_TYPES { ATTRACTIVENESS_L1, ATTRACTIVENESS_L2, ATTRACTIVENESS_L3 }
|
||||
public static enum SCENARIO_TYPES { SINGLE_TIER, TWO_TIER, TWO_TIER_WITH_EO }
|
||||
|
||||
//predifined ID for cloud components.
|
||||
public static int CLOUD_DATACENTER_ID = 1000;
|
||||
public static int CLOUD_HOST_ID = CLOUD_DATACENTER_ID + 1;
|
||||
public static int CLOUD_VM_ID = CLOUD_DATACENTER_ID + 2;
|
||||
|
||||
//delimiter for output file.
|
||||
public static String DELIMITER = ";";
|
||||
|
||||
private double SIMULATION_TIME; //hours unit in properties file
|
||||
private double WARM_UP_PERIOD; //seconds unit in properties file
|
||||
private double INTERVAL_TO_GET_VM_LOAD_LOG; //seconds unit in properties file
|
||||
private double INTERVAL_TO_GET_VM_LOCATION_LOG; //seconds unit in properties file
|
||||
private boolean DEEP_FILE_LOG_ENABLED; //used for each success failed task
|
||||
|
||||
private int MIN_NUM_OF_MOBILE_DEVICES;
|
||||
private int MAX_NUM_OF_MOBILE_DEVICES;
|
||||
private int MOBILE_DEVICE_COUNTER_SIZE;
|
||||
|
||||
private int NUM_OF_EDGE_DATACENTERS;
|
||||
private int NUM_OF_EDGE_HOSTS;
|
||||
private int NUM_OF_EDGE_VMS;
|
||||
|
||||
private double WAN_PROPOGATION_DELAY; //seconds unit in properties file
|
||||
private double LAN_INTERNAL_DELAY; //seconds unit in properties file
|
||||
private int BANDWITH_WLAN; //Mbps unit in properties file
|
||||
private int BANDWITH_WAN; //Mbps unit in properties file
|
||||
private int BANDWITH_GSM; //Mbps unit in properties file
|
||||
|
||||
private int MIPS_FOR_CLOUD; //MIPS
|
||||
|
||||
private String ORCHESTRATOR_POLICY;
|
||||
|
||||
// mean waiting time (minute) is stored for each place types
|
||||
private double[] mobilityLookUpTable;
|
||||
|
||||
// following values are stored for each applications defined in applications.xml
|
||||
// [0] usage percentage (%)
|
||||
// [1] prob. of selecting cloud (%)
|
||||
// [2] poisson mean (sec)
|
||||
// [3] active period (sec)
|
||||
// [4] idle period (sec)
|
||||
// [5] avg data upload (KB)
|
||||
// [6] avg data download (KB)
|
||||
// [7] avg task length (MI)
|
||||
// [8] required # of cores
|
||||
// [9] vm utilization (%)
|
||||
private double[][] taskLookUpTable = new double[APP_TYPES.values().length][10];
|
||||
|
||||
private SimSettings() {
|
||||
}
|
||||
|
||||
public static SimSettings getInstance() {
|
||||
if(instance == null) {
|
||||
instance = new SimSettings();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads configuration file and stores information to local variables
|
||||
* @param propertiesFile
|
||||
* @return
|
||||
*/
|
||||
public boolean initialize(String propertiesFile, String edgeDevicesFile, String applicationsFile){
|
||||
boolean result = false;
|
||||
InputStream input = null;
|
||||
try {
|
||||
input = new FileInputStream(propertiesFile);
|
||||
|
||||
// load a properties file
|
||||
Properties prop = new Properties();
|
||||
prop.load(input);
|
||||
|
||||
SIMULATION_TIME = 3600 * Double.parseDouble(prop.getProperty("simulation_time")); //hours
|
||||
WARM_UP_PERIOD = Double.parseDouble(prop.getProperty("warm_up_period")); //seconds
|
||||
INTERVAL_TO_GET_VM_LOAD_LOG = Double.parseDouble(prop.getProperty("vm_load_check_interval")); //seconds
|
||||
INTERVAL_TO_GET_VM_LOCATION_LOG = Double.parseDouble(prop.getProperty("vm_location_check_interval")); //seconds
|
||||
DEEP_FILE_LOG_ENABLED = Boolean.parseBoolean(prop.getProperty("deep_file_log_enabled"));
|
||||
|
||||
MIN_NUM_OF_MOBILE_DEVICES = Integer.parseInt(prop.getProperty("min_number_of_mobile_devices"));
|
||||
MAX_NUM_OF_MOBILE_DEVICES = Integer.parseInt(prop.getProperty("max_number_of_mobile_devices"));
|
||||
MOBILE_DEVICE_COUNTER_SIZE = Integer.parseInt(prop.getProperty("mobile_device_counter_size"));
|
||||
|
||||
WAN_PROPOGATION_DELAY = Double.parseDouble(prop.getProperty("wan_propogation_delay"));
|
||||
LAN_INTERNAL_DELAY = Double.parseDouble(prop.getProperty("lan_internal_delay"));
|
||||
BANDWITH_WLAN = 1000 * Integer.parseInt(prop.getProperty("wlan_bandwidth"));
|
||||
BANDWITH_WAN = 1000 * Integer.parseInt(prop.getProperty("wan_bandwidth"));
|
||||
BANDWITH_GSM = 1000 * Integer.parseInt(prop.getProperty("gsm_bandwidth"));
|
||||
|
||||
//It is assumed that
|
||||
//-Storage and RAM are unlimited in cloud
|
||||
//-Each task is executed with maximum capacity (as if there is no task in the cloud)
|
||||
MIPS_FOR_CLOUD = Integer.parseInt(prop.getProperty("mips_for_cloud"));
|
||||
|
||||
ORCHESTRATOR_POLICY = prop.getProperty("task_provisioning");
|
||||
|
||||
//avg waiting time in a place (min)
|
||||
double place1_mean_waiting_time = Double.parseDouble(prop.getProperty("attractiveness_L1_mean_waiting_time"));
|
||||
double place2_mean_waiting_time = Double.parseDouble(prop.getProperty("attractiveness_L2_mean_waiting_time"));
|
||||
double place3_mean_waiting_time = Double.parseDouble(prop.getProperty("attractiveness_L3_mean_waiting_time"));
|
||||
|
||||
//mean waiting time (minute)
|
||||
mobilityLookUpTable = new double[]{
|
||||
place1_mean_waiting_time, //ATTRACTIVENESS_L1
|
||||
place2_mean_waiting_time, //ATTRACTIVENESS_L2
|
||||
place3_mean_waiting_time //ATTRACTIVENESS_L3
|
||||
};
|
||||
|
||||
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
if (input != null) {
|
||||
try {
|
||||
input.close();
|
||||
result = true;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
parseApplicatinosXML(applicationsFile);
|
||||
parseEdgeDevicesXML(edgeDevicesFile);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the parsed XML document for edge_devices.xml
|
||||
*/
|
||||
public Document getEdgeDevicesDocument(){
|
||||
return edgeDevicesDoc;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* returns simulation time (in hours unit) from properties file
|
||||
*/
|
||||
public double getSimulationTime()
|
||||
{
|
||||
return SIMULATION_TIME;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns warm up period (in seconds unit) from properties file
|
||||
*/
|
||||
public double getWarmUpPeriod()
|
||||
{
|
||||
return WARM_UP_PERIOD;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns VM utilization log collection interval (in seconds unit) from properties file
|
||||
*/
|
||||
public double getVmLoadLogInterval()
|
||||
{
|
||||
return INTERVAL_TO_GET_VM_LOAD_LOG;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns VM location log collection interval (in seconds unit) from properties file
|
||||
*/
|
||||
public double getVmLocationLogInterval()
|
||||
{
|
||||
return INTERVAL_TO_GET_VM_LOCATION_LOG;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns deep statistics logging status from properties file
|
||||
*/
|
||||
public boolean getDeepFileLoggingEnabled()
|
||||
{
|
||||
return DEEP_FILE_LOG_ENABLED;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns WAN propogation delay (in second unit) from properties file
|
||||
*/
|
||||
public double getWanPropogationDelay()
|
||||
{
|
||||
return WAN_PROPOGATION_DELAY;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns internal LAN propogation delay (in second unit) from properties file
|
||||
*/
|
||||
public double getInternalLanDelay()
|
||||
{
|
||||
return LAN_INTERNAL_DELAY;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns WLAN bandwidth (in Mbps unit) from properties file
|
||||
*/
|
||||
public int getWlanBandwidth()
|
||||
{
|
||||
return BANDWITH_WLAN;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns WAN bandwidth (in Mbps unit) from properties file
|
||||
*/
|
||||
public int getWanBandwidth()
|
||||
{
|
||||
return BANDWITH_WAN;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns GSM bandwidth (in Mbps unit) from properties file
|
||||
*/
|
||||
public int getGsmBandwidth()
|
||||
{
|
||||
return BANDWITH_GSM;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the minimum number of the mobile devices used in the simulation
|
||||
*/
|
||||
public int getMinNumOfMobileDev()
|
||||
{
|
||||
return MIN_NUM_OF_MOBILE_DEVICES;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the maximunm number of the mobile devices used in the simulation
|
||||
*/
|
||||
public int getMaxNumOfMobileDev()
|
||||
{
|
||||
return MAX_NUM_OF_MOBILE_DEVICES;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the number of increase on mobile devices
|
||||
* while iterating from min to max mobile device
|
||||
*/
|
||||
public int getMobileDevCounterSize()
|
||||
{
|
||||
return MOBILE_DEVICE_COUNTER_SIZE;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the number of edge datacenters
|
||||
*/
|
||||
public int getNumOfEdgeDatacenters()
|
||||
{
|
||||
return NUM_OF_EDGE_DATACENTERS;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the number of edge hosts running on the datacenters
|
||||
*/
|
||||
public int getNumOfEdgeHosts()
|
||||
{
|
||||
return NUM_OF_EDGE_HOSTS;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the number of edge VMs running on the hosts
|
||||
*/
|
||||
public int getNumOfEdgeVMs()
|
||||
{
|
||||
return NUM_OF_EDGE_VMS;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns MIPS of the central cloud
|
||||
*/
|
||||
public int getMipsForCloud()
|
||||
{
|
||||
return MIPS_FOR_CLOUD;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns orchestrator policy as string
|
||||
*/
|
||||
public String getOrchestratorPolicy()
|
||||
{
|
||||
return ORCHESTRATOR_POLICY;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns mobility characteristic within an array
|
||||
* the result includes mean waiting time (minute) or each place type
|
||||
*/
|
||||
public double[] getMobilityLookUpTable()
|
||||
{
|
||||
return mobilityLookUpTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns application characteristic within two dimensional array
|
||||
* the result includes the following values for each application type
|
||||
* [0] usage percentage (%)
|
||||
* [1] prob. of selecting cloud (%)
|
||||
* [2] poisson mean (sec)
|
||||
* [3] active period (sec)
|
||||
* [4] idle period (sec)
|
||||
* [5] avg data upload (KB)
|
||||
* [6] avg data download (KB)
|
||||
* [7] avg task length (MI)
|
||||
* [8] required # of cores
|
||||
* [9] vm utilization (%)
|
||||
*/
|
||||
public double[][] getTaskLookUpTable()
|
||||
{
|
||||
return taskLookUpTable;
|
||||
}
|
||||
|
||||
private void isAttribtuePresent(Element element, String key) {
|
||||
String value = element.getAttribute(key);
|
||||
if (value.isEmpty() || value == null){
|
||||
throw new IllegalArgumentException("Attribure '" + key + "' is not found in '" + element.getNodeName() +"'");
|
||||
}
|
||||
}
|
||||
|
||||
private void isElementPresent(Element element, String key) {
|
||||
try {
|
||||
String value = element.getElementsByTagName(key).item(0).getTextContent();
|
||||
if (value.isEmpty() || value == null){
|
||||
throw new IllegalArgumentException("Element '" + key + "' is not found in '" + element.getNodeName() +"'");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException("Element '" + key + "' is not found in '" + element.getNodeName() +"'");
|
||||
}
|
||||
}
|
||||
|
||||
private void parseApplicatinosXML(String filePath)
|
||||
{
|
||||
Document doc = null;
|
||||
try {
|
||||
File devicesFile = new File(filePath);
|
||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
||||
doc = dBuilder.parse(devicesFile);
|
||||
doc.getDocumentElement().normalize();
|
||||
|
||||
NodeList appList = doc.getElementsByTagName("application");
|
||||
for (int i = 0; i < appList.getLength(); i++) {
|
||||
Node appNode = appList.item(i);
|
||||
|
||||
Element appElement = (Element) appNode;
|
||||
isAttribtuePresent(appElement, "name");
|
||||
isElementPresent(appElement, "usage_percentage");
|
||||
isElementPresent(appElement, "prob_cloud_selection");
|
||||
isElementPresent(appElement, "poisson_interarrival");
|
||||
isElementPresent(appElement, "active_period");
|
||||
isElementPresent(appElement, "idle_period");
|
||||
isElementPresent(appElement, "data_upload");
|
||||
isElementPresent(appElement, "data_download");
|
||||
isElementPresent(appElement, "task_length");
|
||||
isElementPresent(appElement, "required_core");
|
||||
isElementPresent(appElement, "vm_utilization");
|
||||
|
||||
String appName = appElement.getAttribute("name");
|
||||
SimSettings.APP_TYPES appType = APP_TYPES.valueOf(appName);
|
||||
double usage_percentage = Double.parseDouble(appElement.getElementsByTagName("usage_percentage").item(0).getTextContent());
|
||||
double prob_cloud_selection = Double.parseDouble(appElement.getElementsByTagName("prob_cloud_selection").item(0).getTextContent());
|
||||
double poisson_interarrival = Double.parseDouble(appElement.getElementsByTagName("poisson_interarrival").item(0).getTextContent());
|
||||
double active_period = Double.parseDouble(appElement.getElementsByTagName("active_period").item(0).getTextContent());
|
||||
double idle_period = Double.parseDouble(appElement.getElementsByTagName("idle_period").item(0).getTextContent());
|
||||
double data_upload = Double.parseDouble(appElement.getElementsByTagName("data_upload").item(0).getTextContent());
|
||||
double data_download = Double.parseDouble(appElement.getElementsByTagName("data_download").item(0).getTextContent());
|
||||
double task_length = Double.parseDouble(appElement.getElementsByTagName("task_length").item(0).getTextContent());
|
||||
double required_core = Double.parseDouble(appElement.getElementsByTagName("required_core").item(0).getTextContent());
|
||||
double vm_utilization = Double.parseDouble(appElement.getElementsByTagName("vm_utilization").item(0).getTextContent());
|
||||
|
||||
taskLookUpTable[appType.ordinal()][0] = usage_percentage; //usage percentage (%)
|
||||
taskLookUpTable[appType.ordinal()][1] = prob_cloud_selection; //prob. of selecting cloud (%)
|
||||
taskLookUpTable[appType.ordinal()][2] = poisson_interarrival; //poisson mean (sec)
|
||||
taskLookUpTable[appType.ordinal()][3] = active_period; //active period (sec)
|
||||
taskLookUpTable[appType.ordinal()][4] = idle_period; //idle period (sec)
|
||||
taskLookUpTable[appType.ordinal()][5] = data_upload; //avg data upload (KB)
|
||||
taskLookUpTable[appType.ordinal()][6] = data_download; //avg data download (KB)
|
||||
taskLookUpTable[appType.ordinal()][7] = task_length; //avg task length (MI)
|
||||
taskLookUpTable[appType.ordinal()][8] = required_core; //required # of core
|
||||
taskLookUpTable[appType.ordinal()][9] = vm_utilization; //vm utilization (%)
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
SimLogger.printLine("Edge Devices XML cannot be parsed! Terminating simulation...");
|
||||
e.printStackTrace();
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
private void parseEdgeDevicesXML(String filePath)
|
||||
{
|
||||
try {
|
||||
File devicesFile = new File(filePath);
|
||||
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
|
||||
edgeDevicesDoc = dBuilder.parse(devicesFile);
|
||||
edgeDevicesDoc.getDocumentElement().normalize();
|
||||
|
||||
NodeList datacenterList = edgeDevicesDoc.getElementsByTagName("datacenter");
|
||||
for (int i = 0; i < datacenterList.getLength(); i++) {
|
||||
NUM_OF_EDGE_DATACENTERS++;
|
||||
Node datacenterNode = datacenterList.item(i);
|
||||
|
||||
Element datacenterElement = (Element) datacenterNode;
|
||||
isAttribtuePresent(datacenterElement, "arch");
|
||||
isAttribtuePresent(datacenterElement, "os");
|
||||
isAttribtuePresent(datacenterElement, "vmm");
|
||||
isElementPresent(datacenterElement, "costPerBw");
|
||||
isElementPresent(datacenterElement, "costPerSec");
|
||||
isElementPresent(datacenterElement, "costPerMem");
|
||||
isElementPresent(datacenterElement, "costPerStorage");
|
||||
|
||||
Element location = (Element)datacenterElement.getElementsByTagName("location").item(0);
|
||||
isElementPresent(location, "attractiveness");
|
||||
isElementPresent(location, "wlan_id");
|
||||
isElementPresent(location, "x_pos");
|
||||
isElementPresent(location, "y_pos");
|
||||
|
||||
NodeList hostList = datacenterElement.getElementsByTagName("host");
|
||||
for (int j = 0; j < hostList.getLength(); j++) {
|
||||
NUM_OF_EDGE_HOSTS++;
|
||||
Node hostNode = hostList.item(j);
|
||||
|
||||
Element hostElement = (Element) hostNode;
|
||||
isElementPresent(hostElement, "core");
|
||||
isElementPresent(hostElement, "mips");
|
||||
isElementPresent(hostElement, "ram");
|
||||
isElementPresent(hostElement, "storage");
|
||||
|
||||
NodeList vmList = hostElement.getElementsByTagName("VM");
|
||||
for (int k = 0; k < vmList.getLength(); k++) {
|
||||
NUM_OF_EDGE_VMS++;
|
||||
Node vmNode = vmList.item(k);
|
||||
|
||||
Element vmElement = (Element) vmNode;
|
||||
isAttribtuePresent(vmElement, "vmm");
|
||||
isElementPresent(vmElement, "core");
|
||||
isElementPresent(vmElement, "mips");
|
||||
isElementPresent(vmElement, "ram");
|
||||
isElementPresent(vmElement, "storage");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
SimLogger.printLine("Edge Devices XML cannot be parsed! Terminating simulation...");
|
||||
e.printStackTrace();
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user