From 5070165c02b085f63c7a937458b64fcbc5c1cacf Mon Sep 17 00:00:00 2001 From: Stefan Derkits Date: Thu, 20 Jun 2013 14:50:24 +0200 Subject: [PATCH] fix SchedulerC --- src/at/ac/tuwien/lsdc/sched/SchedulerC.java | 12 +++++------- src/at/ac/tuwien/lsdc/types/PhysicalMachine.java | 12 ++++++------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/at/ac/tuwien/lsdc/sched/SchedulerC.java b/src/at/ac/tuwien/lsdc/sched/SchedulerC.java index 20ef92a..c4d7729 100644 --- a/src/at/ac/tuwien/lsdc/sched/SchedulerC.java +++ b/src/at/ac/tuwien/lsdc/sched/SchedulerC.java @@ -10,7 +10,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import at.ac.tuwien.lsdc.exception.OutOfPMsException; -import at.ac.tuwien.lsdc.exception.VMResizeException; import at.ac.tuwien.lsdc.types.Application; import at.ac.tuwien.lsdc.types.PhysicalMachine; import at.ac.tuwien.lsdc.types.ScenarioType; @@ -29,13 +28,13 @@ public class SchedulerC extends AbstractSchedulerWithMigration { this.vmType = VMType.NonResizable; } - + @Override protected boolean deployApp(VirtualMachine vm, Application app) { boolean deployed = false; if (!vm.enoughResources(app)) return false; - + deployed = vm.startApplication(app); if (deployed) app.setRunningOn(vm); @@ -54,7 +53,7 @@ public class SchedulerC extends AbstractSchedulerWithMigration { VirtualMachine vm = evt.getApp().getRunningOn(); evt.getApp().setRunningOn(null); vm.stopApplication(evt.getApp()); - + if (vm.getApplications().size() == 0) { PhysicalMachine pm = vm.getRunningOn(); pm.stopVirtualMachine(vm); @@ -89,8 +88,7 @@ public class SchedulerC extends AbstractSchedulerWithMigration { } if (!deployed) { try { - vm = manager.startPhysicalMachine().startVirtualMachine(evt.getApp().getSize(), - evt.getApp().getRam(), evt.getApp().getCpu(), vmType); + vm = manager.startPhysicalMachine().startVirtualMachine(vmType); deployed = deployApp(vm, evt.getApp()); } catch (OutOfPMsException e) { if (federation.askToOutsource(evt.getApp())) { @@ -104,7 +102,7 @@ public class SchedulerC extends AbstractSchedulerWithMigration { } if (deployed) { insertStopEvent(currTime + evt.getApp().getDuration(), evt.getApp()); - + if(manager.countCurrentlyRunningPMs() < manager.getMaxPMs()) { Application app = federation.askToInsource(); if(app != null) { diff --git a/src/at/ac/tuwien/lsdc/types/PhysicalMachine.java b/src/at/ac/tuwien/lsdc/types/PhysicalMachine.java index c80505e..1c87df8 100644 --- a/src/at/ac/tuwien/lsdc/types/PhysicalMachine.java +++ b/src/at/ac/tuwien/lsdc/types/PhysicalMachine.java @@ -68,9 +68,9 @@ public class PhysicalMachine implements Comparable { // Creates a VirtualMachine of maximum possible Size public VirtualMachine startVirtualMachine(VMType type) { - VirtualMachine vm = new VirtualMachine(maxSize - initialSize - VirtualMachine.initialSize, + VirtualMachine vm = startVirtualMachine(maxSize - initialSize - VirtualMachine.initialSize, maxRAM - initialRAM - VirtualMachine.initialRAM, maxCPU - initialCPU - - VirtualMachine.initialCPU, this, type); + - VirtualMachine.initialCPU, type); return vm; } @@ -102,7 +102,7 @@ public class PhysicalMachine implements Comparable { } /** - * Checks if there is enough space for the VM initial resources plus its netto resources + * Checks if there is enough space for the VM initial resources plus its netto resources * @param size the _netto_ size reserved on the VM * @param RAM the _netto_ RAM reserved on the VM * @param CPU the _netto_ CPU reserved on the VM @@ -113,14 +113,14 @@ public class PhysicalMachine implements Comparable { && ((VirtualMachine.initialRAM + RAM) <= availableRAM()) && ((VirtualMachine.initialCPU + CPU) <= availableCPU()); } - - public boolean resizeUp(int diffSize, int diffRAM, int diffCPU) throws VMResizeException { + + public boolean resizeUp(int diffSize, int diffRAM, int diffCPU) throws VMResizeException { reservedSize = reservedSize + diffSize; reservedRAM = reservedRAM + diffRAM; reservedCPU = reservedCPU + diffCPU; return true; } - + public boolean resizeDown(Application app) { reservedSize = reservedSize - app.getSize(); reservedRAM = reservedRAM - app.getRam(); -- 2.43.0