| | |
| | | import org.opends.server.types.ResultCode; |
| | | |
| | | import static org.opends.server.config.ConfigConstants.*; |
| | | import static org.opends.server.loggers.Debug.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCought; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | import static org.opends.server.loggers.Error.*; |
| | | import static org.opends.server.messages.ConfigMessages.*; |
| | | import static org.opends.server.messages.CoreMessages.*; |
| | |
| | | extends WorkQueue |
| | | implements ConfigurableComponent |
| | | { |
| | | /** |
| | | * The fully-qualified name of this class for debugging purposes. |
| | | */ |
| | | private static final String CLASS_NAME = "org.opends.server.core.WorkQueue"; |
| | | |
| | | |
| | | |
| | |
| | | */ |
| | | public TraditionalWorkQueue() |
| | | { |
| | | assert debugConstructor(CLASS_NAME); |
| | | |
| | | // No implementation should be performed here. |
| | | } |
| | |
| | | public void initializeWorkQueue(ConfigEntry configEntry) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "initializeWorkQueue", |
| | | String.valueOf(configEntry)); |
| | | |
| | | |
| | | shutdownRequested = false; |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "<init>", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | msgID = MSGID_CONFIG_WORK_QUEUE_CANNOT_DETERMINE_NUM_WORKER_THREADS; |
| | | String message = getMessage(msgID, String.valueOf(configEntryDN), |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "<init>", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | msgID = MSGID_CONFIG_WORK_QUEUE_CANNOT_DETERMINE_QUEUE_CAPACITY; |
| | | String message = getMessage(msgID, String.valueOf(configEntryDN), |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "<init>", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | msgID = MSGID_CONFIG_WORK_QUEUE_CANNOT_CREATE_MONITOR; |
| | | String message = getMessage(msgID, TraditionalWorkQueueMonitor.class, |
| | |
| | | */ |
| | | public void finalizeWorkQueue(String reason) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "finalizeWorkQueue"); |
| | | |
| | | shutdownRequested = true; |
| | | |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "processServerShutdown", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | logError(ErrorLogCategory.CORE_SERVER, ErrorLogSeverity.SEVERE_WARNING, |
| | | MSGID_QUEUE_UNABLE_TO_CANCEL, String.valueOf(o), |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "processServerShutdown", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | logError(ErrorLogCategory.CORE_SERVER, ErrorLogSeverity.SEVERE_WARNING, |
| | | MSGID_QUEUE_UNABLE_TO_NOTIFY_THREAD, t.getName(), |
| | |
| | | */ |
| | | public boolean shutdownRequested() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "shutdownRequested"); |
| | | |
| | | return shutdownRequested; |
| | | } |
| | |
| | | public void submitOperation(Operation operation) |
| | | throws DirectoryException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "submitOperation", String.valueOf(operation)); |
| | | |
| | | if (shutdownRequested) |
| | | { |
| | |
| | | */ |
| | | public Operation nextOperation(TraditionalWorkerThread workerThread) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "nextOperation"); |
| | | |
| | | return retryNextOperation(workerThread, 0); |
| | | } |
| | |
| | | private Operation retryNextOperation(TraditionalWorkerThread workerThread, |
| | | int numFailures) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "retryNextOperation"); |
| | | |
| | | |
| | | // See if we should kill off this thread. This could be necessary if the |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "retryNextOperation", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | finally |
| | | { |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "retryNextOperation", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | finally |
| | | { |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "nextOperation", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | // This should not happen. The only recourse we have is to log a message |
| | | // and try again. |
| | | logError(ErrorLogCategory.CORE_SERVER, ErrorLogSeverity.SEVERE_WARNING, |
| | | MSGID_WORKER_WAITING_UNCAUGHT_EXCEPTION, |
| | | Thread.currentThread().getName(), String.valueOf(e)); |
| | | return retryNextOperation(workerThread, numFailures+1); |
| | | return retryNextOperation(workerThread, numFailures + 1); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | public boolean removeOperation(Operation operation) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "removeOperation", String.valueOf(operation)); |
| | | |
| | | return opQueue.remove(operation); |
| | | } |
| | |
| | | */ |
| | | public long getOpsSubmitted() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getOpsSubmitted"); |
| | | |
| | | return opsSubmitted.longValue(); |
| | | } |
| | |
| | | */ |
| | | public long getOpsRejectedDueToQueueFull() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getOpsRejectedDueToQueueFull"); |
| | | |
| | | return queueFullRejects.longValue(); |
| | | } |
| | |
| | | */ |
| | | public int size() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "size"); |
| | | |
| | | return opQueue.size(); |
| | | } |
| | |
| | | */ |
| | | public DN getConfigurableComponentEntryDN() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getConfigurableComponentEntryDN"); |
| | | |
| | | return configEntryDN; |
| | | } |
| | |
| | | */ |
| | | public List<ConfigAttribute> getConfigurationAttributes() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getConfigurationAttributes"); |
| | | |
| | | LinkedList<ConfigAttribute> attrList = new LinkedList<ConfigAttribute>(); |
| | | |
| | |
| | | public boolean hasAcceptableConfiguration(ConfigEntry configEntry, |
| | | List<String> unacceptableReasons) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "hasAcceptableConfiguration", |
| | | String.valueOf(configEntry), "java.util.List"); |
| | | |
| | | |
| | | boolean configIsAcceptable = true; |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "<init>", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | msgID = MSGID_CONFIG_WORK_QUEUE_CANNOT_DETERMINE_NUM_WORKER_THREADS; |
| | | String message = getMessage(msgID, String.valueOf(configEntryDN), |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "<init>", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | msgID = MSGID_CONFIG_WORK_QUEUE_CANNOT_DETERMINE_QUEUE_CAPACITY; |
| | | String message = getMessage(msgID, String.valueOf(configEntryDN), |
| | |
| | | public ConfigChangeResult applyNewConfiguration(ConfigEntry configEntry, |
| | | boolean detailedResults) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "applyNewConfiguration", |
| | | String.valueOf(configEntry), |
| | | String.valueOf(detailedResults)); |
| | | |
| | | |
| | | ArrayList<String> resultMessages = new ArrayList<String>(); |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "applyNewConfiguration", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | msgID = MSGID_CONFIG_WORK_QUEUE_CANNOT_DETERMINE_NUM_WORKER_THREADS; |
| | | String message = getMessage(msgID, String.valueOf(configEntryDN), |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "applyNewConfiguration", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | msgID = MSGID_CONFIG_WORK_QUEUE_CANNOT_DETERMINE_QUEUE_CAPACITY; |
| | | String message = getMessage(msgID, String.valueOf(configEntryDN), |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "applyNewConfiguration", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | finally |
| | | { |
| | |
| | | } |
| | | catch (InterruptedException ie) |
| | | { |
| | | assert debugException(CLASS_NAME, "applyNewConfiguration", ie); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, ie); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "applyNewConfiguration", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | } |
| | | finally |
| | | { |
| | |
| | | */ |
| | | public boolean isIdle() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "isIdle"); |
| | | |
| | | if (opQueue.size() > 0) |
| | | { |