Class WorkQueue

java.lang.Object
com.google.gerrit.server.git.WorkQueue

public class WorkQueue extends Object
Delayed execution of tasks using a background thread pool.
  • Constructor Details

    • WorkQueue

      public WorkQueue(IdGenerator idGenerator, int defaultThreadPoolSize, com.google.gerrit.metrics.MetricMaker metrics, PluginMapContext<WorkQueue.TaskListener> listeners)
      Constructor to allow binding the WorkQueue more explicitly in a vhost setup.
  • Method Details

    • getDefaultQueue

      public ScheduledExecutorService getDefaultQueue()
      Get the default work queue, for miscellaneous tasks.
    • createQueue

      public ScheduledExecutorService createQueue(int poolsize, String queueName)
      Create a new executor queue.

      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.

      Parameters:
      poolsize - the size of the pool.
      queueName - the name of the queue.
    • createQueue

      public ScheduledThreadPoolExecutor createQueue(int poolsize, String queueName, boolean withMetrics)
      Create a new executor queue, with default priority, optionally with metrics.

      Creates a new executor queue, optionally with associated metrics. Metrics should not be requested for queues created by plugins.

      Parameters:
      poolsize - the size of the pool.
      queueName - the name of the queue.
      withMetrics - whether to create metrics.
    • createQueue

      public ScheduledThreadPoolExecutor createQueue(int poolsize, String queueName, int threadPriority, boolean withMetrics)
      Create a new executor queue, optionally with metrics.

      Creates a new executor queue, optionally with associated metrics. Metrics should not be requested for queues created by plugins.

      Parameters:
      poolsize - the size of the pool.
      queueName - the name of the queue.
      threadPriority - thread priority.
      withMetrics - whether to create metrics.
    • scheduleAtFixedRate

      public void scheduleAtFixedRate(Runnable command, ScheduleConfig.Schedule schedule)
      Executes a periodic command at a fixed schedule on the default queue.
    • getTasks

      public List<WorkQueue.Task<?>> getTasks()
      Get all of the tasks currently scheduled in any work queue.
    • getTaskInfos

      public <T> List<T> getTaskInfos(TaskInfoFactory<T> factory)
    • getTask

      public WorkQueue.Task<?> getTask(int id)
      Locate a task by its unique id, null if no task matches.
    • getExecutor

      public ScheduledThreadPoolExecutor getExecutor(String queueName)