if (entity == null) {
LOG.warn("No entity for " + key);
continue;
}
Date startTime = EntityUtil.getStartTime(entity, cluster);
Frequency frequency = EntityUtil.getFrequency(entity);
TimeZone timeZone = EntityUtil.getTimeZone(entity);
Date nextStart = EntityUtil.getNextStartTime(startTime, frequency, timeZone, now);
if (nextStart.after(windowEndTime)) continue;
ConcurrentMap<Date, Date> pendingInstances = pendingJobs.get(key);
while (!nextStart.after(windowEndTime)) {
if (pendingInstances == null) {
pendingJobs.putIfAbsent(key, new ConcurrentHashMap<Date, Date>());
pendingInstances = pendingJobs.get(key);
}
Long latency = monitoredEntities.get(key);
if (latency == null) break;
pendingInstances.putIfAbsent(nextStart, new Date(nextStart.getTime() +
latency * 1500)); //1.5 times latency is when it is supposed to have breached
LOG.debug("Adding to pending jobs: " + key + " ---> " +
SchemaHelper.formatDateUTC(nextStart));
Calendar startCal = Calendar.getInstance(timeZone);
startCal.setTime(nextStart);
startCal.add(frequency.getTimeUnit().getCalendarUnit(), frequency.getFrequency());
nextStart = startCal.getTime();
}
}
}