Github user bhaisaab commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/768#discussion_r41699441
  
    --- Diff: engine/schema/src/com/cloud/usage/dao/UsageDaoImpl.java ---
    @@ -469,4 +469,35 @@ public void removeOldUsageRecords(int days) {
                 txn.close();
             }
         }
    +
    +    @SuppressWarnings("deprecation")
    +    public Pair<List<? extends UsageVO>, Integer> 
getUsageRecordsPendingQuotaAggregation(final long accountId, final long 
domainId) {
    +        if (s_logger.isDebugEnabled()){
    +            s_logger.debug("Getting usage records for account: " + 
accountId + ", domainId: " + domainId);
    +        }
    +        final short opendb = 
TransactionLegacy.currentTxn().getDatabaseId();
    +        Pair<List<UsageVO>, Integer> usageRecords = new 
Pair<List<UsageVO>, Integer>(new ArrayList<UsageVO>(), 0);
    +        try {
    +            TransactionLegacy.open(TransactionLegacy.USAGE_DB).close();
    +            Filter usageFilter = new Filter(UsageVO.class, "startDate", 
true, 0L, 10000L);
    +            SearchCriteria<UsageVO> sc = createSearchCriteria();
    +            if (accountId != -1) {
    +                sc.addAnd("accountId", SearchCriteria.Op.EQ, accountId);
    +            }
    +            if (domainId != -1) {
    +                sc.addAnd("domainId", SearchCriteria.Op.EQ, domainId);
    +            }
    +            sc.addAnd("quotaCalculated", SearchCriteria.Op.NULL);
    +            sc.addOr("quotaCalculated", SearchCriteria.Op.EQ, 0);
    +            if (s_logger.isDebugEnabled()){
    +                s_logger.debug("Getting usage records" + 
usageFilter.getOrderBy());
    +            }
    +            usageRecords = searchAndCountAllRecords(sc, usageFilter);
    +        } catch (Exception e) {
    --- End diff --
    
    Good idea, we'll need to switch back the database which is why we have the 
finally. We'll throw exception again in the catch{} block instead of ignoring 
it. Fixed now.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to