if (__log.isDebugEnabled()) __log.debug("loaded "+jobs.size()+" jobs from db");
long delayedTime = System.currentTimeMillis() - _warningDelay;
int delayedCount = 0;
boolean runningLate;
AbsoluteTimeDateFormat f = new AbsoluteTimeDateFormat();
for (Job j : jobs) {
// jobs might have been enqueued by #addTodoOnCommit meanwhile
if (_outstandingJobs.size() >= _todoLimit){
if (__log.isDebugEnabled()) __log.debug("Max capacity reached: "+_outstandingJobs.size()+" jobs dispacthed i.e. queued or being executed");
break;
}
runningLate = j.schedDate <= delayedTime;
if (runningLate) {
delayedCount++;
}
if (__log.isDebugEnabled())
__log.debug("todo.enqueue job from db: " + j.jobId.trim() + " for " + j.schedDate + "(" + f.format(j.schedDate)+") "+(runningLate?" delayed=true":""));
enqueue(j);
}
if (delayedCount > 0) {
__log.warn("Dispatching jobs with more than "+(_warningDelay/60000)+" minutes delay. Either the server was down for some time or the job load is greater than available capacity");
}