camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bvah...@apache.org
Subject camel git commit: CAMEL-8094: Do not use org.jboss.netty.util.internal.ExecutorUtil as it breaks the camel-netty Karaf feature
Date Sun, 30 Nov 2014 11:06:56 GMT
Repository: camel
Updated Branches:
  refs/heads/master 2f4010e03 -> 829458c70


CAMEL-8094: Do not use org.jboss.netty.util.internal.ExecutorUtil as it breaks the camel-netty
Karaf feature

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

Branch: refs/heads/master
Commit: 829458c700a8dcbaa0d710a7d77ff12636afa0a7
Parents: 2f4010e
Author: Babak Vahdat <bvahdat@apache.org>
Authored: Sun Nov 30 12:06:09 2014 +0100
Committer: Babak Vahdat <bvahdat@apache.org>
Committed: Sun Nov 30 12:06:09 2014 +0100

----------------------------------------------------------------------
 .../netty/NettyClientBossPoolBuilder.java       | 16 -----------
 .../camel/component/netty/NettyProducer.java    | 14 +++++++---
 .../netty/NettyServerBossPoolBuilder.java       | 18 +------------
 .../component/netty/NettyWorkerPoolBuilder.java | 28 +-------------------
 4 files changed, 13 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/829458c7/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyClientBossPoolBuilder.java
----------------------------------------------------------------------
diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyClientBossPoolBuilder.java
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyClientBossPoolBuilder.java
index cc9bfb0..62caf1e 100644
--- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyClientBossPoolBuilder.java
+++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyClientBossPoolBuilder.java
@@ -23,7 +23,6 @@ import org.jboss.netty.channel.socket.nio.BossPool;
 import org.jboss.netty.channel.socket.nio.NioClientBossPool;
 import org.jboss.netty.util.ThreadNameDeterminer;
 import org.jboss.netty.util.Timer;
