You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by pt...@apache.org on 2021/11/19 08:11:10 UTC

[ignite-3] branch ignite-15307 updated: IGNITE-15307 Thin 3.0: Reuse Netty infrastructure from network module

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

ptupitsyn pushed a commit to branch ignite-15307
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


The following commit(s) were added to refs/heads/ignite-15307 by this push:
     new 46f6cab  IGNITE-15307 Thin 3.0: Reuse Netty infrastructure from network module
46f6cab is described below

commit 46f6cab7f0eac5811a1d8fe08353585b7f245aff
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Fri Nov 19 11:09:53 2021 +0300

    IGNITE-15307 Thin 3.0: Reuse Netty infrastructure from network module
---
 .../internal/network/netty/ConnectionManager.java  | 16 +++++++++++--
 .../ignite/internal/network/netty/NettyServer.java | 26 +++++++++++++---------
 .../internal/network/netty/NettyServerTest.java    |  8 +++++--
 3 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/modules/network/src/main/java/org/apache/ignite/internal/network/netty/ConnectionManager.java b/modules/network/src/main/java/org/apache/ignite/internal/network/netty/ConnectionManager.java
index 7a08a8f..a42f903 100644
--- a/modules/network/src/main/java/org/apache/ignite/internal/network/netty/ConnectionManager.java
+++ b/modules/network/src/main/java/org/apache/ignite/internal/network/netty/ConnectionManager.java
@@ -59,6 +59,12 @@ public class ConnectionManager {
     /** Client bootstrap. */
     private final Bootstrap clientBootstrap;
     
+    /** Server boss socket channel handler event loop group. */
+    private final EventLoopGroup bossGroup;
+    
+    /** Server work socket channel handler event loop group. */
+    private final EventLoopGroup workerGroup;
+    
     /** Client socket channel handler event loop group. */
     private final EventLoopGroup clientWorkerGroup;
     
@@ -108,15 +114,21 @@ public class ConnectionManager {
         this.serializationRegistry = registry;
         this.consistentId = consistentId;
         this.clientHandshakeManagerFactory = clientHandshakeManagerFactory;
+        
+        this.bossGroup = NamedNioEventLoopGroup.create(consistentId + "-srv-accept");
+        this.workerGroup = NamedNioEventLoopGroup.create(consistentId + "-srv-worker");
+        this.clientWorkerGroup = NamedNioEventLoopGroup.create(consistentId + "-client");
+    
         this.server = new NettyServer(
                 consistentId,
                 networkConfiguration,
                 serverHandshakeManagerFactory,
                 this::onNewIncomingChannel,
                 this::onMessage,
-                serializationRegistry
+                serializationRegistry,
+                bossGroup,
+                workerGroup
         );
-        this.clientWorkerGroup = NamedNioEventLoopGroup.create(consistentId + "-client");
         this.clientBootstrap = createClientBootstrap(clientWorkerGroup, networkConfiguration.outbound());
     }
     
diff --git a/modules/network/src/main/java/org/apache/ignite/internal/network/netty/NettyServer.java b/modules/network/src/main/java/org/apache/ignite/internal/network/netty/NettyServer.java
index 2bba177..abf3b09 100644
--- a/modules/network/src/main/java/org/apache/ignite/internal/network/netty/NettyServer.java
+++ b/modules/network/src/main/java/org/apache/ignite/internal/network/netty/NettyServer.java
@@ -22,8 +22,8 @@ import io.netty.channel.Channel;
 import io.netty.channel.ChannelFuture;
 import io.netty.channel.ChannelInitializer;
 import io.netty.channel.ChannelOption;
+import io.netty.channel.EventLoopGroup;
 import io.netty.channel.ServerChannel;
-import io.netty.channel.nio.NioEventLoopGroup;
 import io.netty.channel.socket.SocketChannel;
 import io.netty.channel.socket.nio.NioServerSocketChannel;
 import io.netty.handler.stream.ChunkedWriteHandler;
@@ -55,10 +55,10 @@ public class NettyServer {
     private final ServerBootstrap bootstrap;
     
     /** Socket accepter event loop group. */
-    private final NioEventLoopGroup bossGroup;
+    private final EventLoopGroup bossGroup;
     
     /** Socket handler event loop group. */
-    private final NioEventLoopGroup workerGroup;
+    private final EventLoopGroup workerGroup;
     
     /** Server socket configuration. */
     private final NetworkView configuration;
@@ -104,7 +104,9 @@ public class NettyServer {
             Supplier<HandshakeManager> handshakeManager,
             Consumer<NettySender> newConnectionListener,
             BiConsumer<SocketAddress, NetworkMessage> messageListener,
-            MessageSerializationRegistry serializationRegistry
+            MessageSerializationRegistry serializationRegistry,
+            EventLoopGroup bossGroup,
+            EventLoopGroup workerGroup
     ) {
         this(
                 consistentId,
@@ -113,7 +115,9 @@ public class NettyServer {
                 handshakeManager,
                 newConnectionListener,
                 messageListener,
-                serializationRegistry
+                serializationRegistry,
+                bossGroup,
+                workerGroup
         );
     }
     
@@ -135,7 +139,9 @@ public class NettyServer {
             Supplier<HandshakeManager> handshakeManager,
             Consumer<NettySender> newConnectionListener,
             BiConsumer<SocketAddress, NetworkMessage> messageListener,
-            MessageSerializationRegistry serializationRegistry
+            MessageSerializationRegistry serializationRegistry,
+            EventLoopGroup bossGroup,
+            EventLoopGroup workerGroup
     ) {
         this.bootstrap = bootstrap;
         this.configuration = configuration;
@@ -143,8 +149,8 @@ public class NettyServer {
         this.newConnectionListener = newConnectionListener;
         this.messageListener = messageListener;
         this.serializationRegistry = serializationRegistry;
-        this.bossGroup = NamedNioEventLoopGroup.create(consistentId + "-srv-accept");
-        this.workerGroup = NamedNioEventLoopGroup.create(consistentId + "-srv-worker");
+        this.bossGroup = bossGroup;
+        this.workerGroup = workerGroup;
         serverCloseFuture = CompletableFuture.allOf(
                 NettyUtils.toCompletableFuture(bossGroup.terminationFuture()),
                 NettyUtils.toCompletableFuture(workerGroup.terminationFuture())
@@ -361,7 +367,7 @@ public class NettyServer {
      * @return Acceptor event loop group.
      */
     @TestOnly
-    public NioEventLoopGroup getBossGroup() {
+    public EventLoopGroup getBossGroup() {
         return bossGroup;
     }
     
@@ -371,7 +377,7 @@ public class NettyServer {
      * @return Worker event loop group.
      */
     @TestOnly
-    public NioEventLoopGroup getWorkerGroup() {
+    public EventLoopGroup getWorkerGroup() {
         return workerGroup;
     }
 }
diff --git a/modules/network/src/test/java/org/apache/ignite/internal/network/netty/NettyServerTest.java b/modules/network/src/test/java/org/apache/ignite/internal/network/netty/NettyServerTest.java
index 1c905e4..46d1232 100644
--- a/modules/network/src/test/java/org/apache/ignite/internal/network/netty/NettyServerTest.java
+++ b/modules/network/src/test/java/org/apache/ignite/internal/network/netty/NettyServerTest.java
@@ -221,7 +221,9 @@ public class NettyServerTest {
                 },
                 (socketAddress, message) -> {
                 },
-                registry
+                registry,
+                NamedNioEventLoopGroup.create("boss-"),
+                NamedNioEventLoopGroup.create("worker-")
         );
         
         server.start().get(3, TimeUnit.SECONDS);
@@ -289,7 +291,9 @@ public class NettyServerTest {
                 () -> mock(HandshakeManager.class),
                 null,
                 null,
-                null
+                null,
+                NamedNioEventLoopGroup.create("boss-"),
+                NamedNioEventLoopGroup.create("worker-")
         );
         
         try {