You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ma...@apache.org on 2016/04/20 16:29:48 UTC

[3/4] activemq-artemis git commit: abstracted global client thread pools from ThreadPoolExecutor as implementation

abstracted global client thread pools from ThreadPoolExecutor as implementation

Changed the ActiveMQClient interface to expose global thread pools as
ExecutorService and ScheduledExecutorService interface. This is necessary
to allow injecting thread pool implementations that are not based on
ThreadPoolExecutor or ScheduledThreadPoolExecutor.


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

Branch: refs/heads/master
Commit: ec4cbf7b34b19dbd9b4b542067461c2593380cc7
Parents: 1b5396c
Author: Bernd Gutjahr <be...@hpe.com>
Authored: Tue Apr 19 13:55:30 2016 +0200
Committer: Martyn Taylor <mt...@redhat.com>
Committed: Wed Apr 20 15:29:25 2016 +0100

----------------------------------------------------------------------
 .../artemis/api/core/client/ActiveMQClient.java         | 12 +++++++-----
 .../apache/activemq/artemis/ClientThreadPoolsTest.java  |  2 +-
 2 files changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec4cbf7b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/ActiveMQClient.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/ActiveMQClient.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/ActiveMQClient.java
index abc3a5d..3f5dcb9 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/ActiveMQClient.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/core/client/ActiveMQClient.java
@@ -19,7 +19,9 @@ package org.apache.activemq.artemis.api.core.client;
 import java.net.URI;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
+import java.util.concurrent.ExecutorService;
 import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.SynchronousQueue;
 import java.util.concurrent.ThreadFactory;
@@ -136,11 +138,11 @@ public final class ActiveMQClient {
 
    public static final String SCHEDULED_THREAD_POOL_SIZE_PROPERTY_KEY = "activemq.artemis.client.global.scheduled.thread.pool.core.size";
 
-   private static ThreadPoolExecutor globalThreadPool;
+   private static ExecutorService globalThreadPool;
 
    private static boolean injectedPools = false;
 
-   private static ScheduledThreadPoolExecutor globalScheduledThreadPool;
+   private static ScheduledExecutorService globalScheduledThreadPool;
 
 
    static {
@@ -195,7 +197,7 @@ public final class ActiveMQClient {
    }
 
    /** Warning: This method has to be called before any clients or servers is started on the JVM otherwise previous ServerLocator would be broken after this call. */
-   public static synchronized void injectPools(ThreadPoolExecutor globalThreadPool, ScheduledThreadPoolExecutor scheduledThreadPool) {
+   public static synchronized void injectPools(ExecutorService globalThreadPool, ScheduledExecutorService scheduledThreadPool) {
       if (globalThreadPool == null || scheduledThreadPool == null)
          throw new IllegalArgumentException("thread pools must not be null");
 
@@ -207,7 +209,7 @@ public final class ActiveMQClient {
       injectedPools = true;
    }
 
-   public static synchronized ThreadPoolExecutor getGlobalThreadPool() {
+   public static synchronized ExecutorService getGlobalThreadPool() {
       if (globalThreadPool == null) {
          ThreadFactory factory = AccessController.doPrivileged(new PrivilegedAction<ThreadFactory>() {
             @Override
@@ -226,7 +228,7 @@ public final class ActiveMQClient {
       return globalThreadPool;
    }
 
-   public static synchronized ScheduledThreadPoolExecutor getGlobalScheduledThreadPool() {
+   public static synchronized ScheduledExecutorService getGlobalScheduledThreadPool() {
       if (globalScheduledThreadPool == null) {
          ThreadFactory factory = AccessController.doPrivileged(new PrivilegedAction<ThreadFactory>() {
             @Override

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ec4cbf7b/artemis-core-client/src/test/java/org/apache/activemq/artemis/ClientThreadPoolsTest.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/test/java/org/apache/activemq/artemis/ClientThreadPoolsTest.java b/artemis-core-client/src/test/java/org/apache/activemq/artemis/ClientThreadPoolsTest.java
index a3dc213..f9cd852 100644
--- a/artemis-core-client/src/test/java/org/apache/activemq/artemis/ClientThreadPoolsTest.java
+++ b/artemis-core-client/src/test/java/org/apache/activemq/artemis/ClientThreadPoolsTest.java
@@ -177,7 +177,7 @@ public class ClientThreadPoolsTest {
       threadPoolField.setAccessible(true);
       scheduledThreadPoolField.setAccessible(true);
 
-      ThreadPoolExecutor threadPool = ActiveMQClient.getGlobalThreadPool();
+      ThreadPoolExecutor threadPool = (ThreadPoolExecutor) ActiveMQClient.getGlobalThreadPool();
 
       final CountDownLatch doneMax = new CountDownLatch(expectedMax);
       final CountDownLatch latch = new CountDownLatch(1);