public class JobQueue extends Object
| Modifier and Type | Field and Description |
|---|---|
(package private) static String | PROP_MAX_RUNNERSrouter.config parameter to override the max runners |
(package private) static int | RUNNERSHow many when we go parallel |
| Constructor and Description |
|---|
JobQueue(RouterContext context)Does not start the pumper. |
| Modifier and Type | Method and Description |
|---|---|
void | addJob(Job job)Enqueue the specified job for normal processing. |
void | addJobToTop(Job job)Enqueue the specified job to be processed at the top of the queue. |
(package private) void | addRunners(int count)Add additional job runners to the pool. |
void | allowParallelOperation()Enable parallel job execution and start additional queue runner threads. |
int | getActiveRunnerCount()Current number of active job runners. |
int | getAndResetDroppedCount()Dropped jobs count (resets on read). |
long | getAvgLag()Average lag time for jobs waiting in the queue. |
int | getJobs(Collection<Job> readyJobs,
Collection<Job> timedJobs,
Collection<Job> activeJobs,
Collection<Job> justFinishedJobs)Collect statistics about jobs currently in the queue. |
Collection<JobStats> | getJobStats()All job statistics collected by the queue. |
Job | getLastJob()Last job that was executed. |
long | getLastJobBegin()Timestamp of when the last job began execution. |
long | getLastJobEnd()Timestamp of when the last job finished execution. |
long | getMaxActiveJobDuration()Maximum duration of currently running jobs. |
long | getMaxLag()Maximum lag time for jobs waiting in the queue. |
int | getMaxRunnerCount()Current maximum number of job runners allowed. |
(package private) Job | getNext()Next job in queue. |
int | getReadyCount()Number of jobs ready to be executed. |
int | getReadyTestJobCount()Count TestJob instances that are ready to run or currently running
(excluding future-scheduled timed jobs). |
int | getTestJobCount()Count the number of TestJob instances currently queued in the job queue. |
(package private) boolean | isAlive()Check if the job queue is currently alive and processing jobs. |
void | releaseJobRunners(int count,
String reason)Release previously requested job runners. |
(package private) int | removeIdleRunners(int maxToRemove)Remove idle job runners from the pool. |
void | removeJob(Job job)Remove a job from the job queue. |
(package private) void | removeRunner(int id)Remove a queue runner from the registry. |
void | requestJobRunners(int count,
String reason,
long autoReleaseMs)Request additional job runners for an anticipated burst. |
void | runQueue(int numThreads)Start the job queue with the specified number of runner threads. |
(package private) void | shutdown()Shutdown the job queue, stopping all runners and clearing all jobs. |
void | startup()Initialize and start the job queue pumper thread. |
(package private) void | updateStats(Job job,
long doStart,
long _origStartAfter,
long duration)Update stats |
static final String PROP_MAX_RUNNERS
static int RUNNERS
public JobQueue(RouterContext context)
public void addJob(Job job)
job - job to add to the queuepublic void addJobToTop(Job job)
job - job to add to the front of the queuevoid addRunners(int count)
count - the number of runners to addpublic void allowParallelOperation()
public int getActiveRunnerCount()
public int getAndResetDroppedCount()
public long getAvgLag()
public int getJobs(Collection<Job> readyJobs, Collection<Job> timedJobs, Collection<Job> activeJobs, Collection<Job> justFinishedJobs)
readyJobs - collection to populate with ready jobstimedJobs - collection to populate with timed/scheduled jobsactiveJobs - collection to populate with currently running jobsjustFinishedJobs - collection to populate with recently finished jobspublic Collection<JobStats> getJobStats()
public Job getLastJob()
public long getLastJobBegin()
public long getLastJobEnd()
public long getMaxActiveJobDuration()
public long getMaxLag()
public int getMaxRunnerCount()
Job getNext()
public int getReadyCount()
public int getReadyTestJobCount()
public int getTestJobCount()
boolean isAlive()
public void releaseJobRunners(int count,
String reason)count - number of runners to releasereason - must match the reason used in requestJobRunnersint removeIdleRunners(int maxToRemove)
maxToRemove - the maximum number of runners to removepublic void removeJob(Job job)
job - the job to remove from the queuevoid removeRunner(int id)
id - the runner ID to removepublic void requestJobRunners(int count,
String reason,
long autoReleaseMs)count - number of additional runners to reservereason - label for logging and trackingautoReleaseMs - if > 0, auto-decay after this many mspublic void runQueue(int numThreads)
numThreads - the number of runner threads to startvoid shutdown()
public void startup()
void updateStats(Job job, long doStart, long _origStartAfter, long duration)