-import org.jboss.netty.util.internal.ExecutorUtil;
 
 /**
  * A builder to create Netty {@link org.jboss.netty.channel.socket.nio.BossPool} which can
be used for sharing boss pools
@@ -78,19 +77,4 @@ public final class NettyClientBossPoolBuilder {
     BossPool build() {
         return new NioClientBossPool(Executors.newCachedThreadPool(), bossCount, timer, new
CamelNettyThreadNameDeterminer(pattern, name));
     }
-    
-    class CamelNioClientBossPool extends NioClientBossPool {
-        private Executor executor;
-        CamelNioClientBossPool(Executor bossExecutor, int bossCount, Timer timer, ThreadNameDeterminer
determiner) {
-            super(bossExecutor, bossCount, timer, determiner);
-            executor = bossExecutor;
-        }
-        
-        // Just make sure we shutdown the executor;
-        public void shutdown() {
-            super.shutdown();
-            ExecutorUtil.shutdownNow(executor);
-        }
-         
-    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/829458c7/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java
index 491ee38..ac1ecef 100644
--- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java
+++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java
@@ -52,6 +52,7 @@ import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
 import org.jboss.netty.channel.socket.nio.NioDatagramChannelFactory;
 import org.jboss.netty.channel.socket.nio.NioDatagramWorkerPool;
 import org.jboss.netty.channel.socket.nio.WorkerPool;
+import org.jboss.netty.util.ExternalResourceReleasable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -161,7 +162,12 @@ public class NettyProducer extends DefaultAsyncProducer {
             bossPool = null;
         }
         if (workerPool != null) {
-            workerPool.shutdown();
+            if (workerPool instanceof ExternalResourceReleasable) {
+                // this will first invoke workerPool#shutdown() internally (e.g. org.jboss.netty.channel.socket.nio.AbstractNioWorkerPool)
+                ((ExternalResourceReleasable) workerPool).releaseExternalResources();
+            } else {
+                workerPool.shutdown();
+            }
             workerPool = null;
         }
 
@@ -174,12 +180,14 @@ public class NettyProducer extends DefaultAsyncProducer {
         }
         
         if (channelFactory != null) {
-            channelFactory.shutdown();
+            // this will first invoke channelFactory#shutdown() internally (see it's javadoc)
+            channelFactory.releaseExternalResources();
             channelFactory = null;
         }
         
         if (datagramChannelFactory != null) {
-            datagramChannelFactory.shutdown();
+            // this will first invoke datagramChannelFactory#shutdown() internally (see it's
javadoc)
+            datagramChannelFactory.releaseExternalResources();
             datagramChannelFactory = null;
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/829458c7/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyServerBossPoolBuilder.java
----------------------------------------------------------------------
diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyServerBossPoolBuilder.java
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyServerBossPoolBuilder.java
index 3be5a64..6404ae1 100644
--- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyServerBossPoolBuilder.java
+++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyServerBossPoolBuilder.java
@@ -22,7 +22,6 @@ import java.util.concurrent.Executors;
 import org.jboss.netty.channel.socket.nio.BossPool;
 import org.jboss.netty.channel.socket.nio.NioServerBossPool;
 import org.jboss.netty.util.ThreadNameDeterminer;
-import org.jboss.netty.util.internal.ExecutorUtil;
 
 /**
  * A builder to create Netty {@link org.jboss.netty.channel.socket.nio.BossPool} which can
be used for sharing boss pools
@@ -65,21 +64,6 @@ public final class NettyServerBossPoolBuilder {
      * Creates a new boss pool.
      */
     BossPool build() {
-        return new CamelNioServerBossPool(Executors.newCachedThreadPool(), bossCount, new
CamelNettyThreadNameDeterminer(pattern, name));
-    }
-    
-    class CamelNioServerBossPool extends NioServerBossPool {
-        private Executor executor;
-        CamelNioServerBossPool(Executor bossExecutor, int bossCount, ThreadNameDeterminer
determiner) {
-            super(bossExecutor, bossCount, determiner);
-            executor = bossExecutor;
-        }
-        
-        // Just make sure we shutdown the executor;
-        public void shutdown() {
-            super.shutdown();
-            ExecutorUtil.shutdownNow(executor);
-        }
-         
+        return new NioServerBossPool(Executors.newCachedThreadPool(), bossCount, new CamelNettyThreadNameDeterminer(pattern,
name));
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/829458c7/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyWorkerPoolBuilder.java
----------------------------------------------------------------------
diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyWorkerPoolBuilder.java
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyWorkerPoolBuilder.java
index 5b6253a..c60cc25 100644
--- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyWorkerPoolBuilder.java
+++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyWorkerPoolBuilder.java
@@ -22,7 +22,6 @@ import java.util.concurrent.Executors;
 import org.jboss.netty.channel.socket.nio.NioWorkerPool;
 import org.jboss.netty.channel.socket.nio.WorkerPool;
 import org.jboss.netty.util.ThreadNameDeterminer;
-import org.jboss.netty.util.internal.ExecutorUtil;
 
 /**
  * A builder to create Netty {@link WorkerPool} which can be used for sharing worker pools
@@ -67,32 +66,7 @@ public final class NettyWorkerPoolBuilder {
      */
     public WorkerPool build() {
         int count = workerCount > 0 ? workerCount : NettyHelper.DEFAULT_IO_THREADS;
-        workerPool = new CamelNioWorkerPool(Executors.newCachedThreadPool(), count, new CamelNettyThreadNameDeterminer(pattern,
name));
+        workerPool = new NioWorkerPool(Executors.newCachedThreadPool(), count, new CamelNettyThreadNameDeterminer(pattern,
name));
         return workerPool;
     }
-    
-    class CamelNioWorkerPool extends NioWorkerPool {
-        private Executor executor;
-        CamelNioWorkerPool(Executor workerExecutor, int count, ThreadNameDeterminer determiner)
{
-            super(workerExecutor, count, determiner);
-            executor = workerExecutor;
-        }
-        
-        // Just make sure we shutdown the executor;
-        public void shutdown() {
-            super.shutdown();
-            ExecutorUtil.shutdownNow(executor);
-        }
-         
-    }
-
-    /**
-     * Shutdown the created worker pool
-     */
-    public void destroy() {
-        if (workerPool != null) {
-            workerPool.shutdown();
-            workerPool = null;
-        }
-    }
 }


Mime
View raw message