You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2015/04/27 04:55:46 UTC
camel git commit: CAMEL-8702 doesn't create the a new EventLoopGroup
per connection in NettyProducer
Repository: camel
Updated Branches:
refs/heads/master d9ae20ba7 -> 2ec2b8750
CAMEL-8702 doesn't create the a new EventLoopGroup per connection in NettyProducer
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2ec2b875
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2ec2b875
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2ec2b875
Branch: refs/heads/master
Commit: 2ec2b87509fb77daf2d40cfa7b7334fc699f4bdf
Parents: d9ae20b
Author: Willem Jiang <wi...@gmail.com>
Authored: Mon Apr 27 10:55:34 2015 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Mon Apr 27 10:55:34 2015 +0800
----------------------------------------------------------------------
.../apache/camel/component/netty4/NettyProducer.java | 14 ++++++--------
.../netty4/NettyServerBootstrapConfiguration.java | 12 +++++++++++-
2 files changed, 17 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/2ec2b875/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyProducer.java b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyProducer.java
index 4dd2cac..9bba354 100644
--- a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyProducer.java
+++ b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyProducer.java
@@ -91,7 +91,12 @@ public class NettyProducer extends DefaultAsyncProducer {
@Override
protected void doStart() throws Exception {
super.doStart();
-
+ if (configuration.getWorkerGroup() == null) {
+ // create new pool which we should shutdown when stopping as its not shared
+ workerGroup = new NettyWorkerPoolBuilder().withWorkerCount(configuration.getWorkerCount())
+ .withName("NettyClientTCPWorker").build();
+ }
+
if (configuration.isProducerPoolEnabled()) {
// setup pool where we want an unbounded pool, which allows the pool to shrink on no demand
GenericObjectPool.Config config = new GenericObjectPool.Config();
@@ -312,19 +317,12 @@ public class NettyProducer extends DefaultAsyncProducer {
}
protected EventLoopGroup getWorkerGroup() {
-
// prefer using explicit configured thread pools
EventLoopGroup wg = configuration.getWorkerGroup();
-
if (wg == null) {
- // create new pool which we should shutdown when stopping as its not
- // shared
- workerGroup = new NettyWorkerPoolBuilder().withWorkerCount(configuration.getWorkerCount())
- .withName("NettyClientTCPWorker").build();
wg = workerGroup;
}
return wg;
-
}
protected ChannelFuture openConnection() throws Exception {
http://git-wip-us.apache.org/repos/asf/camel/blob/2ec2b875/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyServerBootstrapConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyServerBootstrapConfiguration.java b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyServerBootstrapConfiguration.java
index ce1403d..9dc4c40 100644
--- a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyServerBootstrapConfiguration.java
+++ b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyServerBootstrapConfiguration.java
@@ -91,7 +91,9 @@ public class NettyServerBootstrapConfiguration implements Cloneable {
protected String enabledProtocols = DEFAULT_ENABLED_PROTOCOLS;
@UriParam
protected String passphrase;
+ @UriParam
protected EventLoopGroup bossGroup;
+ @UriParam
protected EventLoopGroup workerGroup;
@UriParam
protected String networkInterface;
@@ -360,14 +362,22 @@ public class NettyServerBootstrapConfiguration implements Cloneable {
return bossGroup;
}
+ /**
+ * Set the BossGroup which could be used for handling the new connection of the server side across the NettyEndpoint
+ * @param bossGroup
+ */
public void setBossGroup(EventLoopGroup bossGroup) {
this.bossGroup = bossGroup;
}
-
+
public EventLoopGroup getWorkerGroup() {
return workerGroup;
}
+ /**
+ * Set the WorkerGroup which could be used for handling selector eventloop across the NettyEndpoint
+ * @param workerGroup
+ */
public void setWorkerGroup(EventLoopGroup workerGroup) {
this.workerGroup = workerGroup;
}