Package org.opends.server.extensions
Class TraditionalWorkQueue
- java.lang.Object
-
- org.opends.server.api.WorkQueue<TraditionalWorkQueueCfg>
-
- org.opends.server.extensions.TraditionalWorkQueue
-
- All Implemented Interfaces:
ConfigurationChangeListener<TraditionalWorkQueueCfg>
public class TraditionalWorkQueue extends WorkQueue<TraditionalWorkQueueCfg> implements ConfigurationChangeListener<TraditionalWorkQueueCfg>
This class defines a data structure for storing and interacting with the Directory Server work queue.
-
-
Constructor Summary
Constructors Constructor Description TraditionalWorkQueue()Creates a new instance of this work queue.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConfigChangeResultapplyConfigurationChange(TraditionalWorkQueueCfg configuration)Applies the configuration changes to this change listener.voidfinalizeWorkQueue(org.forgerock.i18n.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.intgetNumWorkerThreads()Return the number of worker threads used by this WorkQueue.longgetOpsRejectedDueToQueueFull()Retrieves the total number of operations that have been rejected because the work queue was already at its maximum capacity.longgetOpsSubmitted()Retrieves the total number of operations that have been successfully submitted to this work queue for processing since server startup.voidinitializeWorkQueue(TraditionalWorkQueueCfg configuration)Initializes this work queue based on the information in the provided configuration entry.booleanisConfigurationChangeAcceptable(TraditionalWorkQueueCfg configuration, List<org.forgerock.i18n.LocalizableMessage> unacceptableReasons)Indicates whether the proposed change to the configuration is acceptable to this change listener.booleanisIdle()Indicates whether the work queue is currently processing any requests.OperationnextOperation(TraditionalWorkerThread workerThread)Retrieves the next operation that should be processed by one of the worker threads, blocking if necessary until a new request arrives.booleanshutdownRequested()Indicates whether this work queue has received a request to shut down.intsize()Retrieves the number of pending operations in the queue that have not yet been picked up for processing.voidsubmitOperation(Operation operation)Submits an operation to be processed by one of the worker threads associated with this work queue.booleantrySubmitOperation(Operation operation)Tries to submit an operation to be processed in the server, without blocking.-
Methods inherited from class org.opends.server.api.WorkQueue
computeNumWorkerThreads, waitUntilIdle
-
-
-
-
Method Detail
-
initializeWorkQueue
public void initializeWorkQueue(TraditionalWorkQueueCfg configuration) throws ConfigException, InitializationException
Description copied from class:WorkQueueInitializes this work queue based on the information in the provided configuration entry.- Specified by:
initializeWorkQueuein classWorkQueue<TraditionalWorkQueueCfg>- 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 void finalizeWorkQueue(org.forgerock.i18n.LocalizableMessage reason)
Description copied from class:WorkQueuePerforms 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.- Specified by:
finalizeWorkQueuein classWorkQueue<TraditionalWorkQueueCfg>- Parameters:
reason- The human-readable reason that the work queue is being shut down.
-
shutdownRequested
public boolean shutdownRequested()
Indicates whether this work queue has received a request to shut down.- Returns:
trueif the work queue has recieved a request to shut down, orfalseif not.
-
submitOperation
public void submitOperation(Operation operation) throws DirectoryException
Submits an operation to be processed by one of the worker threads associated with this work queue.- Specified by:
submitOperationin classWorkQueue<TraditionalWorkQueueCfg>- 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 the pending operation queue is already at its maximum capacity).
-
trySubmitOperation
public boolean trySubmitOperation(Operation operation) throws DirectoryException
Description copied from class:WorkQueueTries to submit an operation to be processed in the server, without blocking.- Specified by:
trySubmitOperationin classWorkQueue<TraditionalWorkQueueCfg>- 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:
DirectoryException- If the provided operation is not accepted for some reason (e.g., if the server is shutting down).
-
nextOperation
public Operation nextOperation(TraditionalWorkerThread workerThread)
Retrieves the next operation that should be processed by one of the worker threads, blocking if necessary until a new request arrives. This method should only be called by a worker thread associated with this work queue.- Parameters:
workerThread- The worker thread that is requesting the operation.- Returns:
- The next operation that should be processed, or
nullif the server is shutting down and no more operations will be processed.
-
getOpsSubmitted
public long getOpsSubmitted()
Retrieves the total number of operations that have been successfully submitted to this work queue for processing since server startup. This does not include operations that have been rejected for some reason like the queue already at its maximum capacity.- Returns:
- The total number of operations that have been successfully submitted to this work queue since startup.
-
getOpsRejectedDueToQueueFull
public long getOpsRejectedDueToQueueFull()
Retrieves the total number of operations that have been rejected because the work queue was already at its maximum capacity.- Returns:
- The total number of operations that have been rejected because the work queue was already at its maximum capacity.
-
size
public int size()
Retrieves the number of pending operations in the queue that have not yet been picked up for processing. Note that this method is not a constant-time operation and can be relatively inefficient, so it should be used sparingly.- Returns:
- The number of pending operations in the queue that have not yet been picked up for processing.
-
isConfigurationChangeAcceptable
public boolean isConfigurationChangeAcceptable(TraditionalWorkQueueCfg configuration, List<org.forgerock.i18n.LocalizableMessage> unacceptableReasons)
Description copied from interface:ConfigurationChangeListenerIndicates whether the proposed change to the configuration is acceptable to this change listener.- Specified by:
isConfigurationChangeAcceptablein interfaceConfigurationChangeListener<TraditionalWorkQueueCfg>- Parameters:
configuration- The new configuration containing the changes.unacceptableReasons- A list that can be used to hold messages about why the provided configuration is not acceptable.- Returns:
- Returns
trueif the proposed change is acceptable, orfalseif it is not.
-
applyConfigurationChange
public ConfigChangeResult applyConfigurationChange(TraditionalWorkQueueCfg configuration)
Description copied from interface:ConfigurationChangeListenerApplies the configuration changes to this change listener.- Specified by:
applyConfigurationChangein interfaceConfigurationChangeListener<TraditionalWorkQueueCfg>- Parameters:
configuration- The new configuration containing the changes.- Returns:
- Returns information about the result of changing the configuration.
-
isIdle
public boolean isIdle()
Description copied from class:WorkQueueIndicates 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.- Specified by:
isIdlein classWorkQueue<TraditionalWorkQueueCfg>- Returns:
trueif the work queue is currently idle, orfalseif it is being used to process one or more operations.
-
getNumWorkerThreads
public int getNumWorkerThreads()
Return the number of worker threads used by this WorkQueue.- Specified by:
getNumWorkerThreadsin classWorkQueue<TraditionalWorkQueueCfg>- Returns:
- the number of worker threads used by this WorkQueue
-
-