Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C1D9F10F4A for ; Tue, 2 Jul 2013 23:37:20 +0000 (UTC) Received: (qmail 81303 invoked by uid 500); 2 Jul 2013 23:37:20 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 81285 invoked by uid 500); 2 Jul 2013 23:37:20 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 81278 invoked by uid 99); 2 Jul 2013 23:37:20 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Jul 2013 23:37:20 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 01F2A552EF; Tue, 2 Jul 2013 23:37:19 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: prachidamle@apache.org To: commits@cloudstack.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: git commit: updated refs/heads/master to 8780fef Date: Tue, 2 Jul 2013 23:37:19 +0000 (UTC) Updated Branches: refs/heads/master 1bdb80a20 -> 8780fef05 CLOUDSTACK-3047 java.lang.NullPointerException encountered when executing capacityChecker thread. Changes: - Added null check around clusterId, since its possible to have null clusterId for storagepool and host records Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/8780fef0 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/8780fef0 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/8780fef0 Branch: refs/heads/master Commit: 8780fef05a9d3e3ca23b14ae5cb7d3a00b2eec14 Parents: 1bdb80a Author: Prachi Damle Authored: Tue Jul 2 16:36:03 2013 -0700 Committer: Prachi Damle Committed: Tue Jul 2 16:36:58 2013 -0700 ---------------------------------------------------------------------- .../com/cloud/capacity/CapacityManagerImpl.java | 13 ++++++++++--- .../com/cloud/storage/StorageManagerImpl.java | 20 ++++++++++++++------ 2 files changed, 24 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8780fef0/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 7a94c78..b2f10f2 100755 --- a/server/src/com/cloud/capacity/CapacityManagerImpl.java +++ b/server/src/com/cloud/capacity/CapacityManagerImpl.java @@ -47,6 +47,7 @@ import com.cloud.configuration.Config; import com.cloud.configuration.ConfigurationManager; import com.cloud.configuration.dao.ConfigurationDao; import com.cloud.dc.ClusterDetailsDao; +import com.cloud.dc.ClusterVO; import com.cloud.dc.dao.ClusterDao; import com.cloud.exception.ConnectionException; import com.cloud.host.Host; @@ -623,15 +624,21 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager, } }else { Transaction txn = Transaction.currentTxn(); - CapacityState capacityState = _configMgr.findClusterAllocationState(ApiDBUtils.findClusterById(host.getClusterId())) == AllocationState.Disabled ? - CapacityState.Disabled : CapacityState.Enabled; txn.start(); CapacityVO capacity = new CapacityVO(host.getId(), host.getDataCenterId(), host.getPodId(), host.getClusterId(), usedMemory, host.getTotalMemory(), CapacityVO.CAPACITY_TYPE_MEMORY); capacity.setReservedCapacity(reservedMemory); - capacity.setCapacityState(capacityState); + CapacityState capacityState = CapacityState.Enabled; + if (host.getClusterId() != null) { + ClusterVO cluster = ApiDBUtils.findClusterById(host.getClusterId()); + if (cluster != null) { + capacityState = _configMgr.findClusterAllocationState(cluster) == AllocationState.Disabled ? CapacityState.Disabled + : CapacityState.Enabled; + capacity.setCapacityState(capacityState); + } + } _capacityDao.persist(capacity); capacity = new CapacityVO( http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8780fef0/server/src/com/cloud/storage/StorageManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index bb21afb..6499e49 100755 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -892,16 +892,24 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C if (capacities.size() == 0) { CapacityVO capacity = new CapacityVO(storagePool.getId(), storagePool.getDataCenterId(), storagePool.getPodId(), storagePool.getClusterId(), allocated, totalOverProvCapacity, capacityType); - AllocationState allocationState = null; + if (storagePool.getScope() == ScopeType.ZONE) { DataCenterVO dc = ApiDBUtils.findZoneById(storagePool.getDataCenterId()); - allocationState = dc.getAllocationState(); + AllocationState allocationState = dc.getAllocationState(); + CapacityState capacityState = (allocationState == AllocationState.Disabled) ? CapacityState.Disabled + : CapacityState.Enabled; + capacity.setCapacityState(capacityState); } else { - allocationState = _configMgr.findClusterAllocationState(ApiDBUtils.findClusterById(storagePool.getClusterId())); + if (storagePool.getClusterId() != null) { + ClusterVO cluster = ApiDBUtils.findClusterById(storagePool.getClusterId()); + if (cluster != null) { + AllocationState allocationState = _configMgr.findClusterAllocationState(cluster); + CapacityState capacityState = (allocationState == AllocationState.Disabled) ? CapacityState.Disabled + : CapacityState.Enabled; + capacity.setCapacityState(capacityState); + } + } } - CapacityState capacityState = (allocationState == AllocationState.Disabled) ? CapacityState.Disabled : CapacityState.Enabled; - - capacity.setCapacityState(capacityState); _capacityDao.persist(capacity); } else { CapacityVO capacity = capacities.get(0);