in src/main/java/org/apache/sling/commons/scheduler/impl/GaugesSupport.java [237:272]
private Long getOldestRunningJobMillis(final ConfigHolder configHolder,
final String threadPoolNameOrNull,
final String filterNameOrNull) {
final QuartzScheduler localQuartzScheduler = quartzScheduler;
if (localQuartzScheduler == null) {
// could happen during deactivation
return -1L;
}
Map<String, SchedulerProxy> schedulers = localQuartzScheduler.getSchedulers();
if (schedulers == null) {
// guessing this is should never happen - so just for paranoia
return -1L;
}
Date oldestDate = null;
if (filterNameOrNull == null && threadPoolNameOrNull != null) {
// if a threadPoolName is set and no filter then we go by
// threadPoolName
final SchedulerProxy schedulerProxy = schedulers.get(threadPoolNameOrNull);
oldestDate = getOldestRunningJobDate(configHolder, schedulerProxy, null);
} else {
// if nothing is set we iterate over everything
// if both threadPoolName and filter is set, filter has precedence
// (hence we iterate over everything but using the filter)
for (Map.Entry<String, SchedulerProxy> entry : schedulers.entrySet()) {
SchedulerProxy schedulerProxy = entry.getValue();
oldestDate = olderOf(oldestDate,
getOldestRunningJobDate(configHolder, schedulerProxy, filterNameOrNull));
}
}
if (oldestDate == null) {
return -1L;
} else {
return System.currentTimeMillis() - oldestDate.getTime();
}
}