Commit dcc1d462 authored by Eduardo Falcão's avatar Eduardo Falcão
Browse files

fixing iops allocation on cloudlet scheduler

parent 27473f14
cloudlet-id,status,datacenter-id,host-id,host-pes-cpu-cores,vm-id,vm-pes-cpu-cores,cloudlet-len-mi-cpu,cloudlet-len-mi-iops,cloudlet-iops-fragmentation,cloudlet-pes-cpu-cores,start-time-secs,finish-time-secs,exec-time-secs
0,SUCCESS,1,0,160,0,1,1,1000,63.66542801502484,1,10.0,40.032,31
cloudlet-id,status,datacenter-id,host-id,host-pes-cpu-cores,vm-id,vm-pes-cpu-cores,cloudlet-len-mi-cpu,cloudlet-len-mi-iops,cloudlet-iops-fragmentation,cloudlet-pes-cpu-cores,start-time-secs,finish-time-secs,exec-time-secs
0,SUCCESS,1,0,160,0,1,1,1000,67.8128758955171,1,10.0,970.9619999999993,961
time,cloudlet-id,current-sla-violation,cumulative-sla-violation,vm-credit,
0,0,0,0,0.0
60,0,0,0,-0.26262626262626265
120,0,0,0,-0.8080808080808078
180,0,0,0,-1.3535353535353536
240,0,0,0,-1.8989898989899
300,0,0,0,-2.444444444444445
360,0,0,0,-2.98989898989899
420,0,0,0,-3.535353535353535
480,0,0,0,-4.08080808080808
540,0,0,0,-4.626262626262625
600,0,0,0,-5.17171717171717
660,0,0,0,-5.717171717171715
720,0,0,0,-6.26262626262626
780,0,0,0,-6.808080808080805
840,0,0,0,-7.35353535353535
900,0,0,0,-7.898989898989895
960,0,0,0,-8.444444444444445
......@@ -79,7 +79,7 @@ public class SlaExploitationSimulation {
// HOST
private static final int HOST_PES = 25;
public static final int HOST_MIPS = 1000;
public static final int HOST_RAM = 25 * 1024;
public static final int HOST_RAM = 50 * 1024;
public static final int HOST_BW = 1000000;
public static final int HOST_BASE_STORAGE = 2 * 1024 * 1024;
......@@ -87,12 +87,9 @@ public class SlaExploitationSimulation {
private static final int NUM_INSTR = 1;
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_BW = 1000;
private static final int VM_RAM = 1024;
private static final int VM_STORAGE = 100 * 1024;
private static final double UPPER_THRESHOLD = 0.8;
private static final double LOWER_THRESHOLD = 0.2;
private static final int VM_STORAGE = 10 * 1024;
public static final double IMPRECISION = 0.0001;
......@@ -107,15 +104,15 @@ public class SlaExploitationSimulation {
public static void main(String[] args) {
//PATH = args[0];
SLA_TIGHT_HOSTS = 0;
SLA_LOOSE_HOSTS = 10;
SLA_TIGHT_HOSTS = 5;
SLA_LOOSE_HOSTS = 5;
HOST_IOPS = 2500;
MINIMUM_IOPS = 100;
LOW_AVAILABILITY = 99.9;
VMS = 250;
CLOUDLETS = 250;
VM_IOPS = 100;
CLOUDLET_IOPS = 12 * 60 * 60 * VM_IOPS;
CLOUDLET_IOPS = 5 * 60 * 60 * VM_IOPS;
MIGRATION_TIME = 30;
random = new Random(1);
......@@ -133,98 +130,6 @@ public class SlaExploitationSimulation {
new SlaExploitationSimulation();
}
/**
* Creates a {@link VerticalVmScaling} for scaling VM's IOPS when it's under or
* overloaded.
*
* <p>
* Realize the lower and upper thresholds are defined inside this method by
* using references to the methods {@link #lowerIopsUtilizationThreshold(Vm)}
* and {@link #upperIopsUtilizationThreshold(Vm)}. These methods enable defining
* thresholds in a dynamic way and even different thresholds for distinct VMs.
* Therefore, it's a powerful mechanism.
* </p>
*
* <p>
* However, if you are defining thresholds in a static way, and they are the
* same for all VMs, you can use a Lambda Expression like below, for instance,
* instead of creating a new method that just returns a constant value:<br>
* {@code verticalIopsScaling.setLowerThresholdFunction(vm -> 0.4);}
* </p>
*
* @see #createListOfScalableVms(int)
*/
private VerticalVmScaling createVerticalIopsScaling() {
// The percentage in which the amount of IOPS has to be scaled
final double scalingFactor = 0.25;
VerticalVmScalingSimple verticalIopsScaling = new VerticalVmScalingSimple(Iops.class, scalingFactor);
/*
* Instead of gradually increasing or decreasing the amount of IOPS, when the
* scaling object detects the Disk usage is above or below the defined
* thresholds, it will automatically calculate the amount of IOPS to add/remove
* to move the VM from the over or underload condition.
*/
verticalIopsScaling.setResourceScaling(new ResourceScalingInstantaneous());
/**
* Different from the line above, the line below implements a ResourceScaling
* using a Lambda Expression. It is just an example which scales the resource
* twice the amount defined by the scaling factor defined in the constructor.
*
* Realize that if the setResourceScaling method is not called, a
* ResourceScalingGradual will be used, which scales the resource according to
* the scaling factor. The lower and upper thresholds after this line can also
* be defined using a Lambda Expression.
*
* So, here we are defining our own {@link ResourceScaling} instead of using the
* available ones such as the {@link ResourceScalingGradual} or
* {@link ResourceScalingInstantaneous}.
*/
// verticalIopsScaling.setResourceScaling(vs ->
// 2*vs.getScalingFactor()*vs.getAllocatedResource());
verticalIopsScaling.setLowerThresholdFunction(this::lowerIopsUtilizationThreshold);
verticalIopsScaling.setUpperThresholdFunction(this::upperIopsUtilizationThreshold);
return verticalIopsScaling;
}
/**
* Defines the minimum Disk utilization percentage that indicates a Vm is
* underloaded. This function is using a statically defined threshold, but it
* would be defined a dynamic threshold based on any condition you want. A
* reference to this method is assigned to each Vertical VM Scaling created.
*
* @param vm
* the VM to check if its Disk is underloaded. <b>The parameter is
* not being used internally, which means the same threshold is used
* for any Vm.</b>
* @return the lower Disk utilization threshold
* @see #createVerticalIopsScaling()
*/
private double lowerIopsUtilizationThreshold(Vm vm) {
return LOWER_THRESHOLD;
}
/**
* Defines the maximum Disk utilization percentage that indicates a Vm is
* overloaded. This function is using a statically defined threshold, but it
* would be defined a dynamic threshold based on any condition you want. A
* reference to this method is assigned to each Vertical VM Scaling created.
*
* @param vm
* the VM to check if its Disk is overloaded. The parameter is not
* being used internally, that means the same threshold is used for
* any Vm.
* @return the upper Disk utilization threshold
* @see #createVerticalIopsScaling()
*/
private double upperIopsUtilizationThreshold(Vm vm) {
return UPPER_THRESHOLD;
}
public SlaExploitationSimulation() {
this.simulation = new CloudSim(10);
......@@ -299,7 +204,7 @@ public class SlaExploitationSimulation {
List<Pe> peList = new ArrayList<Pe>(); // List of CPU cores
for (int i = 0; i < peNumber; i++) {
peList.add(new PeSimple(1000, new PeProvisionerSimple()));
peList.add(new PeSimple(HOST_MIPS, new PeProvisionerSimple()));
}
return peList;
......@@ -340,9 +245,9 @@ public class SlaExploitationSimulation {
final List<Cloudlet> list = new ArrayList<>(CLOUDLETS);
UtilizationModel utilization = new UtilizationModelFull();
for (int i = 0; i < CLOUDLETS; i++) {
Cloudlet cloudlet = new CloudletSimple(i, NUM_INSTR, VM_PES).setFileSize(1024)
.setOutputSize(1024).setUtilizationModel(utilization)
.setUtilizationModelIops(new UtilizationModelUneven(0, 100, random.nextLong()))
Cloudlet cloudlet = new CloudletSimple(i, NUM_INSTR, VM_PES).setFileSize(1)
.setOutputSize(1).setUtilizationModel(utilization)
// .setUtilizationModelIops(new UtilizationModelUneven(0, 100, random.nextLong()))
.setIops(CLOUDLET_IOPS);
list.add(cloudlet);
......
......@@ -151,6 +151,15 @@ public class VmAllocationPolicyMigrationSla extends VmAllocationPolicyAbstract {
previousFragmentation.putAll(currentFragmentation);
// if(!migrationMap.isEmpty()){
// System.out.println(migrationMap);
// try {
// Thread.sleep(10000);
// } catch (Exception e) {
// // TODO: handle exception
// }
// }
return migrationMap;
}
......
package org.cloudbus.cloudsim.allocationpolicies.migration;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
......@@ -100,15 +101,34 @@ public class VmAllocationPolicyMigrationSlaFixedTightHost extends VmAllocationPo
private Map<Vm, Host> optimisticConsolidation(Map<Vm, Host> actualMigrationMap) {
List<Host> orderedLooseHosts = getOrderedLooseHosts();
List<Host> sortedLooseHosts = getLooseHostsSortedAscendingByFragmentation();
for (int j = sortedLooseHosts.size() - 1; j >= 0; j--) {
for (int i = 0; i < sortedLooseHosts.size(); i++) {
if(i == j || sortedLooseHosts.get(i).getVmList().isEmpty())
continue;
for (Vm vm : sortedLooseHosts.get(i).getVmList()) {
if(sortedLooseHosts.get(j).isSuitableForVm(vm) && sortedLooseHosts.get(j).addMigratingInVm(vm)) {
actualMigrationMap.put(vm, sortedLooseHosts.get(j));
}
}
}
}
return actualMigrationMap;
}
private Map<Vm, Host> optimisticConsolidation2(Map<Vm, Host> actualMigrationMap) {
List<Host> sortedLooseHosts = getLooseHostsSortedAscendingByFragmentation();
Iterator<Host> hostIt = sortedLooseHosts.listIterator();
for (int i = 0; i < orderedLooseHosts.size(); i++) {
for (int j = orderedLooseHosts.size() - 1; j >= 0; j--) {
if(i == j || orderedLooseHosts.get(i).getVmList().isEmpty())
break;
for (Vm vm : orderedLooseHosts.get(i).getVmList()) {
if(orderedLooseHosts.get(j).isSuitableForVm(vm)) {
actualMigrationMap.put(vm, orderedLooseHosts.get(j));
for (int j = sortedLooseHosts.size() - 1; j >= 0; j--) {
for (int i = 0; i < sortedLooseHosts.size(); i++) {
if(i == j || sortedLooseHosts.get(i).getVmList().isEmpty())
continue;
for (Vm vm : sortedLooseHosts.get(i).getVmList()) {
if(sortedLooseHosts.get(j).isSuitableForVm(vm) && sortedLooseHosts.get(j).addMigratingInVm(vm)) {
actualMigrationMap.put(vm, sortedLooseHosts.get(j));
}
}
}
......@@ -117,8 +137,8 @@ public class VmAllocationPolicyMigrationSlaFixedTightHost extends VmAllocationPo
return actualMigrationMap;
}
// Returns the list of loose hosts ordered (increse order) by the number of Vm
private List<Host> getOrderedLooseHosts() {
// Returns the list of loose hosts ordered (increase order) by the number of Vm
private List<Host> getLooseHostsSortedAscendingByFragmentation() {
List<Host> looseHosts = getHostsWithLooseSla();
sort(looseHosts);
Collections.reverse(looseHosts);
......
......@@ -332,12 +332,12 @@ public class HostSimple implements Host {
}
if (!vmScheduler.isSuitableForVm(vm)) {
Log.printFormattedLine(
"%.2f: %s: [%s] Allocation of %s to %s failed due to lack of PEs.\n\t "+
"Required %d PEs of %.0f MIPS (%.0f MIPS total). However, there are just %d working PEs of %.0f MIPS, from which %.0f MIPS are available.",
getSimulation().clock(), getClass().getSimpleName(), msg, vm, this,
vm.getNumberOfPes(), vm.getMips(), vm.getTotalMipsCapacity(),
vmScheduler.getWorkingPeList().size(), getMips(), vmScheduler.getAvailableMips());
// Log.printFormattedLine(
// "%.2f: %s: [%s] Allocation of %s to %s failed due to lack of PEs.\n\t "+
// "Required %d PEs of %.0f MIPS (%.0f MIPS total). However, there are just %d working PEs of %.0f MIPS, from which %.0f MIPS are available.",
// getSimulation().clock(), getClass().getSimpleName(), msg, vm, this,
// vm.getNumberOfPes(), vm.getMips(), vm.getTotalMipsCapacity(),
// vmScheduler.getWorkingPeList().size(), getMips(), vmScheduler.getAvailableMips());
return false;
}
......
......@@ -663,7 +663,7 @@ public abstract class CloudletSchedulerAbstract implements CloudletScheduler {
"%.2f: %s: %s requested %d MB of IOPS but just %d was available and allocated to it.",
vm.getSimulation().clock(), getClass().getSimpleName(), cloudlet, requested, iops.getAvailableResource());
}
iops.allocateResource(Math.min(requested, iops.getAvailableResource()));
// iops.allocateResource(Math.min(requested, iops.getAvailableResource())); FIXME should be removed??
}
}
......
......@@ -91,10 +91,6 @@ public class VmSchedulerTimeShared extends VmSchedulerAbstract {
*/
private boolean allocateMipsShareForVmInternal(final Vm vm, final List<Double> requestedMips) {
if(vm.getId()>=160){
System.out.println("debug");
}
if (!isAllowedToAllocateMips(requestedMips)) {
return false;
}
......@@ -115,9 +111,6 @@ public class VmSchedulerTimeShared extends VmSchedulerAbstract {
* @see #getMipsShareRequestedReduced(Vm, List)
*/
protected void allocateMipsShareForVm(final Vm vm, final List<Double> requestedMipsReduced) {
if(vm.getId()>=160){
System.out.println("debug");
}
final List<Double> mipsShare = getMipsShareToAllocate(vm, requestedMipsReduced);
getAllocatedMipsMap().put(vm, mipsShare);
}
......
......@@ -74,10 +74,6 @@ public class VmSchedulerTimeSharedOverSubscription extends VmSchedulerTimeShared
@Override
protected void allocateMipsShareForVm(final Vm vm, final List<Double> requestedMipsReduced) {
if(vm.getId()>=160){
System.out.println("debug");
}
final double totalRequestedMips = requestedMipsReduced.stream().reduce(0.0, Double::sum);
if (getAvailableMips() >= totalRequestedMips) {
super.allocateMipsShareForVm(vm, requestedMipsReduced);
......
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