Commit f0662234 authored by Anton Beloglazov's avatar Anton Beloglazov

A few fixes here and there

parent 7b66bab7
......@@ -223,6 +223,20 @@ public abstract class CloudletScheduler {
*/
public abstract double getTotalCurrentAllocatedMipsForCloudlet(ResCloudlet rcl, double time);
/**
* Gets the current requested ram.
*
* @return the current requested ram
*/
public abstract double getCurrentRequestedUtilizationOfRam();
/**
* Gets the current requested bw.
*
* @return the current requested bw
*/
public abstract double getCurrentRequestedUtilizationOfBw();
/**
* Gets the previous time.
*
......
......@@ -659,4 +659,16 @@ public class CloudletSchedulerSpaceShared extends CloudletScheduler {
return 0.0;
}
@Override
public double getCurrentRequestedUtilizationOfRam() {
// TODO Auto-generated method stub
return 0;
}
@Override
public double getCurrentRequestedUtilizationOfBw() {
// TODO Auto-generated method stub
return 0;
}
}
......@@ -543,4 +543,22 @@ public class CloudletSchedulerTimeShared extends CloudletScheduler {
return 0.0;
}
@Override
public double getCurrentRequestedUtilizationOfRam() {
double ram = 0;
for (ResCloudlet cloudlet : cloudletExecList) {
ram += cloudlet.getCloudlet().getUtilizationOfRam(CloudSim.clock());
}
return ram;
}
@Override
public double getCurrentRequestedUtilizationOfBw() {
double bw = 0;
for (ResCloudlet cloudlet : cloudletExecList) {
bw += cloudlet.getCloudlet().getUtilizationOfBw(CloudSim.clock());
}
return bw;
}
}
......@@ -77,10 +77,10 @@ public class HostDynamicWorkload extends Host {
for (Vm vm : getVmList()) {
double totalRequestedMips = vm.getCurrentRequestedTotalMips();
if (totalRequestedMips == 0) {
Log.printLine("VM #" + vm.getId() + " has completed its execution and destroyed");
continue;
}
// if (totalRequestedMips == 0) {
// Log.printLine("VM #" + vm.getId() + " has completed its execution and destroyed");
// continue;
// }
double totalAllocatedMips = getVmScheduler().getTotalAllocatedMipsForVm(vm);
......@@ -95,8 +95,6 @@ public class HostDynamicWorkload extends Host {
Log.formatLine("%.2f: [Host #" + getId() + "] MIPS for VM #" + vm.getId() + " by PEs (" + getPesNumber() + " * " + getVmScheduler().getPeCapacity() + ")." + pesString, CloudSim.clock());
}
vm.addStateHistoryEntry(currentTime, totalAllocatedMips, totalRequestedMips, (vm.isInMigration() && !getVmsMigratingIn().contains(vm)));
if (getVmsMigratingIn().contains(vm)) {
Log.formatLine("%.2f: [Host #" + getId() + "] VM #" + vm.getId() + " is being migrated to Host #" + getId(), CloudSim.clock());
} else {
......@@ -104,6 +102,8 @@ public class HostDynamicWorkload extends Host {
Log.formatLine("%.2f: [Host #" + getId() + "] Under allocated MIPS for VM #" + vm.getId() + ": %.2f", CloudSim.clock(), totalRequestedMips - totalAllocatedMips);
}
vm.addStateHistoryEntry(currentTime, totalAllocatedMips, totalRequestedMips, (vm.isInMigration() && !getVmsMigratingIn().contains(vm)));
if (vm.isInMigration()) {
Log.formatLine("%.2f: [Host #" + getId() + "] VM #" + vm.getId() + " is in migration", CloudSim.clock());
totalAllocatedMips /= 0.9; // performance degradation due to migration - 10%
......@@ -265,7 +265,15 @@ public class HostDynamicWorkload extends Host {
* @param isActive the is active
*/
public void addStateHistoryEntry(double time, double allocatedMips, double requestedMips, boolean isActive) {
getStateHistory().add(new HostStateHistoryEntry(time, allocatedMips, requestedMips, isActive));
HostStateHistoryEntry newState = new HostStateHistoryEntry(time, allocatedMips, requestedMips, isActive);
if (!getStateHistory().isEmpty()) {
HostStateHistoryEntry previousState = getStateHistory().get(getStateHistory().size() - 1);
if (previousState.getTime() == time) {
getStateHistory().set(getStateHistory().size() - 1, newState);
return;
}
}
getStateHistory().add(newState);
}
}
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package org.cloudbus.cloudsim;
/**
* The UtilizationModelNull class is a simple model, according to which
* a Cloudlet always require zero capacity.
*
* @author Anton Beloglazov
* @since CloudSim Toolkit 2.0
*/
public class UtilizationModelNull implements UtilizationModel {
/* (non-Javadoc)
* @see cloudsim.power.UtilizationModel#getUtilization(double)
*/
@Override
public double getUtilization(double time) {
return 0;
}
}
......@@ -12,6 +12,8 @@ import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import org.cloudbus.cloudsim.core.CloudSim;
/**
* Vm represents a VM: it runs inside a Host, sharing hostList
* with other VMs. It processes cloudlets. This processing happens according
......@@ -150,13 +152,17 @@ public class Vm {
if (isRecentlyCreated()) {
boolean mipsIsNull = true;
for (double mips : currentRequestedMips) {
if (mips > 0.0) {
mipsIsNull = false;
setRecentlyCreated(false);
break;
}
if (CloudSim.clock() > 0) {
mipsIsNull = false;
setRecentlyCreated(false);
}
// for (double mips : currentRequestedMips) {
// if (mips > 0.0) {
// mipsIsNull = false;
// setRecentlyCreated(false);
// break;
// }
// }
//if (mipsIsNull && isRecentlyCreated()) {
if (mipsIsNull) {
......@@ -204,7 +210,10 @@ public class Vm {
* @return the current requested bw
*/
public long getCurrentRequestedBw() {
return getBw();
if (isRecentlyCreated()) {
return getBw();
}
return (long) (getCloudletScheduler().getCurrentRequestedUtilizationOfBw() * getBw());
}
/**
......@@ -213,7 +222,10 @@ public class Vm {
* @return the current requested ram
*/
public int getCurrentRequestedRam() {
return getRam();
if (isRecentlyCreated()) {
return getRam();
}
return (int) (getCloudletScheduler().getCurrentRequestedUtilizationOfRam() * getRam());
}
/**
......@@ -602,7 +614,15 @@ public class Vm {
* @param isInMigration the is in migration
*/
public void addStateHistoryEntry(double time, double allocatedMips, double requestedMips, boolean isInMigration) {
getStateHistory().add(new VmStateHistoryEntry(time, allocatedMips, requestedMips, isInMigration));
VmStateHistoryEntry newState = new VmStateHistoryEntry(time, allocatedMips, requestedMips, isInMigration);
if (!getStateHistory().isEmpty()) {
VmStateHistoryEntry previousState = getStateHistory().get(getStateHistory().size() - 1);
if (previousState.getTime() == time) {
getStateHistory().set(getStateHistory().size() - 1, newState);
return;
}
}
getStateHistory().add(newState);
}
}
......@@ -87,6 +87,8 @@ public class PowerDatacenter extends Datacenter {
// if some time passed since last processing
if (currentTime > getLastProcessTime()) {
System.out.print(currentTime + " ");
double minTime = updateCloudetProcessingWithoutSchedulingFutureEventsForce();
if (!isDisableMigrations()) {
......@@ -110,7 +112,7 @@ public class PowerDatacenter extends Datacenter {
/** VM migration delay = RAM / bandwidth **/
// we use BW / 2 to model BW available for migration purposes, the other half of BW is for VM communication
// around 16 seconds for 1024 MB using 1 Gbit/s network
send(getId(), vm.getCurrentAllocatedRam() / ((double) targetHost.getBw() / (2 * 8000)), CloudSimTags.VM_MIGRATE, migrate);
send(getId(), vm.getRam() / ((double) targetHost.getBw() / (2 * 8000)), CloudSimTags.VM_MIGRATE, migrate);
}
}
}
......@@ -148,23 +150,8 @@ public class PowerDatacenter extends Datacenter {
double timeDiff = currentTime - getLastProcessTime();
double timeFrameDatacenterEnergy = 0.0;
if (timeDiff > 0) {
Log.formatLine("\nEnergy consumption for the last time frame from %.2f to %.2f:", getLastProcessTime(), currentTime);
for (PowerHost host : this.<PowerHost>getHostList()) {
double timeFrameHostEnergy = host.getEnergyLinearInterpolation(host.getPreviousUtilizationOfCpu(), host.getUtilizationOfCpu(), timeDiff);
timeFrameDatacenterEnergy += timeFrameHostEnergy;
Log.printLine();
Log.formatLine("%.2f: [Host #%d] utilization is %.2f%%", currentTime, host.getId(), host.getUtilizationOfCpu() * 100);
Log.formatLine("%.2f: [Host #%d] energy is %.2f W*sec", currentTime, host.getId(), timeFrameHostEnergy);
}
Log.formatLine("\n%.2f: Consumed energy is %.2f W*sec\n", currentTime, timeFrameDatacenterEnergy);
}
Log.printLine("\n\n--------------------------------------------------------------\n\n");
Log.printLine("New resource usage for the next time frame:");
Log.formatLine("New resource usage for the time frame starting at %.2f:", currentTime);
for (PowerHost host : this.<PowerHost>getHostList()) {
Log.printLine();
......@@ -177,6 +164,24 @@ public class PowerDatacenter extends Datacenter {
Log.formatLine("%.2f: [Host #%d] utilization is %.2f%%", currentTime, host.getId(), host.getUtilizationOfCpu() * 100);
}
if (timeDiff > 0) {
Log.formatLine("\nEnergy consumption for the last time frame from %.2f to %.2f:", getLastProcessTime(), currentTime);
for (PowerHost host : this.<PowerHost>getHostList()) {
double previousUtilizationOfCpu = host.getPreviousUtilizationOfCpu();
double utilizationOfCpu = host.getUtilizationOfCpu();
double timeFrameHostEnergy = host.getEnergyLinearInterpolation(previousUtilizationOfCpu, utilizationOfCpu, timeDiff);
timeFrameDatacenterEnergy += timeFrameHostEnergy;
Log.printLine();
Log.formatLine("%.2f: [Host #%d] utilization at %.2f was %.2f%%, now is %.2f%%",
currentTime, host.getId(), getLastProcessTime(), previousUtilizationOfCpu * 100, utilizationOfCpu * 100);
Log.formatLine("%.2f: [Host #%d] energy is %.2f W*sec", currentTime, host.getId(), timeFrameHostEnergy);
}
Log.formatLine("\n%.2f: Data center's energy is %.2f W*sec\n", currentTime, timeFrameDatacenterEnergy);
}
setPower(getPower() + timeFrameDatacenterEnergy);
checkCloudletCompletion();
......
......@@ -101,7 +101,7 @@ public class PowerHost extends HostDynamicWorkload {
* @return the energy
*/
public double getEnergyLinearInterpolation(double fromUtilization, double toUtilization, double time) {
if (fromUtilization == 0 && toUtilization == 0) {
if (fromUtilization == 0) {
return 0;
}
double fromPower = getPower(fromUtilization);
......
package org.cloudbus.cloudsim.power.models;
/**
* The power model of an HP ProLiant ML110 G3 (1 x [Pentium D930 3000 MHz, 2 cores], 4GB).
* http://www.spec.org/power_ssj2008/results/res2011q1/power_ssj2008-20110127-00342.html
*/
public class PowerModelSpecPowerHpProLiantMl110G3PentiumD930 extends PowerModelSpecPower {
/** The power. */
private final double[] power = { 105, 112, 118, 125, 131, 137, 147, 153, 157, 164, 169 };
/* (non-Javadoc)
* @see org.cloudbus.cloudsim.power.models.PowerModelSpecPower#getPowerData(int)
*/
@Override
protected double getPowerData(int index) {
return power[index];
}
}
package org.cloudbus.cloudsim.power.models;
/**
* The power model of an HP ProLiant ML110 G4 (1 x [Xeon 3040 1860 MHz, 2 cores], 4GB).
* http://www.spec.org/power_ssj2008/results/res2011q1/power_ssj2008-20110127-00342.html
*/
public class PowerModelSpecPowerHpProLiantMl110G4Xeon3040 extends PowerModelSpecPower {
/** The power. */
private final double[] power = { 86, 89.4, 92.6, 96, 99.5, 102, 106, 108, 112, 114, 117 };
/* (non-Javadoc)
* @see org.cloudbus.cloudsim.power.models.PowerModelSpecPower#getPowerData(int)
*/
@Override
protected double getPowerData(int index) {
return power[index];
}
}
package org.cloudbus.cloudsim.power.models;
/**
* The power model of an HP ProLiant ML110 G5 (1 x [Xeon 3075 2660 MHz, 2 cores], 4GB).
* http://www.spec.org/power_ssj2008/results/res2011q1/power_ssj2008-20110124-00339.html
*/
public class PowerModelSpecPowerHpProLiantMl110G5Xeon3075 extends PowerModelSpecPower {
/** The power. */
private final double[] power = { 93.7, 97, 101, 105, 110, 116, 121, 125, 129, 133, 135 };
/* (non-Javadoc)
* @see org.cloudbus.cloudsim.power.models.PowerModelSpecPower#getPowerData(int)
*/
@Override
protected double getPowerData(int index) {
return power[index];
}
}
package org.cloudbus.cloudsim.power.models;
/**
* The power model of an IBM server x3250 (1 x [Xeon X3470 2933 MHz, 4 cores], 8GB).
* http://www.spec.org/power_ssj2008/results/res2009q4/power_ssj2008-20091104-00213.html
*/
public class PowerModelSpecPowerIbmX3250XeonX3470 extends PowerModelSpecPower {
/** The power. */
private final double[] power = { 41.6, 46.7, 52.3, 57.9, 65.4, 73, 80.7, 89.5, 99.6, 105, 113 };
/* (non-Javadoc)
* @see org.cloudbus.cloudsim.power.models.PowerModelSpecPower#getPowerData(int)
*/
@Override
protected double getPowerData(int index) {
return power[index];
}
}
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