From e27d1e7a0a055d6326582169cd5112bd6afe8d7e Mon Sep 17 00:00:00 2001 From: Stefan Derkits Date: Thu, 13 Jun 2013 17:05:42 +0200 Subject: [PATCH] fix strange methods in Physical & Virtual Machine --- src/at/ac/tuwien/lsdc/types/PhysicalMachine.java | 6 +++++- src/at/ac/tuwien/lsdc/types/VirtualMachine.java | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/at/ac/tuwien/lsdc/types/PhysicalMachine.java b/src/at/ac/tuwien/lsdc/types/PhysicalMachine.java index 4a482b0..58ddb43 100644 --- a/src/at/ac/tuwien/lsdc/types/PhysicalMachine.java +++ b/src/at/ac/tuwien/lsdc/types/PhysicalMachine.java @@ -106,6 +106,10 @@ public class PhysicalMachine implements Comparable { && ((VirtualMachine.initialCPU + CPU) <= availableCPU()); } + public boolean checkExtendVM(int sizeDiff, int ramDiff, int CPUDiff) { + return ((sizeDiff <= availableSize()) && (ramDiff <= availableRAM()) && (CPUDiff <= availableCPU())); + } + private int availableSize() { return maxSize - reservedSize; } @@ -169,7 +173,7 @@ public class PhysicalMachine implements Comparable { public VirtualMachine getLatestVM() { VirtualMachine vm = null; - for(Iterator it = VMs.values().iterator(); it.hasNext(); ) { + for (Iterator it = VMs.values().iterator(); it.hasNext();) { vm = it.next(); } return vm; diff --git a/src/at/ac/tuwien/lsdc/types/VirtualMachine.java b/src/at/ac/tuwien/lsdc/types/VirtualMachine.java index 2fb7673..ef07d70 100644 --- a/src/at/ac/tuwien/lsdc/types/VirtualMachine.java +++ b/src/at/ac/tuwien/lsdc/types/VirtualMachine.java @@ -63,7 +63,8 @@ public class VirtualMachine { */ public boolean resizeVM(int newSize, int newRAM, int newCPU) { if (type == VMType.Resizable - && runningOn.checkVM(newSize - reservedSize, newRAM - reservedRAM, newCPU - reservedCPU)) { + && runningOn.checkExtendVM(newSize - reservedSize, newRAM - reservedRAM, newCPU + - reservedCPU)) { // Resize VM reservedSize = initialSize + newSize; reservedRAM = initialRAM + newRAM; -- 2.43.0