rhtyd commented on a change in pull request #5259:
URL: https://github.com/apache/cloudstack/pull/5259#discussion_r692881237



##########
File path: usage/src/main/java/com/cloud/usage/parser/BackupUsageParser.java
##########
@@ -68,18 +68,7 @@ public static boolean parse(AccountVO account, Date 
startDate, Date endDate) {
             return true;
         }
 
-        final Map<Long, BackupInfo> vmUsageMap = new HashMap<>();
-        for (final UsageBackupVO usageBackup : usageBackups) {
-            final Long vmId = usageBackup.getVmId();
-            final Long zoneId = usageBackup.getZoneId();
-            final Long offeringId = usageBackup.getBackupOfferingId();
-            if (vmUsageMap.get(vmId) == null) {
-                vmUsageMap.put(vmId, new BackupUsageParser.BackupInfo(new 
Backup.Metric(0L, 0L), zoneId, vmId, offeringId));
-            }
-            final Backup.Metric metric = vmUsageMap.get(vmId).getMetric();
-            metric.setBackupSize(metric.getBackupSize() + 
usageBackup.getSize());
-            metric.setDataSize(metric.getDataSize() + 
usageBackup.getProtectedSize());
-        }
+        Map<String, BackupInfo> vmUsageMap = getVmUsageMap(usageBackups);

Review comment:
       @weizhouapache should we handle it by ensure everytime the offering is 
changed, a usage event is handled? How does other resources say VM handle this 
when their offerings are changed, maybe we should follow the same logic? (I've 
not checked, so maybe your approach is in-line with that)




-- 
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]


Reply via email to