You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/11/29 10:19:25 UTC

[camel] branch camel-3.0.x updated: CAMEL-14228: camel-netty - Let netty calculate the default worker count

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-3.0.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-3.0.x by this push:
     new fa60e25  CAMEL-14228: camel-netty - Let netty calculate the default worker count
fa60e25 is described below

commit fa60e25209078e6a9d6b3ca9bb26a3eb902f5186
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Nov 29 11:15:38 2019 +0100

    CAMEL-14228: camel-netty - Let netty calculate the default worker count
---
 .../camel-netty/src/main/docs/netty-component.adoc |  4 ++--
 .../apache/camel/component/netty/NettyHelper.java  |  1 -
 .../netty/NettyServerBootstrapConfiguration.java   |  6 ++---
 .../component/netty/NettyWorkerPoolBuilder.java    |  5 ++--
 .../endpoint/dsl/NettyEndpointBuilderFactory.java  | 28 +++++++++++-----------
 .../springboot/NettyComponentConfiguration.java    |  6 ++---
 6 files changed, 24 insertions(+), 26 deletions(-)

diff --git a/components/camel-netty/src/main/docs/netty-component.adoc b/components/camel-netty/src/main/docs/netty-component.adoc
index 553afbb..28ae601 100644
--- a/components/camel-netty/src/main/docs/netty-component.adoc
+++ b/components/camel-netty/src/main/docs/netty-component.adoc
@@ -112,7 +112,7 @@ with the following path and query parameters:
 | *reconnect* (consumer) | Used only in clientMode in consumer, the consumer will attempt to reconnect on disconnection if this is enabled | true | boolean
 | *reconnectInterval* (consumer) | Used if reconnect and clientMode is enabled. The interval in milli seconds to attempt reconnection | 10000 | int
 | *backlog* (consumer) | Allows to configure a backlog for netty consumer (server). Note the backlog is just a best effort depending on the OS. Setting this option to a value such as 200, 500 or 1000, tells the TCP stack how long the accept queue can be If this option is not configured, then the backlog depends on OS setting. |  | int
-| *bossCount* (consumer) | When netty works on nio mode, it uses default bossCount parameter from Netty, which is 1. User can use this operation to override the default bossCount from Netty | 1 | int
+| *bossCount* (consumer) | When netty works on nio mode, it uses default bossCount parameter from Netty, which is 1. User can use this option to override the default bossCount from Netty | 1 | int
 | *bossGroup* (consumer) | Set the BossGroup which could be used for handling the new connection of the server side across the NettyEndpoint |  | EventLoopGroup
 | *disconnectOnNoReply* (consumer) | If sync is enabled then this option dictates NettyConsumer if it should disconnect where there is no reply to send back. | true | boolean
 | *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. |  | ExceptionHandler
@@ -148,7 +148,7 @@ with the following path and query parameters:
 | *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean
 | *transferExchange* (advanced) | Only used for TCP. You can transfer the exchange over the wire instead of just the body. The following fields are transferred: In body, Out body, fault body, In headers, Out headers, fault headers, exchange properties, exchange exception. This requires that the objects are serializable. Camel will exclude any non-serializable objects and log it at WARN level. | false | boolean
 | *udpByteArrayCodec* (advanced) | For UDP only. If enabled the using byte array codec instead of Java serialization protocol. | false | boolean
-| *workerCount* (advanced) | When netty works on nio mode, it uses default workerCount parameter from Netty, which is cpu_core_threads x 2. User can use this operation to override the default workerCount from Netty. |  | int
+| *workerCount* (advanced) | When netty works on nio mode, it uses default workerCount parameter from Netty (which is cpu_core_threads x 2). User can use this option to override the default workerCount from Netty. |  | int
 | *workerGroup* (advanced) | To use a explicit EventLoopGroup as the boss thread pool. For example to share a thread pool with multiple consumers or producers. By default each consumer or producer has their own worker pool with 2 x cpu count core threads. |  | EventLoopGroup
 | *allowDefaultCodec* (codec) | The netty component installs a default codec if both, encoder/decoder is null and textline is false. Setting allowDefaultCodec to false prevents the netty component from installing a default codec as the first element in the filter chain. | true | boolean
 | *autoAppendDelimiter* (codec) | Whether or not to auto append missing end delimiter when sending using the textline codec. | true | boolean
diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyHelper.java b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyHelper.java
index d8abbad..9b6a39e 100644
--- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyHelper.java
+++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyHelper.java
@@ -33,7 +33,6 @@ import org.slf4j.LoggerFactory;
  */
 public final class NettyHelper {
 
-    public static final int DEFAULT_IO_THREADS = Runtime.getRuntime().availableProcessors() * 2;
     private static final Logger LOG = LoggerFactory.getLogger(NettyHelper.class);
 
     private NettyHelper() {
diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyServerBootstrapConfiguration.java b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyServerBootstrapConfiguration.java
index 1c7753a..643e6d3 100644
--- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyServerBootstrapConfiguration.java
+++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyServerBootstrapConfiguration.java
@@ -201,8 +201,8 @@ public class NettyServerBootstrapConfiguration implements Cloneable {
     }
 
     /**
-     * When netty works on nio mode, it uses default workerCount parameter from Netty, which is cpu_core_threads x 2.
-     * User can use this operation to override the default workerCount from Netty.
+     * When netty works on nio mode, it uses default workerCount parameter from Netty (which is cpu_core_threads x 2).
+     * User can use this option to override the default workerCount from Netty.
      */
     public void setWorkerCount(int workerCount) {
         this.workerCount = workerCount;
@@ -214,7 +214,7 @@ public class NettyServerBootstrapConfiguration implements Cloneable {
 
     /**
      * When netty works on nio mode, it uses default bossCount parameter from Netty, which is 1.
-     * User can use this operation to override the default bossCount from Netty
+     * User can use this option to override the default bossCount from Netty
      */
     public void setBossCount(int bossCount) {
         this.bossCount = bossCount;
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 defc8b6..1d466ac 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
@@ -73,11 +73,10 @@ public final class NettyWorkerPoolBuilder {
      * Creates a new worker pool.
      */
     public EventLoopGroup build() {
-        int count = workerCount > 0 ? workerCount : NettyHelper.DEFAULT_IO_THREADS;
         if (nativeTransport) {
-            workerPool = new EpollEventLoopGroup(count, new CamelThreadFactory(pattern, name, false));
+            workerPool = new EpollEventLoopGroup(workerCount, new CamelThreadFactory(pattern, name, false));
         } else {
-            workerPool = new NioEventLoopGroup(count, new CamelThreadFactory(pattern, name, false));
+            workerPool = new NioEventLoopGroup(workerCount, new CamelThreadFactory(pattern, name, false));
         }
         return workerPool;
     }
diff --git a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/NettyEndpointBuilderFactory.java b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/NettyEndpointBuilderFactory.java
index 1c12875..eaf097c 100644
--- a/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/NettyEndpointBuilderFactory.java
+++ b/core/camel-endpointdsl/src/main/java/org/apache/camel/builder/endpoint/dsl/NettyEndpointBuilderFactory.java
@@ -831,7 +831,7 @@ public interface NettyEndpointBuilderFactory {
         }
         /**
          * When netty works on nio mode, it uses default bossCount parameter
-         * from Netty, which is 1. User can use this operation to override the
+         * from Netty, which is 1. User can use this option to override the
          * default bossCount from Netty.
          * 
          * The option is a: <code>int</code> type.
@@ -844,7 +844,7 @@ public interface NettyEndpointBuilderFactory {
         }
         /**
          * When netty works on nio mode, it uses default bossCount parameter
-         * from Netty, which is 1. User can use this operation to override the
+         * from Netty, which is 1. User can use this option to override the
          * default bossCount from Netty.
          * 
          * The option will be converted to a <code>int</code> type.
@@ -1453,8 +1453,8 @@ public interface NettyEndpointBuilderFactory {
         }
         /**
          * When netty works on nio mode, it uses default workerCount parameter
-         * from Netty, which is cpu_core_threads x 2. User can use this
-         * operation to override the default workerCount from Netty.
+         * from Netty (which is cpu_core_threads x 2). User can use this option
+         * to override the default workerCount from Netty.
          * 
          * The option is a: <code>int</code> type.
          * 
@@ -1466,8 +1466,8 @@ public interface NettyEndpointBuilderFactory {
         }
         /**
          * When netty works on nio mode, it uses default workerCount parameter
-         * from Netty, which is cpu_core_threads x 2. User can use this
-         * operation to override the default workerCount from Netty.
+         * from Netty (which is cpu_core_threads x 2). User can use this option
+         * to override the default workerCount from Netty.
          * 
          * The option will be converted to a <code>int</code> type.
          * 
@@ -2828,8 +2828,8 @@ public interface NettyEndpointBuilderFactory {
         }
         /**
          * When netty works on nio mode, it uses default workerCount parameter
-         * from Netty, which is cpu_core_threads x 2. User can use this
-         * operation to override the default workerCount from Netty.
+         * from Netty (which is cpu_core_threads x 2). User can use this option
+         * to override the default workerCount from Netty.
          * 
          * The option is a: <code>int</code> type.
          * 
@@ -2841,8 +2841,8 @@ public interface NettyEndpointBuilderFactory {
         }
         /**
          * When netty works on nio mode, it uses default workerCount parameter
-         * from Netty, which is cpu_core_threads x 2. User can use this
-         * operation to override the default workerCount from Netty.
+         * from Netty (which is cpu_core_threads x 2). User can use this option
+         * to override the default workerCount from Netty.
          * 
          * The option will be converted to a <code>int</code> type.
          * 
@@ -3789,8 +3789,8 @@ public interface NettyEndpointBuilderFactory {
         }
         /**
          * When netty works on nio mode, it uses default workerCount parameter
-         * from Netty, which is cpu_core_threads x 2. User can use this
-         * operation to override the default workerCount from Netty.
+         * from Netty (which is cpu_core_threads x 2). User can use this option
+         * to override the default workerCount from Netty.
          * 
          * The option is a: <code>int</code> type.
          * 
@@ -3802,8 +3802,8 @@ public interface NettyEndpointBuilderFactory {
         }
         /**
          * When netty works on nio mode, it uses default workerCount parameter
-         * from Netty, which is cpu_core_threads x 2. User can use this
-         * operation to override the default workerCount from Netty.
+         * from Netty (which is cpu_core_threads x 2). User can use this option
+         * to override the default workerCount from Netty.
          * 
          * The option will be converted to a <code>int</code> type.
          * 
diff --git a/platforms/spring-boot/components-starter/camel-netty-starter/src/main/java/org/apache/camel/component/netty/springboot/NettyComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-netty-starter/src/main/java/org/apache/camel/component/netty/springboot/NettyComponentConfiguration.java
index 9cdf46e..01fdf34 100644
--- a/platforms/spring-boot/components-starter/camel-netty-starter/src/main/java/org/apache/camel/component/netty/springboot/NettyComponentConfiguration.java
+++ b/platforms/spring-boot/components-starter/camel-netty-starter/src/main/java/org/apache/camel/component/netty/springboot/NettyComponentConfiguration.java
@@ -415,13 +415,13 @@ public class NettyComponentConfiguration
         private Integer receiveBufferSizePredictor;
         /**
          * When netty works on nio mode, it uses default workerCount parameter
-         * from Netty, which is cpu_core_threads x 2. User can use this
-         * operation to override the default workerCount from Netty.
+         * from Netty (which is cpu_core_threads x 2). User can use this option
+         * to override the default workerCount from Netty.
          */
         private Integer workerCount;
         /**
          * When netty works on nio mode, it uses default bossCount parameter
-         * from Netty, which is 1. User can use this operation to override the
+         * from Netty, which is 1. User can use this option to override the
          * default bossCount from Netty
          */
         private Integer bossCount = 1;