org.opends.server.api
Class WorkQueue<T extends WorkQueueCfg>

java.lang.Object
  extended by org.opends.server.api.WorkQueue<T>
Type Parameters:
T - The type of configuration handled by this work queue.
Direct Known Subclasses:
TraditionalWorkQueue

@PublicAPI(stability=VOLATILE,
           mayInstantiate=false,
           mayExtend=true,
           mayInvoke=true)
public abstract class WorkQueue<T extends WorkQueueCfg>
extends java.lang.Object

This class defines the structure and methods that must be implemented by a Directory Server work queue. The work queue is the component of the server that accepts requests from connection handlers and ensures that they are properly processed. The manner in which the work queue is able to accomplish this may vary between implementations, but in general it is assumed that one or more worker threads will be associated with the queue and may be used to process requests in parallel.


Constructor Summary
WorkQueue()
           
 
Method Summary
abstract  void finalizeWorkQueue(Message reason)
          Performs any necessary finalization for this work queue, including ensuring that all active operations are interrupted or will be allowed to complete, and that all pending operations will be cancelled.
abstract  void initializeWorkQueue(T configuration)
          Initializes this work queue based on the information in the provided configuration entry.
abstract  boolean isIdle()
          Indicates whether the work queue is currently processing any requests.
abstract  void submitOperation(AbstractOperation operation)
          Submits an operation to be processed in the server.
 boolean waitUntilIdle(long timeLimit)
          Waits for the work queue to become idle before returning.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorkQueue

public WorkQueue()
Method Detail

initializeWorkQueue

public abstract void initializeWorkQueue(T configuration)
                                  throws ConfigException,
                                         InitializationException
Initializes this work queue based on the information in the provided configuration entry.

Parameters:
configuration - The configuration to use to initialize the work queue.
Throws:
ConfigException - If the provided configuration entry does not have a valid work queue configuration.
InitializationException - If a problem occurs during initialization that is not related to the server configuration.

finalizeWorkQueue

public abstract void finalizeWorkQueue(Message reason)
Performs any necessary finalization for this work queue, including ensuring that all active operations are interrupted or will be allowed to complete, and that all pending operations will be cancelled.

Parameters:
reason - The human-readable reason that the work queue is being shut down.

submitOperation

public abstract void submitOperation(AbstractOperation operation)
                              throws DirectoryException
Submits an operation to be processed in the server.

Parameters:
operation - The operation to be processed.
Throws:
DirectoryException - If the provided operation is not accepted for some reason (e.g., if the server is shutting down or already has too many pending requests in the queue).

isIdle

public abstract boolean isIdle()
Indicates whether the work queue is currently processing any requests. Note that this is a point-in-time determination, and if any component of the server wishes to depend on a quiescent state then it should use some external mechanism to ensure that no other requests are submitted to the queue.

Returns:
true if the work queue is currently idle, or false if it is being used to process one or more operations.

waitUntilIdle

public boolean waitUntilIdle(long timeLimit)
Waits for the work queue to become idle before returning. Note that this is a point-in-time determination, and if any component of the server wishes to depend on a quiescent state then it should use some external mechanism to ensure that no other requests are submitted to the queue.

Parameters:
timeLimit - The maximum length of time in milliseconds that this method should wait for the queue to become idle before giving up. A time limit that is less than or equal to zero indicates that there should not be a time limit.
Returns:
true if the work queue is idle at the time that this method returns, or false if the wait time limit was reached before the server became idle.