com.sonyericsson.hudson.plugins.gerrit.gerritevents
Class GerritSendCommandQueue

java.lang.Object
  extended by com.sonyericsson.hudson.plugins.gerrit.gerritevents.GerritSendCommandQueue

public final class GerritSendCommandQueue
extends Object

A thread-pool and queue implementation for queueing commands to the Gerrit server.

Author:
Robert Sandell <robert.sandell@sonyericsson.com>

Field Summary
static int SEND_QUEUE_SIZE_WARNING_THRESHOLD
          The minimum size of the job-queue before monitors should begin to warn the administrator(s).
 
Method Summary
static GerritSendCommandQueue getInstance(GerritConnectionConfig config)
          Returns the singleton instance of the command-queue.
static int getQueueSize()
          Returns the current queue size.
static void queue(AbstractSendCommandJob job)
          Adds a command-job to the singleton instance's queue.
 void queueJob(AbstractSendCommandJob job)
          Adds a job to the queue.
static void shutdown()
          Shuts down the executor(s).
protected  void startQueue(GerritConnectionConfig config)
          Starts the executor if it hasn't started yet, or updates the thread-pool size if it is started.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEND_QUEUE_SIZE_WARNING_THRESHOLD

public static final int SEND_QUEUE_SIZE_WARNING_THRESHOLD
The minimum size of the job-queue before monitors should begin to warn the administrator(s).

See Also:
Constant Field Values
Method Detail

getInstance

public static GerritSendCommandQueue getInstance(GerritConnectionConfig config)
Returns the singleton instance of the command-queue. Updating it with the latest connection configuration.

Parameters:
config - the config.
Returns:
the instance.

queue

public static void queue(AbstractSendCommandJob job)
Adds a command-job to the singleton instance's queue.

Parameters:
job - the job to do.

getQueueSize

public static int getQueueSize()
Returns the current queue size.

Returns:
the queue size,
See Also:
ThreadPoolExecutor.getQueue()

queueJob

public void queueJob(AbstractSendCommandJob job)
Adds a job to the queue. At the same time tries to update the thread-pool size from the latest config of the job.

Parameters:
job - the job to do.
See Also:
AbstractExecutorService.submit(Runnable)

startQueue

protected void startQueue(GerritConnectionConfig config)
Starts the executor if it hasn't started yet, or updates the thread-pool size if it is started.

Parameters:
config - the config with the pool-size.

shutdown

public static void shutdown()
Shuts down the executor(s). Gracefully waits for WAIT_FOR_JOBS_SHUTDOWN_TIMEOUT seconds for all jobs to finish before forcefully shutting them down.



Copyright © 2004-2012 Hudson. All Rights Reserved.