Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion usage/src/main/java/com/cloud/usage/UsageManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public class UsageManagerImpl extends ManagerBase implements UsageManager, Runna
private static final int HOURLY_TIME = 60;
private static final int DAILY_TIME = 60 * 24;
private static final int THREE_DAYS_IN_MINUTES = 60 * 24 * 3;
private static final long MAX_EVENT_REWIND_MILLIS = 24L * 60 * 60 * 1000;

@Inject
private AccountDao _accountDao;
Expand Down Expand Up @@ -699,7 +700,10 @@ public void parse(UsageJobVO job, long startDateMillis, long endDateMillis) {
if ((events != null) && (events.size() > 0)) {
Date oldestEventDate = events.get(0).getCreateDate();
if (oldestEventDate.getTime() < startDateMillis) {
startDateMillis = oldestEventDate.getTime();
// Bound the rewind so a single un-processable event cannot pin the
// aggregation window to an arbitrarily old date and cause unbounded
// re-aggregation of the entire history on every run.
startDateMillis = Math.max(oldestEventDate.getTime(), startDateMillis - MAX_EVENT_REWIND_MILLIS);
startDate = new Date(startDateMillis);
}

Expand Down