Skip older records which generate negative duration usage

This commit is contained in:
Kishan Kavala 2014-11-20 17:34:44 +05:30
parent 4ac96d637c
commit 84c25f7025
9 changed files with 45 additions and 0 deletions

View File

@ -101,6 +101,11 @@ public class IPAddressUsageParser {
IpAssignDate = startDate;
}
if (IpAssignDate.after(endDate)) {
//Ignore records created after endDate
continue;
}
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)
updateIpUsageData(usageMap, key, usageIp.getId(), currentDuration);

View File

@ -98,6 +98,11 @@ public class LoadBalancerUsageParser {
lbCreateDate = startDate;
}
if (lbCreateDate.after(endDate)) {
//Ignore records created after endDate
continue;
}
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)
updateLBUsageData(usageMap, key, usageLB.getId(), currentDuration);

View File

@ -99,6 +99,11 @@ public class NetworkOfferingUsageParser {
noCreateDate = startDate;
}
if (noCreateDate.after(endDate)) {
//Ignore records created after endDate
continue;
}
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)
updateNOUsageData(usageMap, key, usageNO.getVmInstanceId(), currentDuration);

View File

@ -98,6 +98,11 @@ public class PortForwardingUsageParser {
pfCreateDate = startDate;
}
if (pfCreateDate.after(endDate)) {
//Ignore records created after endDate
continue;
}
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)
updatePFUsageData(usageMap, key, usagePF.getId(), currentDuration);

View File

@ -99,6 +99,11 @@ public class SecurityGroupUsageParser {
sgCreateDate = startDate;
}
if (sgCreateDate.after(endDate)) {
//Ignore records created after endDate
continue;
}
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)
updateSGUsageData(usageMap, key, usageSG.getVmInstanceId(), currentDuration);

View File

@ -107,6 +107,11 @@ public class StorageUsageParser {
storageCreateDate = startDate;
}
if (storageCreateDate.after(endDate)) {
//Ignore records created after endDate
continue;
}
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)
updateStorageUsageData(usageMap, key, usageStorage.getId(), currentDuration);

View File

@ -104,6 +104,11 @@ public class VMInstanceUsageParser {
vmStartDate = startDate;
}
if (vmStartDate.after(endDate)) {
//Ignore records created after endDate
continue;
}
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)
switch (usageType) {

View File

@ -94,6 +94,11 @@ public class VPNUserUsageParser {
vuCreateDate = startDate;
}
if (vuCreateDate.after(endDate)) {
//Ignore records created after endDate
continue;
}
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)
updateVUUsageData(usageMap, key, usageVU.getUserId(), currentDuration);

View File

@ -103,6 +103,11 @@ public class VolumeUsageParser {
volCreateDate = startDate;
}
if (volCreateDate.after(endDate)) {
//Ignore records created after endDate
continue;
}
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)
updateVolUsageData(usageMap, key, usageVol.getId(), currentDuration);