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

fixing iops scheduler

parent dcc1d462
......@@ -87,7 +87,7 @@ 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 = 1000;
private static final int VM_BW = 10000;
private static final int VM_RAM = 1024;
private static final int VM_STORAGE = 10 * 1024;
......@@ -107,13 +107,13 @@ public class SlaExploitationSimulation {
SLA_TIGHT_HOSTS = 5;
SLA_LOOSE_HOSTS = 5;
HOST_IOPS = 2500;
MINIMUM_IOPS = 100;
MINIMUM_IOPS = 101;
LOW_AVAILABILITY = 99.9;
VMS = 250;
CLOUDLETS = 250;
CLOUDLETS = VMS;
VM_IOPS = 100;
CLOUDLET_IOPS = 5 * 60 * 60 * VM_IOPS;
MIGRATION_TIME = 30;
CLOUDLET_IOPS = 2 * 60 * 60 * VM_IOPS;
MIGRATION_TIME = 5;
random = new Random(1);
......@@ -245,8 +245,8 @@ 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(1)
.setOutputSize(1).setUtilizationModel(utilization)
Cloudlet cloudlet = new CloudletSimple(i, NUM_INSTR, VM_PES).setFileSize(1000)
.setOutputSize(1000).setUtilizationModel(utilization)
// .setUtilizationModelIops(new UtilizationModelUneven(0, 100, random.nextLong()))
.setIops(CLOUDLET_IOPS);
......
......@@ -151,14 +151,9 @@ 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
// }
// }
if(!migrationMap.isEmpty()){
System.out.println(migrationMap);
}
return migrationMap;
}
......@@ -316,6 +311,8 @@ public class VmAllocationPolicyMigrationSla extends VmAllocationPolicyAbstract {
for (Host h : looseSlaHosts) {
for (Vm vm : h.getVmList()) {
// TODO (IF) Create method with code bellow
if(vm.isInMigration() && !isLooseHost(vm.gethostInMigration()))
continue;
if (vm.getMonitor().getCumulativeCredit(clock) - MIGRATION_TIME >= 0) {
candidateVmsToMigrate.add(vm);
}
......@@ -393,6 +390,10 @@ public class VmAllocationPolicyMigrationSla extends VmAllocationPolicyAbstract {
}
return hosts;
}
private boolean isLooseHost(Host host) {
return host.getIopsProvisioner() instanceof ResourceProvisionerSimple;
}
@Override
public Optional<Host> findHostForVm(Vm vm) {
......
......@@ -63,7 +63,7 @@ public class VmAllocationPolicyMigrationSlaFixedTightHost extends VmAllocationPo
Map<Vm, Host> migrationMap = super.getOptimizedAllocationMap(vmList);
// Consolidate Loose hosts
optimisticConsolidation(migrationMap);
migrationMap = optimisticConsolidation(migrationMap);
return migrationMap;
}
......@@ -101,34 +101,15 @@ public class VmAllocationPolicyMigrationSlaFixedTightHost extends VmAllocationPo
private Map<Vm, Host> optimisticConsolidation(Map<Vm, Host> actualMigrationMap) {
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> orderedLooseHosts = getLooseHostsSortedAscendingByFragmentation();
List<Host> sortedLooseHosts = getLooseHostsSortedAscendingByFragmentation();
Iterator<Host> hostIt = sortedLooseHosts.listIterator();
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));
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) && orderedLooseHosts.get(j).addMigratingInVm(vm)) {
actualMigrationMap.put(vm, orderedLooseHosts.get(j));
}
}
}
......@@ -136,6 +117,26 @@ public class VmAllocationPolicyMigrationSlaFixedTightHost extends VmAllocationPo
return actualMigrationMap;
}
// private Map<Vm, Host> optimisticConsolidation2(Map<Vm, Host> actualMigrationMap) {
//
// List<Host> sortedLooseHosts = getLooseHostsSortedAscendingByFragmentation();
// Iterator<Host> hostIt = sortedLooseHosts.listIterator();
//
// 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;
// }
// Returns the list of loose hosts ordered (increase order) by the number of Vm
private List<Host> getLooseHostsSortedAscendingByFragmentation() {
......
......@@ -411,9 +411,9 @@ public class DatacenterSimple extends CloudSimEntity implements Datacenter {
final List<Double> mipsList = vm.getHost().getVmScheduler().getAllocatedMips(vm);
final double iops = vm.getHost().getVmScheduler().getAllocatedIops(vm);
// final double iops = vm.getIops().getAllocatedResource();
System.out.println("Teste1! Vm id="+vm.getId()+", iops="+iops);
vm.updateProcessing(getSimulation().clock(), mipsList, iops);
//// final double iops = vm.getIops().getAllocatedResource();
// System.out.println("Teste1! Vm id="+vm.getId()+", iops="+iops);
vm.updateProcessing(getSimulation().clock(), mipsList);
}
return hostAllocatedForVm;
......
......@@ -242,7 +242,7 @@ public class HostSimple implements Host {
* e.g., in cases when Vm is destroyed during simulation execution.*/
for (int i = 0; i < vmList.size(); i++) {
final Vm vm = vmList.get(i);
final double nextTime = vm.updateProcessing(currentTime, vmScheduler.getAllocatedMips(vm), vmScheduler.getAllocatedIops(vm));
final double nextTime = vm.updateProcessing(currentTime, vmScheduler.getAllocatedMips(vm));
nextSimulationTime = Math.min(nextTime, nextSimulationTime);
}
......@@ -342,6 +342,10 @@ public class HostSimple implements Host {
}
vm.setInMigration(inMigration);
if(inMigration)
vm.setHostInMigration(this);
storage.allocateResource(vm.getStorage());
ramProvisioner.allocateResourceForVm(vm, vm.getCurrentRequestedRam());
bwProvisioner.allocateResourceForVm(vm, vm.getCurrentRequestedBw());
......
......@@ -178,8 +178,7 @@ public class NetworkHost extends HostSimple {
if (!pktsToSendForLocalVms.isEmpty()) {
for (final Vm vm : getVmList()) {
vm.updateProcessing(
getSimulation().clock(), getVmScheduler().getAllocatedMips(vm),
getVmScheduler().getAllocatedIops(vm));
getSimulation().clock(), getVmScheduler().getAllocatedMips(vm));
}
}
......
......@@ -515,27 +515,27 @@ public abstract class CloudletSchedulerAbstract implements CloudletScheduler {
.orElse(Cloudlet.NULL);
}
@Override
public double updateProcessing(final double currentTime, final List<Double> mipsShare, double iops) {
setCurrentMipsShare(mipsShare);
setCurrentIopsAllocated(iops); //TODO remove?
if (cloudletExecList.isEmpty() && cloudletWaitingList.isEmpty()) {
setPreviousTime(currentTime);
return Double.MAX_VALUE;
}
updateCloudletsProcessing(currentTime);
updateVmRamAbsoluteUtilization();
updateVmIopsAbsoluteUtilization();
removeFinishedCloudletsFromExecutionListAndAddToFinishedList();
moveNextCloudletsFromWaitingToExecList();
final double nextSimulationTime = getEstimatedFinishTimeOfSoonerFinishingCloudlet(currentTime);
setPreviousTime(currentTime);
return nextSimulationTime;
}
// @Override
// public double updateProcessing(final double currentTime, final List<Double> mipsShare, double iops) {
// setCurrentMipsShare(mipsShare);
// setCurrentIopsAllocated(iops); //TODO remove?
//
// if (cloudletExecList.isEmpty() && cloudletWaitingList.isEmpty()) {
// setPreviousTime(currentTime);
// return Double.MAX_VALUE;
// }
//
// updateCloudletsProcessing(currentTime);
// updateVmRamAbsoluteUtilization();
// updateVmIopsAbsoluteUtilization(currentTime);
// removeFinishedCloudletsFromExecutionListAndAddToFinishedList();
// moveNextCloudletsFromWaitingToExecList();
//
// final double nextSimulationTime = getEstimatedFinishTimeOfSoonerFinishingCloudlet(currentTime);
// setPreviousTime(currentTime);
//
// return nextSimulationTime;
// }
@Override
public double updateProcessing(final double currentTime, final List<Double> mipsShare) {
......@@ -548,6 +548,7 @@ public abstract class CloudletSchedulerAbstract implements CloudletScheduler {
updateCloudletsProcessing(currentTime);
updateVmRamAbsoluteUtilization();
updateVmIopsAbsoluteUtilization(currentTime);
removeFinishedCloudletsFromExecutionListAndAddToFinishedList();
moveNextCloudletsFromWaitingToExecList();
......@@ -652,19 +653,25 @@ public abstract class CloudletSchedulerAbstract implements CloudletScheduler {
* If a Cloudlet requests more resources than is available, just the available
* amount is allocated to it.</p>
*/
private void updateVmIopsAbsoluteUtilization() {
private void updateVmIopsAbsoluteUtilization(double currentTime) {
final ResourceManageable iops = vm.getResource(Iops.class);
iops.deallocateAllResources();
long totalRequested = 0;
for (final CloudletExecution cloudletExecution : cloudletExecList) {
final Cloudlet cloudlet = cloudletExecution.getCloudlet();
final long requested = (long)getCloudletIopsAbsoluteUtilization(cloudlet);
if(requested > iops.getAvailableResource()){
Log.printFormattedLine(
"%.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())); FIXME should be removed??
final Cloudlet cloudlet = cloudletExecution.getCloudlet();
final long requested = (long)getCloudletIopsAbsoluteUtilization(cloudlet, currentTime);
totalRequested += requested;
// if(requested > iops.getAvailableResource()){
// Log.printFormattedLine(
// "%.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())); //FIXME should be removed??
}
vm.setIOPSUtilization(currentTime, totalRequested);
}
/**
......@@ -673,12 +680,12 @@ public abstract class CloudletSchedulerAbstract implements CloudletScheduler {
* @param cloudlet the Cloudlet to get the absolute value of IOPS utilization
* @return the Cloudlet IOPS utilization in absolute value
*/
private double getCloudletIopsAbsoluteUtilization(final Cloudlet cloudlet) {
private double getCloudletIopsAbsoluteUtilization(final Cloudlet cloudlet, double currentTime) {
final ResourceManageable iops = vm.getResource(Iops.class);
final UtilizationModel um = cloudlet.getUtilizationModelIops();
return um.getUnit() == Unit.ABSOLUTE ?
Math.min(um.getUtilization(), vm.getIops().getCapacity()) :
um.getUtilization() * iops.getCapacity();
Math.min(um.getUtilization(currentTime), vm.getIops().getCapacity()) :
um.getUtilization(currentTime) * iops.getCapacity();
}
/**
......
......@@ -413,6 +413,16 @@ public interface Vm extends Machine, UniquelyIdentificable, Comparable<Vm>, Cust
* @return
*/
boolean isInMigration();
/**
* Sets host that the Vm is migrating into
*/
void setHostInMigration(Host host);
/**
* Gets host that the Vm is migrating into
*/
Host gethostInMigration();
/**
* Defines if the VM is in migration process or not.
......@@ -471,20 +481,20 @@ public interface Vm extends Machine, UniquelyIdentificable, Comparable<Vm>, Cust
*/
Vm setSize(long size);
/**
* Updates the processing of cloudlets running on this VM.
*
* @param currentTime current simulation time
* @param mipsShare list with MIPS share of each Pe available to the
* scheduler
* @param iops iops of the vm available to the scheduler
* @return the predicted completion time of the earliest finishing cloudlet
* (which is a relative delay from the current simulation time),
* or {@link Double#MAX_VALUE} if there is no next Cloudlet to execute
* @pre currentTime >= 0
* @post $none
*/
double updateProcessing(double currentTime, List<Double> mipsShare, double iops);
// /**
// * Updates the processing of cloudlets running on this VM.
// *
// * @param currentTime current simulation time
// * @param mipsShare list with MIPS share of each Pe available to the
// * scheduler
// * @param iops iops of the vm available to the scheduler
// * @return the predicted completion time of the earliest finishing cloudlet
// * (which is a relative delay from the current simulation time),
// * or {@link Double#MAX_VALUE} if there is no next Cloudlet to execute
// * @pre currentTime >= 0
// * @post $none
// */
// double updateProcessing(double currentTime, List<Double> mipsShare, double iops);
/**
* Updates the processing of cloudlets running on this VM.
......
......@@ -242,11 +242,6 @@ final class VmNull implements Vm {
@Override
public void setContract(SlaContract contract) { }
@Override
public double updateProcessing(double currentTime, List<Double> mipsShare,
double iops) {
return 0;
}
@Override
public SlaMonitor getMonitor() {
return null;
}
......@@ -258,4 +253,14 @@ final class VmNull implements Vm {
public void setIOPSUtilization(double time, double value) {
return;
}
@Override
public void setHostInMigration(Host host) {
// TODO Auto-generated method stub
}
@Override
public Host gethostInMigration() {
// TODO Auto-generated method stub
return null;
}
}
......@@ -123,6 +123,8 @@ public class VmSimple implements Vm {
*/
private Iops iops;
private Host hostMigratingIn;
/**
* The SLA regarding this VM.
*/
......@@ -254,25 +256,10 @@ public class VmSimple implements Vm {
this(id, (long)mipsCapacity, numberOfPes);
}
@Override
public double updateProcessing(final double currentTime, final List<Double> mipsShare, double iops) {
Objects.requireNonNull(mipsShare);
if(!cloudletScheduler.getCloudletExecList().isEmpty()){
this.lastBuzyTime = getSimulation().clock();
}
final double nextSimulationTime = cloudletScheduler.updateProcessing(currentTime, mipsShare, iops);
notifyOnUpdateProcessingListeners();
utilizationHistory.addUtilizationHistory(currentTime);
setIOPSUtilization(currentTime, iops);
return nextSimulationTime;
}
@Override
public double updateProcessing(final double currentTime, final List<Double> mipsShare) {
Objects.requireNonNull(mipsShare);
if(!cloudletScheduler.getCloudletExecList().isEmpty()){
this.lastBuzyTime = getSimulation().clock();
}
......@@ -934,4 +921,17 @@ public class VmSimple implements Vm {
public UtilizationHistory getUtilizationHistory() {
return utilizationHistory;
}
@Override
public void setHostInMigration(Host host) {
this.hostMigratingIn = host;
}
@Override
public Host gethostInMigration() {
return this.hostMigratingIn;
}
}
......@@ -44,7 +44,7 @@ public double getCumulativeCredit(double time) {
ListIterator<VmStateHistoryEntry> it = stateList.listIterator(lastElement);
ListIterator<Double> ut = utilizationList.listIterator(lastUtilization);
if((int) time <= 0) {
if((int) time <= 0 || utilizationList.isEmpty() || stateList.isEmpty()) {
return 0;
}
......
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