activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject git commit: https://issues.apache.org/jira/browse/AMQ-4205
Date Wed, 04 Sep 2013 18:16:55 GMT
Updated Branches:
  refs/heads/trunk 1f57a6408 -> ce5d2a9e9


https://issues.apache.org/jira/browse/AMQ-4205

Allow for tuning to thread pool keep alive times as system properties.

Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/ce5d2a9e
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/ce5d2a9e
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/ce5d2a9e

Branch: refs/heads/trunk
Commit: ce5d2a9e9e075aad14c2a7fe1a19473f3419bb40
Parents: 1f57a64
Author: Timothy Bish <tabish121@gmai.com>
Authored: Wed Sep 4 14:16:51 2013 -0400
Committer: Timothy Bish <tabish121@gmai.com>
Committed: Wed Sep 4 14:16:51 2013 -0400

----------------------------------------------------------------------
 .../org/apache/activemq/thread/TaskRunnerFactory.java    | 11 ++++++++---
 .../activemq/transport/AbstractInactivityMonitor.java    |  8 +++++---
 .../apache/activemq/transport/nio/SelectorManager.java   |  9 +++++++--
 3 files changed, 20 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/ce5d2a9e/activemq-client/src/main/java/org/apache/activemq/thread/TaskRunnerFactory.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/thread/TaskRunnerFactory.java
b/activemq-client/src/main/java/org/apache/activemq/thread/TaskRunnerFactory.java
index 1a0358c..86f4f3f 100755
--- a/activemq-client/src/main/java/org/apache/activemq/thread/TaskRunnerFactory.java
+++ b/activemq-client/src/main/java/org/apache/activemq/thread/TaskRunnerFactory.java
@@ -47,10 +47,10 @@ public class TaskRunnerFactory implements Executor {
     private String name;
     private int priority;
     private boolean daemon;
-    private AtomicLong id = new AtomicLong(0);
+    private final AtomicLong id = new AtomicLong(0);
     private boolean dedicatedTaskRunner;
     private long shutdownAwaitTermination = 30000;
-    private AtomicBoolean initDone = new AtomicBoolean(false);
+    private final AtomicBoolean initDone = new AtomicBoolean(false);
     private int maxThreadPoolSize = Integer.MAX_VALUE;
     private RejectedExecutionHandler rejectedTaskHandler = null;
 
@@ -140,6 +140,7 @@ public class TaskRunnerFactory implements Executor {
         }
     }
 
+    @Override
     public void execute(Runnable runnable) {
         execute(runnable, name);
     }
@@ -164,7 +165,8 @@ public class TaskRunnerFactory implements Executor {
     }
 
     protected ExecutorService createDefaultExecutor() {
-        ThreadPoolExecutor rc = new ThreadPoolExecutor(0, getMaxThreadPoolSize(), 30, TimeUnit.SECONDS,
new SynchronousQueue<Runnable>(), new ThreadFactory() {
+        ThreadPoolExecutor rc = new ThreadPoolExecutor(0, getMaxThreadPoolSize(), getDefaultKeepAliveTime(),
TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), new ThreadFactory() {
+            @Override
             public Thread newThread(Runnable runnable) {
                 String threadName = name + "-" + id.incrementAndGet();
                 Thread thread = new Thread(runnable, threadName);
@@ -253,4 +255,7 @@ public class TaskRunnerFactory implements Executor {
         this.shutdownAwaitTermination = shutdownAwaitTermination;
     }
 
+    private static int getDefaultKeepAliveTime() {
+        return Integer.getInteger("org.apache.activemq.thread.TaskRunnerFactory.keepAliveTime",
30);
+    }
 }

http://git-wip-us.apache.org/repos/asf/activemq/blob/ce5d2a9e/activemq-client/src/main/java/org/apache/activemq/transport/AbstractInactivityMonitor.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/transport/AbstractInactivityMonitor.java
b/activemq-client/src/main/java/org/apache/activemq/transport/AbstractInactivityMonitor.java
index d64f35e..a797645 100644
--- a/activemq-client/src/main/java/org/apache/activemq/transport/AbstractInactivityMonitor.java
+++ b/activemq-client/src/main/java/org/apache/activemq/transport/AbstractInactivityMonitor.java
@@ -444,10 +444,12 @@ public abstract class AbstractInactivityMonitor extends TransportFilter
{
     };
 
     private ThreadPoolExecutor createExecutor() {
-        // TODO: This value of 10 seconds seems to low, see discussion at
-        // http://activemq.2283324.n4.nabble.com/InactivityMonitor-Creating-too-frequent-threads-tp4656752.html;cid=1348142445209-351
-        ThreadPoolExecutor exec = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 10, TimeUnit.SECONDS,
new SynchronousQueue<Runnable>(), factory);
+        ThreadPoolExecutor exec = new ThreadPoolExecutor(0, Integer.MAX_VALUE, getDefaultKeepAliveTime(),
TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), factory);
         exec.allowCoreThreadTimeOut(true);
         return exec;
     }
+
+    private static int getDefaultKeepAliveTime() {
+        return Integer.getInteger("org.apache.activemq.transport.AbstractInactivityMonitor.keepAliveTime",
30);
+    }
 }

http://git-wip-us.apache.org/repos/asf/activemq/blob/ce5d2a9e/activemq-client/src/main/java/org/apache/activemq/transport/nio/SelectorManager.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/transport/nio/SelectorManager.java
b/activemq-client/src/main/java/org/apache/activemq/transport/nio/SelectorManager.java
index c704919..9be5231 100644
--- a/activemq-client/src/main/java/org/apache/activemq/transport/nio/SelectorManager.java
+++ b/activemq-client/src/main/java/org/apache/activemq/transport/nio/SelectorManager.java
@@ -39,14 +39,15 @@ public final class SelectorManager {
 
     private Executor selectorExecutor = createDefaultExecutor();
     private Executor channelExecutor = selectorExecutor;
-    private LinkedList<SelectorWorker> freeWorkers = new LinkedList<SelectorWorker>();
+    private final LinkedList<SelectorWorker> freeWorkers = new LinkedList<SelectorWorker>();
     private int maxChannelsPerWorker = 1024;
 
     protected ExecutorService createDefaultExecutor() {
-        ThreadPoolExecutor rc = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 10, TimeUnit.SECONDS,
new SynchronousQueue<Runnable>(), new ThreadFactory() {
+        ThreadPoolExecutor rc = new ThreadPoolExecutor(0, Integer.MAX_VALUE, getDefaultKeepAliveTime(),
TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), new ThreadFactory() {
 
             private long i = 0;
 
+            @Override
             public Thread newThread(Runnable runnable) {
                 this.i++;
                 final Thread t = new Thread(runnable, "ActiveMQ NIO Worker " + this.i);
@@ -57,6 +58,10 @@ public final class SelectorManager {
         return rc;
     }
 
+    private static int getDefaultKeepAliveTime() {
+        return Integer.getInteger("org.apache.activemq.transport.nio.SelectorManager.keepAliveTime",
30);
+    }
+
     public static SelectorManager getInstance() {
         return SINGLETON;
     }


Mime
View raw message