Commit 8a508691 authored by Anton Beloglazov's avatar Anton Beloglazov

Fixed the examples of the MAD policy with a random workload

parent 350e61ea
...@@ -14,14 +14,13 @@ import org.cloudbus.cloudsim.VmAllocationPolicy; ...@@ -14,14 +14,13 @@ import org.cloudbus.cloudsim.VmAllocationPolicy;
import org.cloudbus.cloudsim.core.CloudSim; import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.power.PowerDatacenter; import org.cloudbus.cloudsim.power.PowerDatacenter;
import org.cloudbus.cloudsim.power.PowerHost; import org.cloudbus.cloudsim.power.PowerHost;
import org.cloudbus.cloudsim.power.PowerVmAllocationPolicySimple;
import org.cloudbus.cloudsim.power.PowerVmAllocationPolicyMigrationAbstract; import org.cloudbus.cloudsim.power.PowerVmAllocationPolicyMigrationAbstract;
import org.cloudbus.cloudsim.power.PowerVmAllocationPolicyMigrationInterQuartileRange; import org.cloudbus.cloudsim.power.PowerVmAllocationPolicyMigrationInterQuartileRange;
import org.cloudbus.cloudsim.power.PowerVmAllocationPolicyMigrationLocalRegression; import org.cloudbus.cloudsim.power.PowerVmAllocationPolicyMigrationLocalRegression;
import org.cloudbus.cloudsim.power.PowerVmAllocationPolicyMigrationLocalRegressionRobust; import org.cloudbus.cloudsim.power.PowerVmAllocationPolicyMigrationLocalRegressionRobust;
import org.cloudbus.cloudsim.power.PowerVmAllocationPolicyMigrationMedianAbsoluteDeviation; import org.cloudbus.cloudsim.power.PowerVmAllocationPolicyMigrationMedianAbsoluteDeviation;
import org.cloudbus.cloudsim.power.PowerVmAllocationPolicyMigrationMedianAbsoluteDeviation2;
import org.cloudbus.cloudsim.power.PowerVmAllocationPolicyMigrationStaticThreshold; import org.cloudbus.cloudsim.power.PowerVmAllocationPolicyMigrationStaticThreshold;
import org.cloudbus.cloudsim.power.PowerVmAllocationPolicySimple;
import org.cloudbus.cloudsim.power.PowerVmSelectionPolicy; import org.cloudbus.cloudsim.power.PowerVmSelectionPolicy;
import org.cloudbus.cloudsim.power.PowerVmSelectionPolicyMaximumCorrelation; import org.cloudbus.cloudsim.power.PowerVmSelectionPolicyMaximumCorrelation;
import org.cloudbus.cloudsim.power.PowerVmSelectionPolicyMinimumMigrationTime; import org.cloudbus.cloudsim.power.PowerVmSelectionPolicyMinimumMigrationTime;
...@@ -246,16 +245,6 @@ public abstract class RunnerAbstract { ...@@ -246,16 +245,6 @@ public abstract class RunnerAbstract {
vmSelectionPolicy, vmSelectionPolicy,
parameter, parameter,
fallbackVmSelectionPolicy); fallbackVmSelectionPolicy);
} else if (vmAllocationPolicyName.equals("mad2")) {
PowerVmAllocationPolicyMigrationAbstract fallbackVmSelectionPolicy = new PowerVmAllocationPolicyMigrationStaticThreshold(
hostList,
vmSelectionPolicy,
0.7);
vmAllocationPolicy = new PowerVmAllocationPolicyMigrationMedianAbsoluteDeviation2(
hostList,
vmSelectionPolicy,
parameter,
fallbackVmSelectionPolicy);
} else if (vmAllocationPolicyName.equals("lr")) { } else if (vmAllocationPolicyName.equals("lr")) {
PowerVmAllocationPolicyMigrationAbstract fallbackVmSelectionPolicy = new PowerVmAllocationPolicyMigrationStaticThreshold( PowerVmAllocationPolicyMigrationAbstract fallbackVmSelectionPolicy = new PowerVmAllocationPolicyMigrationStaticThreshold(
hostList, hostList,
......
...@@ -34,7 +34,7 @@ public class IqrMc { ...@@ -34,7 +34,7 @@ public class IqrMc {
String outputFolder = ""; String outputFolder = "";
String workload = "random"; // Random workload String workload = "random"; // Random workload
String vmAllocationPolicy = "iqr"; // Inter Quartile Range VM allocation policy String vmAllocationPolicy = "iqr"; // Inter Quartile Range VM allocation policy
String vmSelectionPolicy = "mc"; // Maximum Correlation VM selection policy String vmSelectionPolicy = "mc"; // Maximum Correlation (MC) VM selection policy
String parameter = "1.5"; // the safety parameter of the IQR policy String parameter = "1.5"; // the safety parameter of the IQR policy
new RandomRunner( new RandomRunner(
......
...@@ -34,7 +34,7 @@ public class IqrMmt { ...@@ -34,7 +34,7 @@ public class IqrMmt {
String outputFolder = ""; String outputFolder = "";
String workload = "random"; // Random workload String workload = "random"; // Random workload
String vmAllocationPolicy = "iqr"; // Inter Quartile Range VM allocation policy String vmAllocationPolicy = "iqr"; // Inter Quartile Range VM allocation policy
String vmSelectionPolicy = "mmt"; // Minimum Migration Time VM selection policy String vmSelectionPolicy = "mmt"; // Minimum Migration Time (MMT) VM selection policy
String parameter = "1.5"; // the safety parameter of the IQR policy String parameter = "1.5"; // the safety parameter of the IQR policy
new RandomRunner( new RandomRunner(
......
...@@ -34,7 +34,7 @@ public class IqrMu { ...@@ -34,7 +34,7 @@ public class IqrMu {
String outputFolder = ""; String outputFolder = "";
String workload = "random"; // Random workload String workload = "random"; // Random workload
String vmAllocationPolicy = "iqr"; // Inter Quartile Range VM allocation policy String vmAllocationPolicy = "iqr"; // Inter Quartile Range VM allocation policy
String vmSelectionPolicy = "mu"; // Minimum Utilization VM selection policy String vmSelectionPolicy = "mu"; // Minimum Utilization (MU) VM selection policy
String parameter = "1.5"; // the safety parameter of the IQR policy String parameter = "1.5"; // the safety parameter of the IQR policy
new RandomRunner( new RandomRunner(
......
...@@ -34,7 +34,7 @@ public class IqrRs { ...@@ -34,7 +34,7 @@ public class IqrRs {
String outputFolder = ""; String outputFolder = "";
String workload = "random"; // Random workload String workload = "random"; // Random workload
String vmAllocationPolicy = "iqr"; // Inter Quartile Range VM allocation policy String vmAllocationPolicy = "iqr"; // Inter Quartile Range VM allocation policy
String vmSelectionPolicy = "rs"; // Random Selection VM selection policy String vmSelectionPolicy = "rs"; // Random Selection (RS) VM selection policy
String parameter = "1.5"; // the safety parameter of the IQR policy String parameter = "1.5"; // the safety parameter of the IQR policy
new RandomRunner( new RandomRunner(
......
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.PowerVmAllocationPolicyMigrationMedianAbsoluteDeviation;
import org.cloudbus.cloudsim.power.PowerVmSelectionPolicyMaximumCorrelation;
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 Median Absolute
* the time. * Deviation (MAD) VM allocation policy and Maximum Correlation (MC) 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 MadMc { public class MadMc {
/** /**
* 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 = "mad_mc_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 = "mad"; // Median Absolute Deviation VM allocation policy
try { String vmSelectionPolicy = "mc"; // Maximum Correlation (MC) VM selection policy
CloudSim.init(1, Calendar.getInstance(), false); String parameter = "2.5"; // the safety parameter of the MAD 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, parameter);
new PowerVmAllocationPolicyMigrationMedianAbsoluteDeviation(hostList,
new PowerVmSelectionPolicyMaximumCorrelation(
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("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.PowerVmAllocationPolicyMigrationMedianAbsoluteDeviation;
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 Median Absolute
* the time. * Deviation (MAD) 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 MadMmt { public class MadMmt {
/** /**
* 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 = "mad_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 = "mad"; // Median Absolute Deviation VM allocation policy
try { String vmSelectionPolicy = "mmt"; // Minimum Migration Time (MMT) VM selection policy
CloudSim.init(1, Calendar.getInstance(), false); String parameter = "2.5"; // the safety parameter of the MAD 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, parameter);
new PowerVmAllocationPolicyMigrationMedianAbsoluteDeviation(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.PowerVmAllocationPolicyMigrationMedianAbsoluteDeviation;
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 Median Absolute
* the time. * Deviation (MAD) 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 MadMu { public class MadMu {
/** /**
* 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 = "mad_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 = "mad"; // Median Absolute Deviation VM allocation policy
try { String vmSelectionPolicy = "mu"; // Minimum Utilization (MU) VM selection policy
CloudSim.init(1, Calendar.getInstance(), false); String parameter = "2.5"; // the safety parameter of the MAD 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, parameter);
new PowerVmAllocationPolicyMigrationMedianAbsoluteDeviation(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.PowerVmAllocationPolicyMigrationMedianAbsoluteDeviation;
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 Median Absolute
* the time. * Deviation (MAD) 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 MadRs { public class MadRs {
/** /**
* 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 = "mad_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 = "mad"; // Median Absolute Deviation VM allocation policy
try { String vmSelectionPolicy = "rs"; // Random Selection (RS) VM selection policy
CloudSim.init(1, Calendar.getInstance(), false); String parameter = "2.5"; // the safety parameter of the MAD 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, parameter);
new PowerVmAllocationPolicyMigrationMedianAbsoluteDeviation(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("Unwanted errors happen");
}
Log.printLine("Finished " + experimentName);
} }
} }
...@@ -34,7 +34,7 @@ public class ThrMc { ...@@ -34,7 +34,7 @@ public class ThrMc {
String outputFolder = ""; String outputFolder = "";
String workload = "random"; // Random workload String workload = "random"; // Random workload
String vmAllocationPolicy = "thr"; // Static Threshold VM allocation policy String vmAllocationPolicy = "thr"; // Static Threshold VM allocation policy
String vmSelectionPolicy = "mc"; // Maximum Correlation VM selection policy String vmSelectionPolicy = "mc"; // Maximum Correlation (MC) VM selection policy
String parameter = "0.8"; // the static utilization threshold String parameter = "0.8"; // the static utilization threshold
new RandomRunner( new RandomRunner(
......
...@@ -34,7 +34,7 @@ public class ThrMmt { ...@@ -34,7 +34,7 @@ public class ThrMmt {
String outputFolder = ""; String outputFolder = "";
String workload = "random"; // Random workload String workload = "random"; // Random workload
String vmAllocationPolicy = "thr"; // Static Threshold VM allocation policy String vmAllocationPolicy = "thr"; // Static Threshold VM allocation policy
String vmSelectionPolicy = "mmt"; // Minimum Migration Time VM selection policy String vmSelectionPolicy = "mmt"; // Minimum Migration Time (MMT) VM selection policy
String parameter = "0.8"; // the static utilization threshold String parameter = "0.8"; // the static utilization threshold
new RandomRunner( new RandomRunner(
......
...@@ -34,7 +34,7 @@ public class ThrMu { ...@@ -34,7 +34,7 @@ public class ThrMu {
String outputFolder = ""; String outputFolder = "";
String workload = "random"; // Random workload String workload = "random"; // Random workload
String vmAllocationPolicy = "thr"; // Static Threshold VM allocation policy String vmAllocationPolicy = "thr"; // Static Threshold VM allocation policy
String vmSelectionPolicy = "mu"; // Minimum Utilization VM selection policy String vmSelectionPolicy = "mu"; // Minimum Utilization (MU) VM selection policy
String parameter = "0.8"; // the static utilization threshold String parameter = "0.8"; // the static utilization threshold
new RandomRunner( new RandomRunner(
......
...@@ -34,7 +34,7 @@ public class ThrRs { ...@@ -34,7 +34,7 @@ public class ThrRs {
String outputFolder = ""; String outputFolder = "";
String workload = "random"; // Random workload String workload = "random"; // Random workload
String vmAllocationPolicy = "thr"; // Static Threshold VM allocation policy String vmAllocationPolicy = "thr"; // Static Threshold VM allocation policy
String vmSelectionPolicy = "rs"; // Random Selection VM selection policy String vmSelectionPolicy = "rs"; // Random Selection (RS) VM selection policy
String parameter = "0.8"; // the static utilization threshold String parameter = "0.8"; // the static utilization threshold
new RandomRunner( new RandomRunner(
......
package org.cloudbus.cloudsim.power;
import java.util.Arrays;
import java.util.List;
import org.cloudbus.cloudsim.Host;
import org.cloudbus.cloudsim.Log;
import org.cloudbus.cloudsim.Vm;
import org.cloudbus.cloudsim.core.CloudSim;
import org.cloudbus.cloudsim.util.MathUtil;
/**
* The Class PowerVmAllocationPolicyMigrationMad.
*/
public class PowerVmAllocationPolicyMigrationMedianAbsoluteDeviation2 extends
PowerVmAllocationPolicyMigrationAbstract {
/** The safety parameter. */
private double safetyParameter = 0;
/** The fallback vm allocation policy. */
private PowerVmAllocationPolicyMigrationAbstract fallbackVmAllocationPolicy;
/**
* Instantiates a new power vm allocation policy migration mad.
*
* @param hostList the host list
* @param vmSelectionPolicy the vm selection policy
* @param safetyParameter the safety parameter
* @param utilizationThreshold the utilization threshold
*/
public PowerVmAllocationPolicyMigrationMedianAbsoluteDeviation2(
List<? extends Host> hostList,
PowerVmSelectionPolicy vmSelectionPolicy,
double safetyParameter,
PowerVmAllocationPolicyMigrationAbstract fallbackVmAllocationPolicy,
double utilizationThreshold) {
super(hostList, vmSelectionPolicy);
setSafetyParameter(safetyParameter);
setFallbackVmAllocationPolicy(fallbackVmAllocationPolicy);
}
/**
* Instantiates a new power vm allocation policy migration mad.
*
* @param hostList the host list
* @param vmSelectionPolicy the vm selection policy
* @param safetyParameter the safety parameter
*/
public PowerVmAllocationPolicyMigrationMedianAbsoluteDeviation2(
List<? extends Host> hostList,
PowerVmSelectionPolicy vmSelectionPolicy,
double safetyParameter,
PowerVmAllocationPolicyMigrationAbstract fallbackVmAllocationPolicy) {
super(hostList, vmSelectionPolicy);
setSafetyParameter(safetyParameter);
setFallbackVmAllocationPolicy(fallbackVmAllocationPolicy);
}
/**
* Checks if is host over utilized.
*
* @param _host the _host
* @return true, if is host over utilized
*/
@Override
protected boolean isHostOverUtilized(PowerHost host) {
PowerHostUtilizationHistory _host = (PowerHostUtilizationHistory) host;
if (CloudSim.clock() == 5400 && host.getId() == 81) {
Log.printLine();
}
double upperThreshold = 0;
try {
upperThreshold = getSafetyParameter() - getHostUtilizationMad(_host);
} catch (IllegalArgumentException e) {
return getFallbackVmAllocationPolicy().isHostOverUtilized(host);
}
addHistoryEntry(host, upperThreshold);
double totalRequestedMips = 0;
for (Vm vm : host.getVmList()) {
totalRequestedMips += vm.getCurrentRequestedTotalMips();
}
double utilization = totalRequestedMips / host.getTotalMips();
return utilization > upperThreshold;
}
/**
* Gets the host utilization mad.
*
* @param host the host
* @return the host utilization mad
*/
protected double getHostUtilizationMad(PowerHostUtilizationHistory host) throws IllegalArgumentException {
double[] data = host.getUtilizationHistory();
if (MathUtil.countNonZeroBeginning(data) >= 12) { // 12 has been suggested as a safe value
return MathUtil.mad(Arrays.copyOfRange(data, 0, 12));
}
throw new IllegalArgumentException();
}
/**
* Sets the safety parameter.
*
* @param safetyParameter the new safety parameter
*/
protected void setSafetyParameter(double safetyParameter) {
if (safetyParameter < 0) {
Log.printLine("The safety parameter cannot be less than zero. The passed value is: "
+ safetyParameter);
System.exit(0);
}
this.safetyParameter = safetyParameter;
}
/**
* Gets the safety parameter.
*
* @return the safety parameter
*/
protected double getSafetyParameter() {
return safetyParameter;
}
/**
* Sets the fallback vm allocation policy.
*
* @param fallbackVmAllocationPolicy the new fallback vm allocation policy
*/
public void setFallbackVmAllocationPolicy(
PowerVmAllocationPolicyMigrationAbstract fallbackVmAllocationPolicy) {
this.fallbackVmAllocationPolicy = fallbackVmAllocationPolicy;
}
/**
* Gets the fallback vm allocation policy.
*
* @return the fallback vm allocation policy
*/
public PowerVmAllocationPolicyMigrationAbstract getFallbackVmAllocationPolicy() {
return fallbackVmAllocationPolicy;
}
}
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