You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by da...@apache.org on 2014/01/25 23:27:25 UTC

git commit: updated refs/heads/4.3-forward to 43ba36f

Updated Branches:
  refs/heads/4.3-forward c307de312 -> 43ba36f97


nullpointer dereference guarded

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

Branch: refs/heads/4.3-forward
Commit: 43ba36f97950aa8d09399a28bb50c6a22209f15e
Parents: c307de3
Author: Daan Hoogland <da...@onecht.net>
Authored: Sat Jan 25 23:26:53 2014 +0100
Committer: Daan Hoogland <da...@onecht.net>
Committed: Sat Jan 25 23:26:53 2014 +0100

----------------------------------------------------------------------
 .../impl/UserConcentratedAllocator.java         | 58 ++++++++------------
 1 file changed, 24 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43ba36f9/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java b/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java
index 3f1994e..8101da9 100755
--- a/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java
+++ b/server/src/com/cloud/agent/manager/allocator/impl/UserConcentratedAllocator.java
@@ -32,30 +32,18 @@ import org.apache.log4j.Logger;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 
 import com.cloud.agent.manager.allocator.PodAllocator;
-import com.cloud.capacity.CapacityVO;
-import com.cloud.capacity.dao.CapacityDao;
 import com.cloud.dc.DataCenter;
-import com.cloud.dc.HostPodVO;
 import com.cloud.dc.Pod;
-import com.cloud.dc.dao.HostPodDao;
 import com.cloud.offering.ServiceOffering;
-import com.cloud.service.dao.ServiceOfferingDao;
-import com.cloud.storage.VolumeVO;
-import com.cloud.storage.dao.VMTemplatePoolDao;
-import com.cloud.storage.dao.VolumeDao;
 import com.cloud.template.VirtualMachineTemplate;
 import com.cloud.utils.DateUtil;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.Pair;
 import com.cloud.utils.component.AdapterBase;
 import com.cloud.utils.db.SearchCriteria;
-import com.cloud.vm.UserVmVO;
-import com.cloud.vm.VMInstanceVO;
 import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachine.State;
 import com.cloud.vm.VirtualMachineProfile;
-import com.cloud.vm.dao.UserVmDao;
-import com.cloud.vm.dao.VMInstanceDao;
 
 @Local(value = PodAllocator.class)
 public class UserConcentratedAllocator extends AdapterBase implements PodAllocator {
@@ -246,35 +234,37 @@ public class UserConcentratedAllocator extends AdapterBase implements PodAllocat
         // List<VMInstanceVO> vms = _vmInstanceDao.listByLastHostId(hostId);
         List<VMInstanceVO> vms = null;
         long usedCapacity = 0;
-        for (VMInstanceVO vm : vms) {
-            if (skipCalculation(vm)) {
-                continue;
-            }
+        if (vms != null) {
+            for (VMInstanceVO vm : vms) {
+                if (skipCalculation(vm)) {
+                    continue;
+                }
 
-            ServiceOffering so = null;
+                ServiceOffering so = null;
 
-            if (vm.getType() == VirtualMachine.Type.User) {
-                UserVmVO userVm = _vmDao.findById(vm.getId());
-                if (userVm == null) {
-                    continue;
+                if (vm.getType() == VirtualMachine.Type.User) {
+                    UserVmVO userVm = _vmDao.findById(vm.getId());
+                    if (userVm == null) {
+                        continue;
+                    }
                 }
-            }
 
-            so = _offeringDao.findById(vm.getId(), vm.getServiceOfferingId());
+                so = _offeringDao.findById(vm.getId(), vm.getServiceOfferingId());
 
-            if (capacityType == CapacityVO.CAPACITY_TYPE_MEMORY) {
-                usedCapacity += so.getRamSize() * 1024L * 1024L;
+                if (capacityType == CapacityVO.CAPACITY_TYPE_MEMORY) {
+                    usedCapacity += so.getRamSize() * 1024L * 1024L;
 
-                if (s_logger.isDebugEnabled()) {
-                    s_logger.debug("Counting memory capacity used by vm: " + vm.getId() + ", size: " + so.getRamSize() + "MB, host: " + hostId
-                            + ", currently counted: " + usedCapacity + " Bytes");
-                }
-            } else if (capacityType == CapacityVO.CAPACITY_TYPE_CPU) {
-                usedCapacity += so.getCpu() * so.getSpeed();
+                    if (s_logger.isDebugEnabled()) {
+                        s_logger.debug("Counting memory capacity used by vm: " + vm.getId() + ", size: " + so.getRamSize() + "MB, host: " + hostId
+                                + ", currently counted: " + usedCapacity + " Bytes");
+                    }
+                } else if (capacityType == CapacityVO.CAPACITY_TYPE_CPU) {
+                    usedCapacity += so.getCpu() * so.getSpeed();
 
-                if (s_logger.isDebugEnabled()) {
-                    s_logger.debug("Counting cpu capacity used by vm: " + vm.getId() + ", cpu: " + so.getCpu() + ", speed: " + so.getSpeed()
-                            + ", currently counted: " + usedCapacity + " Bytes");
+                    if (s_logger.isDebugEnabled()) {
+                        s_logger.debug("Counting cpu capacity used by vm: " + vm.getId() + ", cpu: " + so.getCpu() + ", speed: " + so.getSpeed()
+                                + ", currently counted: " + usedCapacity + " Bytes");
+                    }
                 }
             }
         }