public class JobQueue extends Object
| Modifier and Type | Field and Description |
|---|---|
(package private) static String |
PROP_MAX_RUNNERS
router.config parameter to override the max runners
|
(package private) static int |
RUNNERS
How 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.
|
(package private) int |
getActiveRunnerCount()
Get the current number of active job runners.
|
long |
getAvgLag()
Get the average lag time for jobs waiting in the queue.
|
double |
getAvgLagDouble()
Get the average lag time with sub-millisecond precision.
|
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()
Get all job statistics collected by the queue.
|
Job |
getLastJob()
Get the last job that was executed.
|
long |
getLastJobBegin()
Get the timestamp of when the last job began execution.
|
long |
getLastJobEnd()
Get the timestamp of when the last job finished execution.
|
long |
getMaxActiveJobDuration()
Get the maximum duration of currently running jobs.
|
long |
getMaxLag()
Get the maximum lag time for jobs waiting in the queue.
|
double |
getMaxLagDouble()
Get the maximum lag time with sub-millisecond precision.
|
int |
getMaxRunnerCount()
Get the current maximum number of job runners allowed.
|
int |
getMaxWaitingJobs()
Get the maximum number of waiting jobs before dropping.
|
(package private) Job |
getNext() |
long |
getPeakLag()
Get the peak lag observed from completed jobs in the last interval.
|
int |
getReadyCount()
Get the number of jobs ready to be executed.
|
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.
|
(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 |
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,
double duration) |
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()
int getActiveRunnerCount()
public long getAvgLag()
public double getAvgLagDouble()
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 double getMaxLagDouble()
public int getMaxRunnerCount()
public int getMaxWaitingJobs()
Job getNext()
public long getPeakLag()
public int getReadyCount()
public int getTestJobCount()
boolean isAlive()
int 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 runQueue(int numThreads)
numThreads - the number of runner threads to startvoid shutdown()
public void startup()
void updateStats(Job job, double duration)