Author: norman
Date: Wed Nov 10 11:05:07 2010
New Revision: 1033412

URL: http://svn.apache.org/viewvc?rev=1033412&view=rev
Log:
Allow to specify the IO-worker count (PROTOCOLS-8)

Modified:
    
james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/AbstractAsyncServer.java

Modified: 
james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/AbstractAsyncServer.java
URL: 
http://svn.apache.org/viewvc/james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/AbstractAsyncServer.java?rev=1033412&r1=1033411&r2=1033412&view=diff
==============================================================================
--- 
james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/AbstractAsyncServer.java
 (original)
+++ 
james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/AbstractAsyncServer.java
 Wed Nov 10 11:05:07 2010
@@ -48,6 +48,8 @@ public abstract class AbstractAsyncServe
     
     private ChannelGroup channels = new DefaultChannelGroup();
 
+    private int ioWorker = Runtime.getRuntime().availableProcessors() * 2;
+
     
     /**
      * Set the ip on which the Server should listen on
@@ -71,6 +73,15 @@ public abstract class AbstractAsyncServe
     }
     
     /**
+     * Set the IO-worker thread count to use. Default is nCores * 2
+     * 
+     * @param ioWorker
+     */
+    public void setIoWorkerCount(int ioWorker) {
+        if (started) throw new IllegalStateException("Can only be set when the 
server is not running");
+        this.ioWorker = ioWorker;
+    }
+    /**
      * Start the server
      * 
      * @throws Exception 
@@ -81,7 +92,7 @@ public abstract class AbstractAsyncServe
 
         if (port < 1) throw new RuntimeException("Please specify a port to 
which the server should get bound!");
 
-        bootstrap = new ServerBootstrap(new 
NioServerSocketChannelFactory(Executors.newCachedThreadPool(), 
Executors.newCachedThreadPool()));
+        bootstrap = new ServerBootstrap(new 
NioServerSocketChannelFactory(Executors.newCachedThreadPool(), 
Executors.newCachedThreadPool(), ioWorker));
         ChannelPipelineFactory factory = createPipelineFactory(channels);
         
         // Configure the pipeline factory.



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to