expose some stats useful for throttling (# ready & waiting jobs and the max lag of those jobs)

This commit is contained in:
jrandom
2004-07-09 03:39:38 +00:00
committed by zzz
parent 9685884279
commit ff7742bca3

View File

@ -186,6 +186,20 @@ public class JobQueue {
return;
}
public int getReadyCount() {
synchronized (_readyJobs) {
return _readyJobs.size();
}
}
public long getMaxLag() {
synchronized (_readyJobs) {
if (_readyJobs.size() <= 0) return 0;
// first job is the one that has been waiting the longest
long startAfter = ((Job)_readyJobs.get(0)).getTiming().getStartAfter();
return _context.clock().now() - startAfter;
}
}
/**
* are we so overloaded that we should drop the given job?
* This is driven both by the numReady and waiting jobs, the type of job