From 84a6349d4c1e49de04d6ba61e587130af3efbc00 Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Mon, 09 Mar 2009 18:04:05 +0000
Subject: [PATCH] Fix issue 3832 - Provide ergonomics style settings for common server properties

---
 opends/src/server/org/opends/server/extensions/TraditionalWorkQueue.java |   33 +++++++++++++++++++++++++--------
 1 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/opends/src/server/org/opends/server/extensions/TraditionalWorkQueue.java b/opends/src/server/org/opends/server/extensions/TraditionalWorkQueue.java
index a007102..30058c6 100644
--- a/opends/src/server/org/opends/server/extensions/TraditionalWorkQueue.java
+++ b/opends/src/server/org/opends/server/extensions/TraditionalWorkQueue.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2006-2008 Sun Microsystems, Inc.
+ *      Copyright 2006-2009 Sun Microsystems, Inc.
  */
 package org.opends.server.extensions;
 
@@ -49,7 +49,6 @@
 import org.opends.server.types.ConfigChangeResult;
 import org.opends.server.types.DebugLogLevel;
 import org.opends.server.types.DirectoryException;
-import org.opends.server.types.DN;
 import org.opends.server.types.InitializationException;
 import org.opends.server.types.Operation;
 import org.opends.server.types.ResultCode;
@@ -103,10 +102,6 @@
   // Indicates whether the Directory Server is shutting down.
   private boolean shutdownRequested;
 
-  // The DN of the configuration entry with information to use to configure the
-  // work queue.
-  private DN configEntryDN;
-
   // The thread number used for the last worker thread that was created.
   private int lastThreadNumber;
 
@@ -156,8 +151,7 @@
 
 
     // Get the necessary configuration from the provided entry.
-    configEntryDN    = configuration.dn();
-    numWorkerThreads = configuration.getNumWorkerThreads();
+    numWorkerThreads = getNumWorkerThreads(configuration);
     maxCapacity      = configuration.getMaxWorkQueueCapacity();
 
 
@@ -292,6 +286,7 @@
    *                              down or the pending operation queue is already
    *                              at its maximum capacity).
    */
+  @Override
   public void submitOperation(AbstractOperation operation)
          throws DirectoryException
   {
@@ -712,5 +707,27 @@
       return true;
     }
   }
+
+
+
+  // Determine the number of worker threads.
+  private int getNumWorkerThreads(TraditionalWorkQueueCfg configuration)
+  {
+    if (configuration.getNumWorkerThreads() == null)
+    {
+      // Automatically choose based on the number of processors.
+      int cpus = Runtime.getRuntime().availableProcessors();
+      int value = Math.max(24, cpus * 2);
+
+      Message message = INFO_ERGONOMIC_SIZING_OF_WORKER_THREAD_POOL.get(value);
+      logError(message);
+
+      return value;
+    }
+    else
+    {
+      return configuration.getNumWorkerThreads();
+    }
+  }
 }
 

--
Gitblit v1.10.0