Package org.opends.server.api
Class WorkQueue<T extends WorkQueueCfg>
- java.lang.Object
-
- 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, mayExtend=true, mayInvoke=true) public abstract class WorkQueue<T extends WorkQueueCfg> extends 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
Constructors Constructor Description WorkQueue()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract void
finalizeWorkQueue(LocalizableMessage 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 int
getNumWorkerThreads()
Return the maximum number of worker threads that can be used by this WorkQueue (The WorkQueue could have a thread pool which adjusts its size).abstract void
initializeWorkQueue(T configuration, ServerContext serverContext)
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(Operation operation)
Submits an operation to be processed in the server.abstract boolean
trySubmitOperation(Operation operation)
Tries to submit an operation to be processed in the server, without blocking.boolean
waitUntilIdle(long timeLimit)
Waits for the work queue to become idle before returning.
-
-
-
Method Detail
-
initializeWorkQueue
public abstract void initializeWorkQueue(T configuration, ServerContext serverContext) throws 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.serverContext
- The server context.- Throws:
InitializationException
- If a problem occurs during initialization that is not related to the server configuration.
-
finalizeWorkQueue
public abstract void finalizeWorkQueue(LocalizableMessage 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(Operation operation) throws LdapException
Submits an operation to be processed in the server.- Parameters:
operation
- The operation to be processed.- Throws:
LdapException
- 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).
-
trySubmitOperation
public abstract boolean trySubmitOperation(Operation operation) throws LdapException
Tries to submit an operation to be processed in the server, without blocking.- Parameters:
operation
- The operation to be processed.- Returns:
- true if the operation could be submitted to the queue, false if the queue was full
- Throws:
LdapException
- If the provided operation is not accepted for some reason (e.g., if the server is shutting down).
-
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, orfalse
if it is being used to process one or more operations.
-
getNumWorkerThreads
public abstract int getNumWorkerThreads()
Return the maximum number of worker threads that can be used by this WorkQueue (The WorkQueue could have a thread pool which adjusts its size).- Returns:
- the maximum number of worker threads that can be used by this WorkQueue
-
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, orfalse
if the wait time limit was reached before the server became idle.
-
-