mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Skip older records which generate negative duration usage
This commit is contained in:
parent
4ac96d637c
commit
84c25f7025
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user