cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [02/11] git commit: updated refs/heads/4.3 to d6bbfbb
Date Wed, 29 Jan 2014 20:59:33 GMT
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/5296c12d
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/5296c12d
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/5296c12d

Branch: refs/heads/4.3
Commit: 5296c12d2ad87c24a69cafae6a444b650f258485
Parents: da80eaf
Author: Daan Hoogland <daan@onecht.net>
Authored: Sat Jan 25 23:26:53 2014 +0100
Committer: Daan Hoogland <dhoogland@schubergphilis.com>
Committed: Wed Jan 29 21:27:49 2014 +0100

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


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5296c12d/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");
+                    }
                 }
             }
         }


Mime
View raw message