You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by pr...@apache.org on 2013/11/08 00:23:32 UTC

git commit: updated refs/heads/4.2 to 4e632af

Updated Branches:
  refs/heads/4.2 f1568f953 -> 4e632afd5


CLOUDSTACK-4755: cloudstack 4.x does not allow memory upgrade

Changes:
- Set total capacity of a host if it has changed in the CapacityChecker thread
- Fix bug while setting the reserved/used cpu/mem capacity - only one of them used to get set


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/4e632afd
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/4e632afd
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/4e632afd

Branch: refs/heads/4.2
Commit: 4e632afd55cce5c782fc375b9e8049e3c3c35227
Parents: f1568f9
Author: Prachi Damle <pr...@cloud.com>
Authored: Mon Nov 4 16:37:55 2013 -0800
Committer: Prachi Damle <pr...@cloud.com>
Committed: Thu Nov 7 15:23:14 2013 -0800

----------------------------------------------------------------------
 .../com/cloud/capacity/CapacityManagerImpl.java | 64 ++++++++++++++------
 1 file changed, 44 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4e632afd/server/src/com/cloud/capacity/CapacityManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/capacity/CapacityManagerImpl.java b/server/src/com/cloud/capacity/CapacityManagerImpl.java
index 7dde12e..5f9aee6 100755
--- a/server/src/com/cloud/capacity/CapacityManagerImpl.java
+++ b/server/src/com/cloud/capacity/CapacityManagerImpl.java
@@ -595,34 +595,58 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager,
         CapacityVO memCap = _capacityDao.findByHostIdType(host.getId(), CapacityVO.CAPACITY_TYPE_MEMORY);
 
         if (cpuCap != null && memCap != null){
+
+            long hostTotalCpu = host.getCpus().longValue() * host.getSpeed().longValue();
+
+            if (cpuCap.getTotalCapacity() != hostTotalCpu) {
+                s_logger.debug("Calibrate total cpu for host: " + host.getId() + " old total CPU:"
+                        + cpuCap.getTotalCapacity() + " new total CPU:" + hostTotalCpu);
+                cpuCap.setTotalCapacity(hostTotalCpu);
+
+            }
+
         	if (cpuCap.getUsedCapacity() == usedCpu && cpuCap.getReservedCapacity() == reservedCpu) {
         		s_logger.debug("No need to calibrate cpu capacity, host:" + host.getId() + " usedCpu: " + cpuCap.getUsedCapacity()
         				+ " reservedCpu: " + cpuCap.getReservedCapacity());
-        	} else if (cpuCap.getReservedCapacity() != reservedCpu) {
-        		s_logger.debug("Calibrate reserved cpu for host: " + host.getId() + " old reservedCpu:" + cpuCap.getReservedCapacity()
-        				+ " new reservedCpu:" + reservedCpu);
-        		cpuCap.setReservedCapacity(reservedCpu);
-        	} else if (cpuCap.getUsedCapacity() != usedCpu) {
-        		s_logger.debug("Calibrate used cpu for host: " + host.getId() + " old usedCpu:" + cpuCap.getUsedCapacity() + " new usedCpu:"
-        				+ usedCpu);
-        		cpuCap.setUsedCapacity(usedCpu);
+            } else {
+                if (cpuCap.getReservedCapacity() != reservedCpu) {
+                    s_logger.debug("Calibrate reserved cpu for host: " + host.getId() + " old reservedCpu:"
+                            + cpuCap.getReservedCapacity() + " new reservedCpu:" + reservedCpu);
+                    cpuCap.setReservedCapacity(reservedCpu);
+                }
+                if (cpuCap.getUsedCapacity() != usedCpu) {
+                    s_logger.debug("Calibrate used cpu for host: " + host.getId() + " old usedCpu:"
+                            + cpuCap.getUsedCapacity() + " new usedCpu:" + usedCpu);
+                    cpuCap.setUsedCapacity(usedCpu);
+                }
         	}
 
+            if (memCap.getTotalCapacity() != host.getTotalMemory()) {
+                s_logger.debug("Calibrate total memory for host: " + host.getId() + " old total memory:"
+                        + memCap.getTotalCapacity() + " new total memory:" + host.getTotalMemory());
+                memCap.setTotalCapacity(host.getTotalMemory());
+
+            }
+
 	        if (memCap.getUsedCapacity() == usedMemory && memCap.getReservedCapacity() == reservedMemory) {
 	            s_logger.debug("No need to calibrate memory capacity, host:" + host.getId() + " usedMem: " + memCap.getUsedCapacity()
 	                    + " reservedMem: " + memCap.getReservedCapacity());
-	        } else if (memCap.getReservedCapacity() != reservedMemory) {
-	            s_logger.debug("Calibrate reserved memory for host: " + host.getId() + " old reservedMem:" + memCap.getReservedCapacity()
-	                    + " new reservedMem:" + reservedMemory);
-	            memCap.setReservedCapacity(reservedMemory);
-	        } else if (memCap.getUsedCapacity() != usedMemory) {
-	            /*
-	             * Didn't calibrate for used memory, because VMs can be in state(starting/migrating) that I don't know on which host they are
-	             * allocated
-	             */
-	            s_logger.debug("Calibrate used memory for host: " + host.getId() + " old usedMem: " + memCap.getUsedCapacity()
-	                    + " new usedMem: " + usedMemory);
-	            memCap.setUsedCapacity(usedMemory);
+            } else {
+                if (memCap.getReservedCapacity() != reservedMemory) {
+                    s_logger.debug("Calibrate reserved memory for host: " + host.getId() + " old reservedMem:"
+                            + memCap.getReservedCapacity() + " new reservedMem:" + reservedMemory);
+                    memCap.setReservedCapacity(reservedMemory);
+                }
+                if (memCap.getUsedCapacity() != usedMemory) {
+                    /*
+                     * Didn't calibrate for used memory, because VMs can be in
+                     * state(starting/migrating) that I don't know on which host
+                     * they are allocated
+                     */
+                    s_logger.debug("Calibrate used memory for host: " + host.getId() + " old usedMem: "
+                            + memCap.getUsedCapacity() + " new usedMem: " + usedMemory);
+                    memCap.setUsedCapacity(usedMemory);
+                }
 	        }
 
 	        try {