DaanHoogland commented on code in PR #5909:
URL: https://github.com/apache/cloudstack/pull/5909#discussion_r951238325
##########
framework/quota/src/main/java/org/apache/cloudstack/quota/QuotaManagerImpl.java:
##########
@@ -133,342 +152,408 @@ public boolean stop() {
return true;
}
- public List<QuotaUsageVO> aggregatePendingQuotaRecordsForAccount(final
AccountVO account, final Pair<List<? extends UsageVO>, Integer> usageRecords) {
- List<QuotaUsageVO> quotaListForAccount = new ArrayList<>();
- if (usageRecords == null || usageRecords.first() == null ||
usageRecords.first().isEmpty()) {
- return quotaListForAccount;
+ protected void processQuotaBalanceForAccount(AccountVO accountVo,
List<QuotaUsageVO> accountQuotaUsages) {
+ String accountToString = accountVo.reflectionToString();
+
+ if (CollectionUtils.isEmpty(accountQuotaUsages)) {
+ s_logger.info(String.format("Account [%s] does not have quota
usages to process. Skipping it.", accountToString));
+ return;
}
- s_logger.info("Getting pending quota records for account=" +
account.getAccountName());
- for (UsageVO usageRecord : usageRecords.first()) {
- switch (usageRecord.getUsageType()) {
- case QuotaTypes.RUNNING_VM:
- List<QuotaUsageVO> lq = updateQuotaRunningVMUsage(usageRecord);
- if (!lq.isEmpty()) {
- quotaListForAccount.addAll(lq);
- }
- break;
- case QuotaTypes.ALLOCATED_VM:
- QuotaUsageVO qu = updateQuotaAllocatedVMUsage(usageRecord);
- if (qu != null) {
- quotaListForAccount.add(qu);
- }
- break;
- case QuotaTypes.SNAPSHOT:
- case QuotaTypes.TEMPLATE:
- case QuotaTypes.ISO:
- case QuotaTypes.VOLUME:
- case QuotaTypes.VM_SNAPSHOT:
- case QuotaTypes.BACKUP:
- qu = updateQuotaDiskUsage(usageRecord,
usageRecord.getUsageType());
- if (qu != null) {
- quotaListForAccount.add(qu);
- }
- break;
- case QuotaTypes.LOAD_BALANCER_POLICY:
- case QuotaTypes.PORT_FORWARDING_RULE:
- case QuotaTypes.IP_ADDRESS:
- case QuotaTypes.NETWORK_OFFERING:
- case QuotaTypes.SECURITY_GROUP:
- case QuotaTypes.VPN_USERS:
- qu = updateQuotaRaw(usageRecord, usageRecord.getUsageType());
- if (qu != null) {
- quotaListForAccount.add(qu);
- }
- break;
- case QuotaTypes.NETWORK_BYTES_RECEIVED:
- case QuotaTypes.NETWORK_BYTES_SENT:
- qu = updateQuotaNetwork(usageRecord,
usageRecord.getUsageType());
- if (qu != null) {
- quotaListForAccount.add(qu);
- }
- break;
- case QuotaTypes.VM_DISK_IO_READ:
- case QuotaTypes.VM_DISK_IO_WRITE:
- case QuotaTypes.VM_DISK_BYTES_READ:
- case QuotaTypes.VM_DISK_BYTES_WRITE:
- default:
- break;
+
+ QuotaUsageVO firstQuotaUsage = accountQuotaUsages.get(0);
+ Date startDate = firstQuotaUsage.getStartDate();
+ Date endDate = firstQuotaUsage.getStartDate();
+
+ s_logger.debug(String.format("Processing quota balance for account
[%s] between [%s] and [%s].", accountToString, startDate,
+ accountQuotaUsages.get(accountQuotaUsages.size() -
1).getEndDate()));
Review Comment:
should this be debug?
```suggestion
s_logger.info(String.format("Processing quota balance for account
[%s] between [%s] and [%s].", accountToString, startDate,
accountQuotaUsages.get(accountQuotaUsages.size() -
1).getEndDate()));
```
or
```suggestion
if(s_logger.isDebugEnabled()) {
s_logger.debug(String.format("Processing quota balance for
account [%s] between [%s] and [%s].", accountToString, startDate,
accountQuotaUsages.get(accountQuotaUsages.size() -
1).getEndDate()));
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]