public class WorkQueue
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
WorkQueue.CancelableRunnable
Runnable needing to know it was canceled.
|
static interface |
WorkQueue.CanceledWhileRunning
Base interface handles the case when task was canceled before actual execution and in case it
was started cancel method is not called yet the task itself will be destroyed anyway (it will
result in resource opening errors).
|
static class |
WorkQueue.Lifecycle |
static class |
WorkQueue.Module |
static class |
WorkQueue.ProjectTask<V>
Same as Task class, but with a reference to ProjectRunnable, used to retrieve the project name
from the operation queued
|
static class |
WorkQueue.Task<V>
A wrapper around a scheduled Runnable, as maintained in the queue.
|
Constructor and Description |
---|
WorkQueue(IdGenerator idGenerator,
int defaultThreadPoolSize,
com.google.gerrit.metrics.MetricMaker metrics)
Constructor to allow binding the WorkQueue more explicitly in a vhost setup.
|
Modifier and Type | Method and Description |
---|---|
java.util.concurrent.ScheduledExecutorService |
createQueue(int poolsize,
java.lang.String queueName)
Create a new executor queue.
|
java.util.concurrent.ScheduledThreadPoolExecutor |
createQueue(int poolsize,
java.lang.String queueName,
boolean withMetrics)
Create a new executor queue, with default priority, optionally with metrics.
|
java.util.concurrent.ScheduledThreadPoolExecutor |
createQueue(int poolsize,
java.lang.String queueName,
int threadPriority,
boolean withMetrics)
Create a new executor queue, optionally with metrics.
|
java.util.concurrent.ScheduledExecutorService |
getDefaultQueue()
Get the default work queue, for miscellaneous tasks.
|
java.util.concurrent.ScheduledThreadPoolExecutor |
getExecutor(java.lang.String queueName) |
WorkQueue.Task<?> |
getTask(int id)
Locate a task by its unique id, null if no task matches.
|
<T> java.util.List<T> |
getTaskInfos(TaskInfoFactory<T> factory) |
java.util.List<WorkQueue.Task<?>> |
getTasks()
Get all of the tasks currently scheduled in any work queue.
|
void |
scheduleAtFixedRate(java.lang.Runnable command,
ScheduleConfig.Schedule schedule)
Executes a periodic command at a fixed schedule on the default queue.
|
public WorkQueue(IdGenerator idGenerator, int defaultThreadPoolSize, com.google.gerrit.metrics.MetricMaker metrics)
public java.util.concurrent.ScheduledExecutorService getDefaultQueue()
public java.util.concurrent.ScheduledExecutorService createQueue(int poolsize, java.lang.String queueName)
Creates a new executor queue without associated metrics. This method is suitable for use by plugins.
If metrics are needed, use createQueue(int, String, int, boolean)
instead.
poolsize
- the size of the pool.queueName
- the name of the queue.public java.util.concurrent.ScheduledThreadPoolExecutor createQueue(int poolsize, java.lang.String queueName, boolean withMetrics)
Creates a new executor queue, optionally with associated metrics. Metrics should not be requested for queues created by plugins.
poolsize
- the size of the pool.queueName
- the name of the queue.withMetrics
- whether to create metrics.public java.util.concurrent.ScheduledThreadPoolExecutor createQueue(int poolsize, java.lang.String queueName, int threadPriority, boolean withMetrics)
Creates a new executor queue, optionally with associated metrics. Metrics should not be requested for queues created by plugins.
poolsize
- the size of the pool.queueName
- the name of the queue.threadPriority
- thread priority.withMetrics
- whether to create metrics.public void scheduleAtFixedRate(java.lang.Runnable command, ScheduleConfig.Schedule schedule)
public java.util.List<WorkQueue.Task<?>> getTasks()
public <T> java.util.List<T> getTaskInfos(TaskInfoFactory<T> factory)
public WorkQueue.Task<?> getTask(int id)
public java.util.concurrent.ScheduledThreadPoolExecutor getExecutor(java.lang.String queueName)