You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by we...@apache.org on 2015/01/12 12:26:54 UTC
git commit: updated refs/heads/master to b528047
Repository: cloudstack
Updated Branches:
refs/heads/master aaf6a34c5 -> b528047fb
CLOUDSTACK-8146: Resource count of primary storage does not consider the detached volumes
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/b528047f
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/b528047f
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/b528047f
Branch: refs/heads/master
Commit: b528047fb6f1c199e5e1cfe991a10b72a2b32a49
Parents: aaf6a34
Author: Wei Zhou <w....@tech.leaseweb.com>
Authored: Mon Jan 12 12:25:28 2015 +0100
Committer: Wei Zhou <w....@tech.leaseweb.com>
Committed: Mon Jan 12 12:25:28 2015 +0100
----------------------------------------------------------------------
.../com/cloud/storage/dao/VolumeDaoImpl.java | 21 +++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b528047f/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
index 24de717..61cce8d 100644
--- a/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
+++ b/engine/schema/src/com/cloud/storage/dao/VolumeDaoImpl.java
@@ -65,6 +65,7 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
protected final SearchBuilder<VolumeVO> AllFieldsSearch;
protected GenericSearchBuilder<VolumeVO, Long> CountByAccount;
protected GenericSearchBuilder<VolumeVO, SumCount> primaryStorageSearch;
+ protected GenericSearchBuilder<VolumeVO, SumCount> primaryStorageSearch2;
protected GenericSearchBuilder<VolumeVO, SumCount> secondaryStorageSearch;
@Inject
ResourceTagDao _tagsDao;
@@ -367,7 +368,6 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
primaryStorageSearch = createSearchBuilder(SumCount.class);
primaryStorageSearch.select("sum", Func.SUM, primaryStorageSearch.entity().getSize());
primaryStorageSearch.and("accountId", primaryStorageSearch.entity().getAccountId(), Op.EQ);
- primaryStorageSearch.and("virtualRouterVmIds", primaryStorageSearch.entity().getInstanceId(), Op.NIN);
primaryStorageSearch.and().op("path", primaryStorageSearch.entity().getPath(), Op.NNULL);
primaryStorageSearch.or("states", primaryStorageSearch.entity().getState(), Op.IN);
primaryStorageSearch.cp();
@@ -375,6 +375,18 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
primaryStorageSearch.and("isRemoved", primaryStorageSearch.entity().getRemoved(), Op.NULL);
primaryStorageSearch.done();
+ primaryStorageSearch2 = createSearchBuilder(SumCount.class);
+ primaryStorageSearch2.select("sum", Func.SUM, primaryStorageSearch2.entity().getSize());
+ primaryStorageSearch2.and("accountId", primaryStorageSearch2.entity().getAccountId(), Op.EQ);
+ primaryStorageSearch2.and().op("instanceId", primaryStorageSearch2.entity().getInstanceId(), Op.NULL);
+ primaryStorageSearch2.or("virtualRouterVmIds", primaryStorageSearch2.entity().getInstanceId(), Op.NIN);
+ primaryStorageSearch2.cp();
+ primaryStorageSearch2.and().op("path", primaryStorageSearch2.entity().getPath(), Op.NNULL);
+ primaryStorageSearch2.or("states", primaryStorageSearch2.entity().getState(), Op.IN);
+ primaryStorageSearch2.cp();
+ primaryStorageSearch2.and("displayVolume", primaryStorageSearch2.entity().isDisplayVolume(), Op.EQ);
+ primaryStorageSearch2.and("isRemoved", primaryStorageSearch2.entity().getRemoved(), Op.NULL);
+
secondaryStorageSearch = createSearchBuilder(SumCount.class);
secondaryStorageSearch.select("sum", Func.SUM, secondaryStorageSearch.entity().getSize());
secondaryStorageSearch.and("accountId", secondaryStorageSearch.entity().getAccountId(), Op.EQ);
@@ -405,11 +417,14 @@ public class VolumeDaoImpl extends GenericDaoBase<VolumeVO, Long> implements Vol
@Override
public long primaryStorageUsedForAccount(long accountId, List<Long> virtualRouters) {
- SearchCriteria<SumCount> sc = primaryStorageSearch.create();
- sc.setParameters("accountId", accountId);
+ SearchCriteria<SumCount> sc;
if (!virtualRouters.isEmpty()) {
+ sc = primaryStorageSearch2.create();
sc.setParameters("virtualRouterVmIds", virtualRouters.toArray(new Object[virtualRouters.size()]));
+ } else {
+ sc = primaryStorageSearch.create();
}
+ sc.setParameters("accountId", accountId);
sc.setParameters("states", State.Allocated);
sc.setParameters("displayVolume", 1);
List<SumCount> storageSpace = customSearch(sc, null);