Commit 9d9c5d63 authored by Rafael Vieira Falcão's avatar Rafael Vieira Falcão
Browse files

Modifications into Info-Aware simulation

parent d202dbca
......@@ -15,6 +15,9 @@ import org.cloudbus.cloudsim.datacenters.Datacenter;
import org.cloudbus.cloudsim.datacenters.DatacenterSimple;
import org.cloudbus.cloudsim.hosts.Host;
import org.cloudbus.cloudsim.hosts.HostSimple;
import org.cloudbus.cloudsim.power.models.PowerModel;
import org.cloudbus.cloudsim.power.models.PowerModelSpecPowerHpProLiantBL460cGen9HighPowerMode;
import org.cloudbus.cloudsim.power.models.PowerModelSpecPowerHpProLiantBL460cGen9LowPowerMode;
import org.cloudbus.cloudsim.provisioners.PeProvisionerSimple;
import org.cloudbus.cloudsim.provisioners.ResourceProvisioner;
import org.cloudbus.cloudsim.provisioners.ResourceProvisionerShared;
......@@ -38,7 +41,7 @@ import org.cloudsimplus.listeners.EventInfo;
public class InfoAwareSimulation {
private static final int SCHEDULING_INTERVAL = 0;
private static final int SCHEDULING_INTERVAL = 1;
/*
* Hosts (2) configuration
......@@ -92,9 +95,9 @@ public class InfoAwareSimulation {
*/
private static final int CLOUDLET_CPU_BOUND_ID = 1;
private static final double CLOUDLET_CPU_BOUND_DELAY = 0.0;
private static final int CLOUDLET_CPU_BOUND_LENGTH = 50000000; // CPU-Bound workload (Set a high duration time)
private static final int CLOUDLET_CPU_BOUND_LENGTH = 200000000; // CPU-Bound workload (Set a high duration time)
private static final int CLOUDLET_CPU_BOUND_PES = 1;
private static final int CLOUDLET_CPU_BOUND_IOPS = 2;
private static final int CLOUDLET_CPU_BOUND_IOPS = 3600; // 2*30*60
/*
......@@ -116,7 +119,7 @@ public class InfoAwareSimulation {
private static final double CLOUDLET_IO_BOUND_DELAY = 0.0;
private static final int CLOUDLET_IO_BOUND_LENGTH = 0;
private static final int CLOUDLET_IO_BOUND_PES = 1;
private static final int CLOUDLET_IO_BOUND_IOPS = 250000; // IO-Bound workload
private static final int CLOUDLET_IO_BOUND_IOPS = 1000000; // IO-Bound workload (Set a high duration time)
private static final int NUMBER_VMS_LAUNCHED = 4;
......@@ -139,7 +142,7 @@ public class InfoAwareSimulation {
private static final double CLOUDLET_LAUNCHED_DELAY = 0;
private static final int CLOUDLET_LAUNCHED_LENGTH = 11250;
private static final int CLOUDLET_LAUNCHED_PES = 4;
private static final int CLOUDLET_LAUNCHED_IOPS = 500; // IO-Bound workload
private static final int CLOUDLET_LAUNCHED_IOPS = 900000; // IO-Bound workload
private final CloudSim simulation;
......@@ -147,6 +150,7 @@ public class InfoAwareSimulation {
private DatacenterBroker broker;
private List<Vm> vmList;
private List<Cloudlet> cloudletList;
private List<Host> hostList;
public static void main(String[] args) {
new InfoAwareSimulation();
......@@ -187,9 +191,52 @@ public class InfoAwareSimulation {
final List<Cloudlet> finishedCloudlets = broker.getCloudletFinishedList();
new CloudletsTableBuilder(finishedCloudlets).build();
printHostCpuUtilizationAndPowerConsumption();
}
/**
* <p>
* The Host CPU Utilization History is only computed if VMs utilization history
* is enabled by calling {@code vm.getUtilizationHistory().enable()}
* </p>
* *
*/
private void printHostCpuUtilizationAndPowerConsumption() {
System.out.println();
for (Host host : hostList) {
System.out.printf("Host %d CPU utilization and power consumption\n", host.getId());
System.out.println(
"-------------------------------------------------------------------------------------------");
/*
* Since the utilization history are stored in the reverse chronological order,
* the values are presented in this way.
*/
final double[] utilizationPercentHistory = host.getUtilizationHistory();
double totalPower = 0;
double time = simulation.clock();
for (int i = 0; i < utilizationPercentHistory.length; i++) {
final double utilizationPercent = utilizationPercentHistory[i];
/**
* The power consumption is returned in Watt-second, but it's measured the
* continuous consumption before a given time, according to the time interval
* defined by {@link #SCHEDULING_INTERVAL} set to the Datacenter.
*/
final double wattsPerInterval = host.getPowerModel().getPower(utilizationPercent) * SCHEDULING_INTERVAL;
totalPower += wattsPerInterval;
System.out.printf(
"\tTime %6.0f | CPU Utilization %6.2f%% | Power Consumption: %8.2f Watt-Second in %d Seconds\n",
time, utilizationPercent * 100, wattsPerInterval, SCHEDULING_INTERVAL);
time -= SCHEDULING_INTERVAL;
}
System.out.printf(
"Total Host %d Power Consumption in %.0f seconds: %.2f Watt-Second (mean of %.2f Watt-Second) \n",
host.getId(), simulation.clock(), totalPower, totalPower / simulation.clock());
System.out.println(
"-------------------------------------------------------------------------------------------\n");
}
}
/**
* Event listener which is called every time the simulation clock advances.
* @param info information about the event happened.
......@@ -200,7 +247,7 @@ public class InfoAwareSimulation {
/* Checks if the time specified in the scheduling interval has passed. */
if(time == SCHEDULING_INTERVAL) {
Log.printLine("\n" + info.getTime() + ": # Changing Vm Allocation Policy to: Info-Aware");
Log.printLine("\n" + info.getTime() + ": # Changing Vm Allocation Policy to: Info-Aware");
datacenter = ((DatacenterSimple) datacenter).setVmAllocationPolicy(new VmAllocationPolicyInfoAware());
List<Vm> listVmsLaunched = new ArrayList<>(NUMBER_VMS_LAUNCHED);
......@@ -237,13 +284,14 @@ public class InfoAwareSimulation {
private Datacenter createDatacenter(int numberOfHosts) {
final List<Host> hostList = new ArrayList<>(numberOfHosts);
hostList = new ArrayList<>(numberOfHosts);
for(int i = 0; i < numberOfHosts; i++) {
Host host = createHost(HOSTS_PES, HOSTS_MIPS, HOSTS_RAM, HOSTS_IOPS, HOSTS_BW, HOSTS_STORAGE);
hostList.add(host);
}
final Datacenter dc = new DatacenterSimple(simulation, hostList, new VmAllocationPolicySimple());
dc.setSchedulingInterval(SCHEDULING_INTERVAL);
return dc;
}
......@@ -253,12 +301,17 @@ public class InfoAwareSimulation {
for (int i = 0; i < hostPes; i++) {
peList.add(new PeSimple(mipsPerPe, new PeProvisionerSimple()));
}
// final PowerModel powerModel = new PowerModelSpecPowerHpProLiantBL460cGen9DvfsMode();
// final PowerModel powerModel = new PowerModelSpecPowerHpProLiantBL460cGen9HighPowerMode();
final PowerModel powerModel = new PowerModelSpecPowerHpProLiantBL460cGen9LowPowerMode();
ResourceProvisioner ramProvisioner = new ResourceProvisionerShared();
ResourceProvisioner bwProvisioner = new ResourceProvisionerShared();
ResourceProvisioner iopsProvisioner = new ResourceProvisionerShared();
VmScheduler vmScheduler = new VmSchedulerTimeShared();
Host host = new HostSimple(ram, iops, bw, storage, peList);
host.setPowerModel(powerModel);
host
.setRamProvisioner(ramProvisioner)
.setBwProvisioner(bwProvisioner)
......@@ -274,6 +327,7 @@ public class InfoAwareSimulation {
.setCloudletScheduler(new CloudletSchedulerTimeShared())
.setIops(iops);
vm.getUtilizationHistory().enable();
vm.setSubmissionDelay(delayTime);
return vm;
......
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