Updated Branches:
refs/heads/4.2 80dd1e263 -> 3eacdb154
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
Conflicts:
server/src/com/cloud/capacity/CapacityManagerImpl.java
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/3eacdb15
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/3eacdb15
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/3eacdb15
Branch: refs/heads/4.2
Commit: 3eacdb1547f42ee69378503b5b27cbbf4f1baf9b
Parents: 80dd1e2
Author: Prachi Damle <[email protected]>
Authored: Thu Aug 15 17:44:07 2013 -0700
Committer: Prachi Damle <[email protected]>
Committed: Thu Aug 15 17:44:07 2013 -0700
----------------------------------------------------------------------
.../com/cloud/capacity/CapacityManagerImpl.java | 12 +++++++++---
.../com/cloud/storage/StorageManagerImpl.java | 20 ++++++++++++++------
2 files changed, 23 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3eacdb15/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 cf7f3c4..7dde12e 100755
--- a/server/src/com/cloud/capacity/CapacityManagerImpl.java
+++ b/server/src/com/cloud/capacity/CapacityManagerImpl.java
@@ -633,15 +633,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 clusterOfHost =
ApiDBUtils.findClusterById(host.getClusterId());
+ if (clusterOfHost != null) {
+ capacityState =
_configMgr.findClusterAllocationState(clusterOfHost) ==
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/3eacdb15/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 4ce134e..67e3b47 100755
--- a/server/src/com/cloud/storage/StorageManagerImpl.java
+++ b/server/src/com/cloud/storage/StorageManagerImpl.java
@@ -984,16 +984,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);