Commit 298bad17 authored by Lucas Cavalcante's avatar Lucas Cavalcante
Browse files

utilization

parent 212db8ca
......@@ -84,7 +84,7 @@ public class SlaExploitationSimulation {
private static final int VM_PES = 1;
private static final int VM_MIPS = 500;
private static final int VM_BW = 10;
private static final int VM_RAM = 1024;
private static final int VM_RAM = 1;
private static final int VM_STORAGE = 100 * 1024;
public static final double IMPRECISION = 0.0001;
......@@ -99,18 +99,18 @@ public class SlaExploitationSimulation {
public static void main(String[] args) {
PATH = args[0];
SLA_TIGHT_HOSTS = Integer.parseInt(args[1]);
SLA_LOOSE_HOSTS = Integer.parseInt(args[2]);
HOST_IOPS = Integer.parseInt(args[3]);
MINIMUM_IOPS = Long.parseLong(args[4]);
LOW_AVAILABILITY = Double.parseDouble(args[5]);
VMS = Integer.parseInt(args[6]);
CLOUDLETS = Integer.parseInt(args[7]);
CLOUDLET_IOPS = Integer.parseInt(args[8]);
VM_IOPS = Integer.parseInt(args[9]);
MIGRATION_TIME = Integer.parseInt(args[10]);
random = new Random(Integer.parseInt(args[11]));
//PATH = args[0];
SLA_TIGHT_HOSTS = 1;
SLA_LOOSE_HOSTS = 0;
HOST_IOPS = 500;
MINIMUM_IOPS = 100;
LOW_AVAILABILITY = 99;
VMS = 1;
CLOUDLETS = 1;
CLOUDLET_IOPS = 1000;
VM_IOPS = 100;
MIGRATION_TIME = 10;
random = new Random(1);
FILEID = "tight"+SLA_TIGHT_HOSTS+"-"+
......@@ -143,9 +143,8 @@ public class SlaExploitationSimulation {
cloudletList = createCloudlets();
broker.submitVmList(vmList);
broker.submitCloudletList(cloudletList);
for(int i = 0; i < vmList.size();i+=2){
for(int i = 0; i < vmList.size();i++){
broker.bindCloudletToVm(cloudletList.get(i), vmList.get(i));
broker.bindCloudletToVm(cloudletList.get(i+1), vmList.get(i+1));
}
simulation.start();
......
......@@ -48,6 +48,10 @@ public interface Vm extends Machine, UniquelyIdentificable, Comparable<Vm>, Cust
* objects.
*/
Vm NULL = new VmNull();
List<Double> getIOPSUtilizationList();
void setIOPSUtilization(double time, double value);
/**
* Gets the Vm description, which is an optional text
......
......@@ -248,7 +248,14 @@ final class VmNull implements Vm {
}
@Override
public SlaMonitor getMonitor() {
// TODO Auto-generated method stub
return null;
}
@Override
public List<Double> getIOPSUtilizationList() {
return null;
}
@Override
public void setIOPSUtilization(double time, double value) {
return;
}
}
......@@ -153,6 +153,8 @@ public class VmSimple implements Vm {
private double stopTime;
private double lastBuzyTime;
private List<Double> IOPSUtilizationList;
/**
* Creates a Vm with 1024 MEGABYTE of RAM, 5000 Iops, 1000 Megabits/s of Bandwidth and 1024 MEGABYTE of Storage Size.
*
......@@ -204,6 +206,7 @@ public class VmSimple implements Vm {
//By default, the VM doesn't store utilization history. This has to be enabled by the user as wanted
utilizationHistory = new VmUtilizationHistory(this, false);
this.IOPSUtilizationList = new LinkedList<Double>();
this.monitor = new SlaMonitor(this);
}
......@@ -262,6 +265,7 @@ public class VmSimple implements Vm {
notifyOnUpdateProcessingListeners();
utilizationHistory.addUtilizationHistory(currentTime);
setIOPSUtilization(currentTime, iops);
return nextSimulationTime;
}
......@@ -278,8 +282,15 @@ public class VmSimple implements Vm {
utilizationHistory.addUtilizationHistory(currentTime);
return nextSimulationTime;
}
public List<Double> getIOPSUtilizationList() {
return this.IOPSUtilizationList;
}
public void setIOPSUtilization(double time, double value) {
this.getIOPSUtilizationList().add(value);
}
@Override
public double getCpuPercentUsage() {
return getCpuPercentUsage(getSimulation().clock());
......
......@@ -104,7 +104,7 @@ public class VmUtilizationHistory implements UtilizationHistory {
if (time > getPreviousTime() && (time - 0.1) % vm.getHost().getDatacenter().getSchedulingInterval() == 0) {
final double utilization = vm.getCpuPercentUsage(vm.getCloudletScheduler().getPreviousTime());
if (time != 0 || utilization != 0) {
if (time != 0 ) {
addUtilizationHistoryValue(utilization);
}
setPreviousTime(time);
......
......@@ -39,7 +39,7 @@ public double getCumulativeCredit(double time) {
double availability = vm.getContract().getAvailabilityMetric().getMinDimension().getValue();
List<VmStateHistoryEntry> stateList = vm.getStateHistory();
List<Double> utilizationList = vm.getUtilizationHistory().getHistory();
List<Double> utilizationList = vm.getIOPSUtilizationList();
double cumulativeCredit = 0;
ListIterator<VmStateHistoryEntry> it = stateList.listIterator(lastElement);
ListIterator<Double> ut = utilizationList.listIterator(lastUtilization);
......@@ -77,9 +77,10 @@ public double getCumulativeCredit(double time) {
if(stateList.get(lastElement - 1).getTime() < time) {
VmStateHistoryEntry last = stateList.get(lastElement - 1);
double utilization = utilizationList.get(lastUtilization - 1);
Double previous = credits.get((int) last.getTime());
if (last.getAllocatedIops() < provisioned) {
if (last.getAllocatedIops() <= utilization) {
cumulativeCredit = previous - (((int) time - stateList.get(lastElement - 1).getTime())) * (1 / availability);
} else {
cumulativeCredit = previous + (((int) time - stateList.get(lastElement - 1).getTime())) * (1 / availability);
......@@ -90,7 +91,7 @@ public double getCumulativeCredit(double time) {
private Double putCredits(VmStateHistoryEntry state, double utilization, double dif, double availability) {
Double cumulativeCredit;
if(state.getAllocatedIops() < utilization) {
if(state.getAllocatedIops() <= utilization) {
credits.put((int) state.getTime(), dif - (1 / availability));
}
else {
......@@ -122,7 +123,7 @@ public double getCumulativeCredit(double time) {
return previous;
}
if(state.getAllocatedIops() >= utilization)
if(state.getAllocatedIops() > utilization)
dif = previous + (1 / availability) * (int )(time - prevTime - 1);
else
dif = previous - (1 / availability) * (int )(time - prevTime - 1);
......
......@@ -78,13 +78,22 @@ public class SlaMonitorTest {
@Test
public void getVmCredit_test() {
Vm vm = new VmSimple(0, 0);
vm.getUtilizationHistory().enable();
vm.addStateHistoryEntry(new VmStateHistoryEntry(1,0,0,400,0,false));
vm.setIOPSUtilization(1, 400);
vm.addStateHistoryEntry(new VmStateHistoryEntry(2,0,0,500,0,false));
vm.setIOPSUtilization(1, 400);
vm.addStateHistoryEntry(new VmStateHistoryEntry(3,0,0,500,0,false));
vm.setIOPSUtilization(1, 400);
vm.addStateHistoryEntry(new VmStateHistoryEntry(4,0,0,600,0,false));
vm.setIOPSUtilization(1, 400);
vm.addStateHistoryEntry(new VmStateHistoryEntry(5,0,0,600,0,false));
vm.setIOPSUtilization(1, 400);
vm.addStateHistoryEntry(new VmStateHistoryEntry(11,0,0,400,0,false));
vm.setIOPSUtilization(1, 400);
vm.addStateHistoryEntry(new VmStateHistoryEntry(16,0,0,500,0,false));
vm.setIOPSUtilization(1, 400);
vm.setContract(contract);
assertEquals(0, vm.getMonitor().getCumulativeCredit(0), imprecision);
......
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