Commit 350e61ea authored by Anton Beloglazov's avatar Anton Beloglazov

Fixed the examples of the IRQ policy with a random workload

parent c73c1838
...@@ -10,7 +10,7 @@ public class Constants { ...@@ -10,7 +10,7 @@ public class Constants {
public final static boolean OUTPUT_CSV = false; public final static boolean OUTPUT_CSV = false;
public final static double SCHEDULING_INTERVAL = 300; public final static double SCHEDULING_INTERVAL = 300;
public final static double SIMULATION_LIMIT = 24 * 60 * 60; public final static double SIMULATION_LIMIT = 24 * 60 * 10;
public final static int CLOUDLET_LENGTH = 2500 * (int) SIMULATION_LIMIT; public final static int CLOUDLET_LENGTH = 2500 * (int) SIMULATION_LIMIT;
public final static int CLOUDLET_PES = 1; public final static int CLOUDLET_PES = 1;
......
package org.cloudbus.cloudsim.examples.power.random; package org.cloudbus.cloudsim.examples.power.random;
import java.io.IOException; import java.io.IOException;
import java.util.Calendar;
import java.util.List;
import org.cloudbus.cloudsim.Cloudlet;
import org.cloudbus.cloudsim.DatacenterBroker;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.Vm;
import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.power.PowerDatacenter;
import org.cloudbus.cloudsim.power.PowerHost;
import org.cloudbus.cloudsim.power.PowerVmAllocationPolicyMigrationInterQuartileRange;
import org.cloudbus.cloudsim.power.PowerVmSelectionPolicyMinimumMigrationTime;
/** /**
* A simulation of a heterogeneous non-power aware data center: all hosts consume maximum power all * A simulation of a heterogeneous power aware data center that applies the Inter Quartile Range
* the time. * (IQR) VM allocation policy and Minimum Migration Time (MMT) VM selection policy.
*
* The remaining configuration parameters are in the Constants and RandomConstants classes.
*
* If you are using any algorithms, policies or workload included in the power package please cite
* the following paper:
*
* Anton Beloglazov, and Rajkumar Buyya, "Optimal Online Deterministic Algorithms and Adaptive
* Heuristics for Energy and Performance Efficient Dynamic Consolidation of Virtual Machines in
* Cloud Data Centers", Concurrency and Computation: Practice and Experience, ISSN: 1532-0626, Wiley
* Press, New York, USA, 2011, DOI: 10.1002/cpe.1867
*
* @author Anton Beloglazov
* @since Jan 5, 2012
*/ */
public class IqrMmt { public class IqrMmt {
/** /**
* Creates main() to run this example. * The main method.
* *
* @param args the args * @param args the arguments
* @throws IOException Signals that an I/O exception has occurred. * @throws IOException Signals that an I/O exception has occurred.
*/ */
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
String experimentName = "iqr_mmt_1"; boolean enableOutput = true;
String outputFolder = "output"; boolean outputToFile = false;
String inputFolder = "";
Log.setDisabled(!RandomConstants.ENABLE_OUTPUT); String outputFolder = "";
Log.printLine("Starting " + experimentName); String workload = "random"; // Random workload
String vmAllocationPolicy = "iqr"; // Inter Quartile Range VM allocation policy
try { String vmSelectionPolicy = "mmt"; // Minimum Migration Time VM selection policy
CloudSim.init(1, Calendar.getInstance(), false); String parameter = "1.5"; // the safety parameter of the IQR policy
DatacenterBroker broker = RandomHelper.createBroker(); new RandomRunner(
int brokerId = broker.getId(); enableOutput,
outputToFile,
List<Cloudlet> cloudletList = RandomHelper.createCloudletList(brokerId, RandomConstants.NUMBER_OF_VMS); inputFolder,
List<Vm> vmList = RandomHelper.createVmList(brokerId, cloudletList.size()); outputFolder,
List<PowerHost> hostList = RandomHelper.createHostList(RandomConstants.NUMBER_OF_HOSTS); workload,
vmAllocationPolicy,
PowerDatacenter datacenter = (PowerDatacenter) RandomHelper.createDatacenter("Datacenter", vmSelectionPolicy,
PowerDatacenter.class, hostList, new PowerVmAllocationPolicyMigrationInterQuartileRange( parameter);
hostList, new PowerVmSelectionPolicyMinimumMigrationTime(), 1), -1);
datacenter.setDisableMigrations(false);
broker.submitVmList(vmList);
broker.submitCloudletList(cloudletList);
double lastClock = CloudSim.startSimulation();
List<Cloudlet> newList = broker.getCloudletReceivedList();
Log.printLine("Received " + newList.size() + " cloudlets");
CloudSim.stopSimulation();
RandomHelper.printResults(datacenter, vmList, lastClock, experimentName, RandomConstants.OUTPUT_CSV,
outputFolder);
} catch (Exception e) {
e.printStackTrace();
Log.printLine("Unwanted errors happen");
}
Log.printLine("Finished " + experimentName);
} }
} }
package org.cloudbus.cloudsim.examples.power.random; package org.cloudbus.cloudsim.examples.power.random;
import java.io.IOException; import java.io.IOException;
import java.util.Calendar;
import java.util.List;
import org.cloudbus.cloudsim.Cloudlet;
import org.cloudbus.cloudsim.DatacenterBroker;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.Vm;
import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.power.PowerDatacenter;
import org.cloudbus.cloudsim.power.PowerHost;
import org.cloudbus.cloudsim.power.PowerVmAllocationPolicyMigrationInterQuartileRange;
import org.cloudbus.cloudsim.power.PowerVmSelectionPolicyMinimumUtilization;
/** /**
* A simulation of a heterogeneous non-power aware data center: all hosts consume maximum power all * A simulation of a heterogeneous power aware data center that applies the Inter Quartile Range
* the time. * (IQR) VM allocation policy and Minimum Utilization (MU) VM selection policy.
*
* The remaining configuration parameters are in the Constants and RandomConstants classes.
*
* If you are using any algorithms, policies or workload included in the power package please cite
* the following paper:
*
* Anton Beloglazov, and Rajkumar Buyya, "Optimal Online Deterministic Algorithms and Adaptive
* Heuristics for Energy and Performance Efficient Dynamic Consolidation of Virtual Machines in
* Cloud Data Centers", Concurrency and Computation: Practice and Experience, ISSN: 1532-0626, Wiley
* Press, New York, USA, 2011, DOI: 10.1002/cpe.1867
*
* @author Anton Beloglazov
* @since Jan 5, 2012
*/ */
public class IqrMu { public class IqrMu {
/** /**
* Creates main() to run this example. * The main method.
* *
* @param args the args * @param args the arguments
* @throws IOException Signals that an I/O exception has occurred. * @throws IOException Signals that an I/O exception has occurred.
*/ */
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
String experimentName = "iqr_mu_1"; boolean enableOutput = true;
String outputFolder = "output"; boolean outputToFile = false;
String inputFolder = "";
Log.setDisabled(!RandomConstants.ENABLE_OUTPUT); String outputFolder = "";
Log.printLine("Starting " + experimentName); String workload = "random"; // Random workload
String vmAllocationPolicy = "iqr"; // Inter Quartile Range VM allocation policy
try { String vmSelectionPolicy = "mu"; // Minimum Utilization VM selection policy
CloudSim.init(1, Calendar.getInstance(), false); String parameter = "1.5"; // the safety parameter of the IQR policy
DatacenterBroker broker = RandomHelper.createBroker(); new RandomRunner(
int brokerId = broker.getId(); enableOutput,
outputToFile,
List<Cloudlet> cloudletList = RandomHelper.createCloudletList(brokerId, RandomConstants.NUMBER_OF_VMS); inputFolder,
List<Vm> vmList = RandomHelper.createVmList(brokerId, cloudletList.size()); outputFolder,
List<PowerHost> hostList = RandomHelper.createHostList(RandomConstants.NUMBER_OF_HOSTS); workload,
vmAllocationPolicy,
PowerDatacenter datacenter = (PowerDatacenter) RandomHelper.createDatacenter("Datacenter", vmSelectionPolicy,
PowerDatacenter.class, hostList, new PowerVmAllocationPolicyMigrationInterQuartileRange( parameter);
hostList, new PowerVmSelectionPolicyMinimumUtilization(), 1), -1);
datacenter.setDisableMigrations(false);
broker.submitVmList(vmList);
broker.submitCloudletList(cloudletList);
double lastClock = CloudSim.startSimulation();
List<Cloudlet> newList = broker.getCloudletReceivedList();
Log.printLine("Received " + newList.size() + " cloudlets");
CloudSim.stopSimulation();
RandomHelper.printResults(datacenter, vmList, lastClock, experimentName, RandomConstants.OUTPUT_CSV,
outputFolder);
} catch (Exception e) {
e.printStackTrace();
Log.printLine("Unwanted errors happen");
}
Log.printLine("Finished " + experimentName);
} }
} }
package org.cloudbus.cloudsim.examples.power.random; package org.cloudbus.cloudsim.examples.power.random;
import java.io.IOException; import java.io.IOException;
import java.util.Calendar;
import java.util.List;
import org.cloudbus.cloudsim.Cloudlet;
import org.cloudbus.cloudsim.DatacenterBroker;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.Vm;
import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.power.PowerDatacenter;
import org.cloudbus.cloudsim.power.PowerHost;
import org.cloudbus.cloudsim.power.PowerVmAllocationPolicyMigrationInterQuartileRange;
import org.cloudbus.cloudsim.power.PowerVmSelectionPolicyRandomSelection;
/** /**
* A simulation of a heterogeneous non-power aware data center: all hosts consume maximum power all * A simulation of a heterogeneous power aware data center that applies the Inter Quartile Range
* the time. * (IQR) VM allocation policy and Random Selection (RS) VM selection policy.
*
* The remaining configuration parameters are in the Constants and RandomConstants classes.
*
* If you are using any algorithms, policies or workload included in the power package please cite
* the following paper:
*
* Anton Beloglazov, and Rajkumar Buyya, "Optimal Online Deterministic Algorithms and Adaptive
* Heuristics for Energy and Performance Efficient Dynamic Consolidation of Virtual Machines in
* Cloud Data Centers", Concurrency and Computation: Practice and Experience, ISSN: 1532-0626, Wiley
* Press, New York, USA, 2011, DOI: 10.1002/cpe.1867
*
* @author Anton Beloglazov
* @since Jan 5, 2012
*/ */
public class IqrRs { public class IqrRs {
/** /**
* Creates main() to run this example. * The main method.
* *
* @param args the args * @param args the arguments
* @throws IOException Signals that an I/O exception has occurred. * @throws IOException Signals that an I/O exception has occurred.
*/ */
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
String experimentName = "iqr_rs_1"; boolean enableOutput = true;
String outputFolder = "output"; boolean outputToFile = false;
String inputFolder = "";
Log.setDisabled(!RandomConstants.ENABLE_OUTPUT); String outputFolder = "";
Log.printLine("Starting " + experimentName); String workload = "random"; // Random workload
String vmAllocationPolicy = "iqr"; // Inter Quartile Range VM allocation policy
try { String vmSelectionPolicy = "rs"; // Random Selection VM selection policy
CloudSim.init(1, Calendar.getInstance(), false); String parameter = "1.5"; // the safety parameter of the IQR policy
DatacenterBroker broker = RandomHelper.createBroker(); new RandomRunner(
int brokerId = broker.getId(); enableOutput,
outputToFile,
List<Cloudlet> cloudletList = RandomHelper.createCloudletList(brokerId, RandomConstants.NUMBER_OF_VMS); inputFolder,
List<Vm> vmList = RandomHelper.createVmList(brokerId, cloudletList.size()); outputFolder,
List<PowerHost> hostList = RandomHelper.createHostList(RandomConstants.NUMBER_OF_HOSTS); workload,
vmAllocationPolicy,
PowerDatacenter datacenter = (PowerDatacenter) RandomHelper.createDatacenter("Datacenter", vmSelectionPolicy,
PowerDatacenter.class, hostList, new PowerVmAllocationPolicyMigrationInterQuartileRange( parameter);
hostList, new PowerVmSelectionPolicyRandomSelection(), 1), -1);
datacenter.setDisableMigrations(false);
broker.submitVmList(vmList);
broker.submitCloudletList(cloudletList);
double lastClock = CloudSim.startSimulation();
List<Cloudlet> newList = broker.getCloudletReceivedList();
Log.printLine("Received " + newList.size() + " cloudlets");
CloudSim.stopSimulation();
RandomHelper.printResults(datacenter, vmList, lastClock, experimentName, RandomConstants.OUTPUT_CSV,
outputFolder);
} catch (Exception e) {
e.printStackTrace();
Log.printLine("The simulation has been terminated due to an unexpected error");
}
Log.printLine("Finished " + experimentName);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment