cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cxf git commit: setter for applicationExecutor This closes #284
Date Thu, 22 Jun 2017 11:50:51 GMT
Repository: cxf
Updated Branches:
  refs/heads/master e9f7d73e6 -> 21618dad0


setter for applicationExecutor This closes #284


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

Branch: refs/heads/master
Commit: 21618dad08506cc80edde02cf1661cecd06c49ab
Parents: e9f7d73
Author: Maxim Samoylych <msamoylych@sberbank-tele.com>
Authored: Thu Jun 22 13:50:14 2017 +0200
Committer: Dennis Kieselhorst <deki@apache.org>
Committed: Thu Jun 22 13:50:14 2017 +0200

----------------------------------------------------------------------
 .../netty/server/NettyHttpServerEngine.java     | 27 +++++++++++++++++---
 .../server/NettyHttpServletPipelineFactory.java | 17 +++++++++---
 2 files changed, 37 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/21618dad/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServerEngine.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServerEngine.java
b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServerEngine.java
index 878f5b4..6dff4e6 100644
--- a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServerEngine.java
+++ b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServerEngine.java
@@ -40,7 +40,8 @@ import io.netty.channel.ChannelOption;
 import io.netty.channel.EventLoopGroup;
 import io.netty.channel.nio.NioEventLoopGroup;
 import io.netty.channel.socket.nio.NioServerSocketChannel;
-
+import io.netty.util.concurrent.DefaultEventExecutorGroup;
+import io.netty.util.concurrent.EventExecutorGroup;
 
 public class NettyHttpServerEngine implements ServerEngine {
 
@@ -92,6 +93,7 @@ public class NettyHttpServerEngine implements ServerEngine {
     // TODO need to setup configuration about them
     private EventLoopGroup bossGroup;
     private EventLoopGroup workerGroup;
+    private EventExecutorGroup applicationExecutor;
 
     public NettyHttpServerEngine() {
 
@@ -141,6 +143,9 @@ public class NettyHttpServerEngine implements ServerEngine {
         if (workerGroup == null) {
             workerGroup = new NioEventLoopGroup();
         }
+        if (applicationExecutor == null) {
+            applicationExecutor = new DefaultEventExecutorGroup(threadingParameters.getThreadPoolSize());
+        }
 
         final ServerBootstrap bootstrap = new ServerBootstrap();
         bootstrap.group(bossGroup, workerGroup)
@@ -151,9 +156,8 @@ public class NettyHttpServerEngine implements ServerEngine {
         servletPipeline =
             new NettyHttpServletPipelineFactory(
                  tlsServerParameters, sessionSupport,
-                 threadingParameters.getThreadPoolSize(),
-                 maxChunkContentSize,
-                 handlerMap, this);
+                 maxChunkContentSize, handlerMap,
+                 this, applicationExecutor);
         // Start the servletPipeline's timer
         servletPipeline.start();
         bootstrap.childHandler(servletPipeline);
@@ -235,6 +239,9 @@ public class NettyHttpServerEngine implements ServerEngine {
         // just unbind the channel
         if (servletPipeline != null) {
             servletPipeline.shutdown();
+        } else if (applicationExecutor != null) {
+            // shutdown executor if it set but not server started
+            applicationExecutor.shutdownGracefully();
         }
 
         if (serverChannel != null) {
@@ -329,4 +336,16 @@ public class NettyHttpServerEngine implements ServerEngine {
     public EventLoopGroup getWorkerGroup() {
         return workerGroup;
     }
+
+    public EventExecutorGroup getApplicationExecutor() {
+        return applicationExecutor;
+    }
+
+    public void setApplicationExecutor(EventExecutorGroup applicationExecutor) {
+        if (this.applicationExecutor == null) {
+            this.applicationExecutor = applicationExecutor;
+        } else {
+            throw new IllegalStateException("applicationExecutor is already defined");
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/21618dad/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServletPipelineFactory.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServletPipelineFactory.java
b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServletPipelineFactory.java
index eec502a..5c27ae5 100644
--- a/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServletPipelineFactory.java
+++ b/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServletPipelineFactory.java
@@ -69,21 +69,32 @@ public class NettyHttpServletPipelineFactory extends ChannelInitializer<Channel>
 
     private final NettyHttpServerEngine nettyHttpServerEngine;
 
+    /**
+     * @deprecated use {@link #NettyHttpServletPipelineFactory(TLSServerParameters, boolean,
int, Map,
+     * NettyHttpServerEngine, EventExecutorGroup)}
+     */
+    @Deprecated
     public NettyHttpServletPipelineFactory(TLSServerParameters tlsServerParameters,
                                            boolean supportSession, int threadPoolSize, int
maxChunkContentSize,
                                            Map<String, NettyHttpContextHandler> handlerMap,
                                            NettyHttpServerEngine engine) {
+        this(tlsServerParameters, supportSession, maxChunkContentSize, handlerMap, engine,
+                new DefaultEventExecutorGroup(threadPoolSize));
+    }
+
+    public NettyHttpServletPipelineFactory(TLSServerParameters tlsServerParameters,
+                                           boolean supportSession, int maxChunkContentSize,
+                                           Map<String, NettyHttpContextHandler> handlerMap,
+                                           NettyHttpServerEngine engine, EventExecutorGroup
applicationExecutor) {
         this.supportSession = supportSession;
         this.watchdog = new HttpSessionWatchdog();
         this.handlerMap = handlerMap;
         this.tlsServerParameters = tlsServerParameters;
         this.maxChunkContentSize = maxChunkContentSize;
         this.nettyHttpServerEngine = engine;
-        //TODO need to configure the thread size of EventExecutorGroup
-        applicationExecutor = new DefaultEventExecutorGroup(threadPoolSize);
+        this.applicationExecutor = applicationExecutor;
     }
 
-
     public Map<String, NettyHttpContextHandler> getHttpContextHandlerMap() {
         return handlerMap;
     }


Mime
View raw message