bug 9419: implement api to reset resource count

This commit is contained in:
Murali Reddy 2011-06-13 16:32:26 +05:30
parent 8ae65de6b3
commit b625bb1d27
4 changed files with 10 additions and 9 deletions

View File

@ -163,7 +163,7 @@ public class SnapshotDaoImpl extends GenericDaoBase<SnapshotVO, Long> implements
CountSnapshotsByAccount = createSearchBuilder(Long.class);
CountSnapshotsByAccount.select(null, Func.COUNT, null);
CountSnapshotsByAccount.and("account", CountSnapshotsByAccount.entity().getAccountId(), SearchCriteria.Op.EQ);
CountSnapshotsByAccount.and("removed", CountSnapshotsByAccount.entity().getRemoved(), SearchCriteria.Op.NNULL);
CountSnapshotsByAccount.and("removed", CountSnapshotsByAccount.entity().getRemoved(), SearchCriteria.Op.NULL);
CountSnapshotsByAccount.done();
}

View File

@ -286,7 +286,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
CountTemplatesByAccount = createSearchBuilder(Long.class);
CountTemplatesByAccount.select(null, Func.COUNT, null);
CountTemplatesByAccount.and("account", CountTemplatesByAccount.entity().getAccountId(), SearchCriteria.Op.EQ);
CountTemplatesByAccount.and("removed", CountTemplatesByAccount.entity().getRemoved(), SearchCriteria.Op.NNULL);
CountTemplatesByAccount.and("removed", CountTemplatesByAccount.entity().getRemoved(), SearchCriteria.Op.NULL);
CountTemplatesByAccount.done();
return result;

View File

@ -793,13 +793,14 @@ public class AccountManagerImpl implements AccountManager, AccountService, Manag
for (DomainVO domainChild : domainChildren) {
long domainCount = updateDomainResourceCount(domainChild.getId(), type);
count = count + domainCount; // add the child domain count to parent domain count
List<AccountVO> accounts = _accountDao.findActiveAccountsForDomain(domainChild.getId());
for (AccountVO account : accounts) {
long accountCount = updateAccountResourceCount(account.getId(), type);
count = count + accountCount; // add account's resource count to parent domain count
}
}
List<AccountVO> accounts = _accountDao.findActiveAccountsForDomain(domain.getId());
for (AccountVO account : accounts) {
long accountCount = updateAccountResourceCount(account.getId(), type);
count = count + accountCount; // add account's resource count to parent domain count
}
_resourceCountDao.setDomainCount(domainId, type, count);
} catch (Exception e) {
throw new CloudRuntimeException("Failed to update resource count for domain with Id " + domainId);

View File

@ -66,7 +66,7 @@ public class AccountDaoImpl extends GenericDaoBase<AccountVO, Long> implements A
DomainAccountsSearch = createSearchBuilder();
DomainAccountsSearch.and("domainId", DomainAccountsSearch.entity().getDomainId(), SearchCriteria.Op.EQ);
DomainAccountsSearch.and("removed", DomainAccountsSearch.entity().getRemoved(), SearchCriteria.Op.NNULL);
DomainAccountsSearch.and("removed", DomainAccountsSearch.entity().getRemoved(), SearchCriteria.Op.NULL);
DomainAccountsSearch.done();
CleanupSearch = createSearchBuilder();