| | |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | |
| | | |
| | | import static org.opends.messages.ConfigMessages.*; |
| | | import static org.opends.messages.CoreMessages.*; |
| | | |
| | |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.Operation; |
| | | |
| | | |
| | | |
| | | /** |
| | | * This class defines a data structure for storing and interacting with the |
| | | * Directory Server work queue. |
| | |
| | | /** The queue that will be used to actually hold the pending operations. */ |
| | | private LinkedBlockingQueue<Operation> opQueue; |
| | | |
| | | /** |
| | | * The lock used to provide threadsafe access for the queue, used for |
| | | * non-config changes. |
| | | */ |
| | | /** The lock used to provide threadsafe access for the queue, used for non-config changes. */ |
| | | private final ReadLock queueReadLock; |
| | | |
| | | /** |
| | | * The lock used to provide threadsafe access for the queue, used for config |
| | | * changes. |
| | | */ |
| | | /** The lock used to provide threadsafe access for the queue, used for config changes. */ |
| | | private final WriteLock queueWriteLock; |
| | | { |
| | | ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); |
| | |
| | | queueWriteLock = lock.writeLock(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Creates a new instance of this work queue. All initialization should be |
| | | * performed in the <CODE>initializeWorkQueue</CODE> method. |
| | |
| | | // No implementation should be performed here. |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void initializeWorkQueue(TraditionalWorkQueueCfg configuration) |
| | | throws ConfigException, InitializationException |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void finalizeWorkQueue(LocalizableMessage reason) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Indicates whether this work queue has received a request to shut down. |
| | | * |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Submits an operation to be processed by one of the worker threads |
| | | * associated with this work queue. |
| | |
| | | submitOperation(operation, isBlocking); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean trySubmitOperation(Operation operation) |
| | | throws DirectoryException |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the next operation that should be processed by one of the worker |
| | | * threads, blocking if necessary until a new request arrives. This method |
| | |
| | | return retryNextOperation(workerThread, 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the next operation that should be processed by one of the worker |
| | | * threads following a previous failure attempt. A maximum of five consecutive |
| | |
| | | return retryNextOperation(workerThread, numFailures + 1); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Kills this worker thread if needed. This method assumes that the read lock |
| | | * is already taken and ensure that it is taken on exit. |
| | |
| | | return false; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the total number of operations that have been successfully |
| | | * submitted to this work queue for processing since server startup. This does |
| | |
| | | return opsSubmitted.longValue(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Retrieves the total number of operations that have been rejected because |
| | | * the work queue was already at its maximum capacity. |
| | |
| | | return queueFullRejects.longValue(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 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 |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isConfigurationChangeAcceptable( |
| | | TraditionalWorkQueueCfg configuration, List<LocalizableMessage> unacceptableReasons) |
| | |
| | | return true; |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public ConfigChangeResult applyConfigurationChange( |
| | | TraditionalWorkQueueCfg configuration) |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | // Apply a change to the maximum capacity if appropriate. Since we can't |
| | | // change capacity on the fly, then we'll have to create a new queue and |
| | | // transfer any remaining items into it. Any thread that is waiting on the |
| | |
| | | return new ConfigChangeResult(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean isIdle() |
| | | { |