boolean batchIsExhausted = false;
while(batchIsExhausted != true) {
// TODO: make this use a semaphore
Job job = readyQueue.getNextJob();
if(job == null) {
if(runQueue.getRunningJobCount() <= 0) {
if(checkIfAnyJobIsReady() == false) {
logger.info("all queues exhausted.");
batchIsExhausted = true;
}
}
} else {
// this is blocking
if(runQueue.hasCapacity()) {
runQueue.addJob(job);
} else {
logger.error("*** WE SHOULD NEVER GET HERE** [" + job.getName() + "]");
}
}
}
runQueue.waitForCompletion();