You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2021/08/19 07:19:13 UTC

[GitHub] [cloudstack] DaanHoogland commented on a change in pull request #5259: usage: create backup usage record for vmId-offeringId pair

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



##########
File path: usage/src/main/java/com/cloud/usage/parser/BackupUsageParser.java
##########
@@ -100,6 +89,32 @@ public static boolean parse(AccountVO account, Date startDate, Date endDate) {
         return true;
     }
 
+    protected static final Map<String, BackupInfo> getVmUsageMap(final List<UsageBackupVO> usageBackups) {
+        final Map<Long, Long> vmOffering = new HashMap<Long, Long>();
+        final Map<Long, Integer> vmOfferingIndex = new HashMap<Long, Integer>();
+        final Map<String, BackupInfo> vmUsageMap = new HashMap<>();
+        for (final UsageBackupVO usageBackup : usageBackups) {
+            final Long vmId = usageBackup.getVmId();
+            final Long zoneId = usageBackup.getZoneId();
+            final Long offeringId = usageBackup.getBackupOfferingId();
+            Integer index = vmOfferingIndex.get(vmId) == null ? -1 : vmOfferingIndex.get(vmId);
+            boolean isVmOfferingEqualsToPrevious = vmOffering.get(vmId) != null && vmOffering.get(vmId) == offeringId;

Review comment:
       maybe also change the name to `isVmOfferingEqualToPrevious`, without the 3rd person singular 's'. Also the name `vmOfferingEqualsToPrevious` is better.

##########
File path: usage/src/main/java/com/cloud/usage/parser/BackupUsageParser.java
##########
@@ -100,6 +89,32 @@ public static boolean parse(AccountVO account, Date startDate, Date endDate) {
         return true;
     }
 
+    protected static final Map<String, BackupInfo> getVmUsageMap(final List<UsageBackupVO> usageBackups) {
+        final Map<Long, Long> vmOffering = new HashMap<Long, Long>();
+        final Map<Long, Integer> vmOfferingIndex = new HashMap<Long, Integer>();
+        final Map<String, BackupInfo> vmUsageMap = new HashMap<>();
+        for (final UsageBackupVO usageBackup : usageBackups) {
+            final Long vmId = usageBackup.getVmId();
+            final Long zoneId = usageBackup.getZoneId();
+            final Long offeringId = usageBackup.getBackupOfferingId();
+            Integer index = vmOfferingIndex.get(vmId) == null ? -1 : vmOfferingIndex.get(vmId);
+            boolean isVmOfferingEqualsToPrevious = vmOffering.get(vmId) != null && vmOffering.get(vmId) == offeringId;

Review comment:
       ```suggestion
               boolean isVmOfferingEqualsToPrevious = offeringId.equals(vmOffering.get(vmId));
   ```




-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org