Return-Path: X-Original-To: apmail-cloudstack-dev-archive@www.apache.org Delivered-To: apmail-cloudstack-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 43CF4177B5 for ; Sat, 10 Oct 2015 17:39:03 +0000 (UTC) Received: (qmail 36063 invoked by uid 500); 10 Oct 2015 17:38:57 -0000 Delivered-To: apmail-cloudstack-dev-archive@cloudstack.apache.org Received: (qmail 36005 invoked by uid 500); 10 Oct 2015 17:38:57 -0000 Mailing-List: contact dev-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list dev@cloudstack.apache.org Received: (qmail 35994 invoked by uid 99); 10 Oct 2015 17:38:57 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 10 Oct 2015 17:38:57 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 7D572DFFC2; Sat, 10 Oct 2015 17:38:57 +0000 (UTC) From: bhaisaab To: dev@cloudstack.apache.org Reply-To: dev@cloudstack.apache.org References: In-Reply-To: Subject: [GitHub] cloudstack pull request: Quota Content-Type: text/plain Message-Id: <20151010173857.7D572DFFC2@git1-us-west.apache.org> Date: Sat, 10 Oct 2015 17:38:57 +0000 (UTC) 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, 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, Integer> usageRecords = new Pair, Integer>(new ArrayList(), 0); + try { + TransactionLegacy.open(TransactionLegacy.USAGE_DB).close(); + Filter usageFilter = new Filter(UsageVO.class, "startDate", true, 0L, 10000L); + SearchCriteria 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 infrastructure@apache.org or file a JIRA ticket with INFRA. ---