Author: rmannibucau
Date: Thu Jan 10 19:51:06 2013
New Revision: 1431581

URL: http://svn.apache.org/viewvc?rev=1431581&view=rev
Log:
fixing defaults for servicepool + adding missing config + fixing tests

Modified:
    
openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/FullPoolFailoverTest.java
    
openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/ServicePool.java

Modified: 
openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/FullPoolFailoverTest.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/FullPoolFailoverTest.java?rev=1431581&r1=1431580&r2=1431581&view=diff
==============================================================================
--- 
openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/FullPoolFailoverTest.java
 (original)
+++ 
openejb/trunk/openejb/server/openejb-ejbd/src/test/java/org/apache/openejb/server/ejbd/FullPoolFailoverTest.java
 Thu Jan 10 19:51:06 2013
@@ -88,6 +88,13 @@ public class FullPoolFailoverTest extend
         }
 
         // Wait for the beans to reach the start line
+        try {
+            if (!paused.await(3000, TimeUnit.MILLISECONDS)) {
+                System.out.println();
+            }
+        } catch (Throwable t) {
+            System.out.println();
+        }
         assertTrue("expected 10 invocations", paused.await(3000, 
TimeUnit.MILLISECONDS));
 
         assertEquals(10, CounterBean.instances.get());

Modified: 
openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/ServicePool.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/ServicePool.java?rev=1431581&r1=1431580&r2=1431581&view=diff
==============================================================================
--- 
openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/ServicePool.java
 (original)
+++ 
openejb/trunk/openejb/server/openejb-server/src/main/java/org/apache/openejb/server/ServicePool.java
 Thu Jan 10 19:51:06 2013
@@ -45,19 +45,29 @@ public class ServicePool extends ServerS
 
     public ServicePool(final ServerService next, final Properties properties) {
         //Liberal defaults
-        this(next, new Options(properties).get("threads", 50), new 
Options(properties).get("queue", 50000), new Options(properties).get("block", 
false));
+        this(next, new Options(properties).get("threadsCore", 2), new 
Options(properties).get("threads", 50), new Options(properties).get("queue", 
50000), new Options(properties).get("block", false), new 
Options(properties).get("keepAliveTime", 1000 * 60 * 5));
     }
 
     public ServicePool(final ServerService next, final int threads) {
-        this(next, threads, 50000, true);
+        this(next, threads, threads, 50000, true, 1000 * 60 * 5);
     }
 
     public ServicePool(final ServerService next, int threads, int queue, final 
boolean block) {
+        this(next, threads, threads, queue, block, 1000 * 60 * 5);
+    }
+
+    public ServicePool(final ServerService next, int threadCore, int threads, 
int queue, final boolean block, long keepAliveTime) {
         super(next);
 
-        int core = 2;
-        if (threads < core) {
-            threads = core;
+        if (keepAliveTime <= 0) {
+            keepAliveTime = 1000 * 60 * 5;
+        }
+
+        if (threads <= 0) {
+            threads = 100;
+        }
+        if (threadCore <= 0) {
+            threadCore = threads;
         }
 
         if (queue < 1) {
@@ -73,7 +83,7 @@ public class ServicePool extends ServerS
          is true then a final attempt is made to run the process in the 
current thread (the service thread).
          */
 
-        threadPool = new ThreadPoolExecutor(core, threads, 1, 
TimeUnit.MINUTES, new LinkedBlockingQueue<Runnable>(queue));
+        threadPool = new ThreadPoolExecutor(threadCore, threads, 
keepAliveTime, TimeUnit.MINUTES, new LinkedBlockingQueue<Runnable>(queue));
         threadPool.setThreadFactory(new ThreadFactory() {
 
             private final AtomicInteger i = new AtomicInteger(0);


Reply via email to