CLOUDSTACK-3089 [ZWPS] NPE while cancelling the Storage Maintenance Signed-off-by: Edison Su <sudi...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/d660bc7e Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/d660bc7e Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/d660bc7e Branch: refs/heads/vmsync Commit: d660bc7e8da57d94049d55e53ffe18df8016e4e5 Parents: 2bc4cbf Author: Rajesh Battala <rajesh.batt...@citrix.com> Authored: Fri Jun 28 14:31:33 2013 +0530 Committer: Edison Su <sudi...@gmail.com> Committed: Tue Jul 2 11:51:16 2013 -0700 ---------------------------------------------------------------------- .../cloud/storage/StoragePoolAutomationImpl.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d660bc7e/server/src/com/cloud/storage/StoragePoolAutomationImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/storage/StoragePoolAutomationImpl.java b/server/src/com/cloud/storage/StoragePoolAutomationImpl.java index b2cb1f5..f6b39f1 100644 --- a/server/src/com/cloud/storage/StoragePoolAutomationImpl.java +++ b/server/src/com/cloud/storage/StoragePoolAutomationImpl.java @@ -23,12 +23,7 @@ import java.util.List; import javax.inject.Inject; -import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; -import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle; -import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; -import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider; -import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager; -import org.apache.cloudstack.engine.subsystem.api.storage.Scope; +import org.apache.cloudstack.engine.subsystem.api.storage.*; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; import org.apache.log4j.Logger; @@ -137,6 +132,7 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation { //Handeling the Zone wide and cluster wide primay storage List<HostVO> hosts = new ArrayList<HostVO>(); // if the storage scope is ZONE wide, then get all the hosts for which hypervisor ZWSP created to send Modifystoragepoolcommand + //TODO: if it's zone wide, this code will list a lot of hosts in the zone, which may cause performance/OOM issue. if (pool.getScope().equals(ScopeType.ZONE)) { hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(pool.getHypervisor() , pool.getDataCenterId()); } else { @@ -366,8 +362,16 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation { .findById(store.getId()); StoragePool pool = (StoragePool)store; - List<HostVO> hosts = _resourceMgr.listHostsInClusterByStatus( + //Handeling the Zone wide and cluster wide primay storage + List<HostVO> hosts = new ArrayList<HostVO>(); + // if the storage scope is ZONE wide, then get all the hosts for which hypervisor ZWSP created to send Modifystoragepoolcommand + if (poolVO.getScope().equals(ScopeType.ZONE)) { + hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(poolVO.getHypervisor(), pool.getDataCenterId()); + } else { + hosts = _resourceMgr.listHostsInClusterByStatus( pool.getClusterId(), Status.Up); + } + if (hosts == null || hosts.size() == 0) { return true; }