Skip to content
This repository was archived by the owner on Jan 15, 2020. It is now read-only.

Commit 84c25f7

Browse files
committed
Skip older records which generate negative duration usage
1 parent 4ac96d6 commit 84c25f7

9 files changed

Lines changed: 45 additions & 0 deletions

usage/src/com/cloud/usage/parser/IPAddressUsageParser.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ public static boolean parse(AccountVO account, Date startDate, Date endDate) {
101101
IpAssignDate = startDate;
102102
}
103103

104+
if (IpAssignDate.after(endDate)) {
105+
//Ignore records created after endDate
106+
continue;
107+
}
108+
104109
long currentDuration = (IpReleaseDeleteDate.getTime() - IpAssignDate.getTime()) + 1; // make sure this is an inclusive check for milliseconds (i.e. use n - m + 1 to find total number of millis to charge)
105110

106111
updateIpUsageData(usageMap, key, usageIp.getId(), currentDuration);

usage/src/com/cloud/usage/parser/LoadBalancerUsageParser.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ public static boolean parse(AccountVO account, Date startDate, Date endDate) {
9898
lbCreateDate = startDate;
9999
}
100100

101+
if (lbCreateDate.after(endDate)) {
102+
//Ignore records created after endDate
103+
continue;
104+
}
105+
101106
long currentDuration = (lbDeleteDate.getTime() - lbCreateDate.getTime()) + 1; // make sure this is an inclusive check for milliseconds (i.e. use n - m + 1 to find total number of millis to charge)
102107

103108
updateLBUsageData(usageMap, key, usageLB.getId(), currentDuration);

usage/src/com/cloud/usage/parser/NetworkOfferingUsageParser.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ public static boolean parse(AccountVO account, Date startDate, Date endDate) {
9999
noCreateDate = startDate;
100100
}
101101

102+
if (noCreateDate.after(endDate)) {
103+
//Ignore records created after endDate
104+
continue;
105+
}
106+
102107
long currentDuration = (noDeleteDate.getTime() - noCreateDate.getTime()) + 1; // make sure this is an inclusive check for milliseconds (i.e. use n - m + 1 to find total number of millis to charge)
103108

104109
updateNOUsageData(usageMap, key, usageNO.getVmInstanceId(), currentDuration);

usage/src/com/cloud/usage/parser/PortForwardingUsageParser.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ public static boolean parse(AccountVO account, Date startDate, Date endDate) {
9898
pfCreateDate = startDate;
9999
}
100100

101+
if (pfCreateDate.after(endDate)) {
102+
//Ignore records created after endDate
103+
continue;
104+
}
105+
101106
long currentDuration = (pfDeleteDate.getTime() - pfCreateDate.getTime()) + 1; // make sure this is an inclusive check for milliseconds (i.e. use n - m + 1 to find total number of millis to charge)
102107

103108
updatePFUsageData(usageMap, key, usagePF.getId(), currentDuration);

usage/src/com/cloud/usage/parser/SecurityGroupUsageParser.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ public static boolean parse(AccountVO account, Date startDate, Date endDate) {
9999
sgCreateDate = startDate;
100100
}
101101

102+
if (sgCreateDate.after(endDate)) {
103+
//Ignore records created after endDate
104+
continue;
105+
}
106+
102107
long currentDuration = (sgDeleteDate.getTime() - sgCreateDate.getTime()) + 1; // make sure this is an inclusive check for milliseconds (i.e. use n - m + 1 to find total number of millis to charge)
103108

104109
updateSGUsageData(usageMap, key, usageSG.getVmInstanceId(), currentDuration);

usage/src/com/cloud/usage/parser/StorageUsageParser.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ public static boolean parse(AccountVO account, Date startDate, Date endDate) {
107107
storageCreateDate = startDate;
108108
}
109109

110+
if (storageCreateDate.after(endDate)) {
111+
//Ignore records created after endDate
112+
continue;
113+
}
114+
110115
long currentDuration = (storageDeleteDate.getTime() - storageCreateDate.getTime()) + 1; // make sure this is an inclusive check for milliseconds (i.e. use n - m + 1 to find total number of millis to charge)
111116

112117
updateStorageUsageData(usageMap, key, usageStorage.getId(), currentDuration);

usage/src/com/cloud/usage/parser/VMInstanceUsageParser.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ public static boolean parse(AccountVO account, Date startDate, Date endDate) {
104104
vmStartDate = startDate;
105105
}
106106

107+
if (vmStartDate.after(endDate)) {
108+
//Ignore records created after endDate
109+
continue;
110+
}
111+
107112
long currentDuration = (vmEndDate.getTime() - vmStartDate.getTime()) + 1; // make sure this is an inclusive check for milliseconds (i.e. use n - m + 1 to find total number of millis to charge)
108113

109114
switch (usageType) {

usage/src/com/cloud/usage/parser/VPNUserUsageParser.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ public static boolean parse(AccountVO account, Date startDate, Date endDate) {
9494
vuCreateDate = startDate;
9595
}
9696

97+
if (vuCreateDate.after(endDate)) {
98+
//Ignore records created after endDate
99+
continue;
100+
}
101+
97102
long currentDuration = (vuDeleteDate.getTime() - vuCreateDate.getTime()) + 1; // make sure this is an inclusive check for milliseconds (i.e. use n - m + 1 to find total number of millis to charge)
98103

99104
updateVUUsageData(usageMap, key, usageVU.getUserId(), currentDuration);

usage/src/com/cloud/usage/parser/VolumeUsageParser.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ public static boolean parse(AccountVO account, Date startDate, Date endDate) {
103103
volCreateDate = startDate;
104104
}
105105

106+
if (volCreateDate.after(endDate)) {
107+
//Ignore records created after endDate
108+
continue;
109+
}
110+
106111
long currentDuration = (volDeleteDate.getTime() - volCreateDate.getTime()) + 1; // make sure this is an inclusive check for milliseconds (i.e. use n - m + 1 to find total number of millis to charge)
107112

108113
updateVolUsageData(usageMap, key, usageVol.getId(), currentDuration);

0 commit comments

Comments
 (0)