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/22 17:49:02 UTC

[ignite-3] branch ignite-15307 updated (a894afa -> b9406eb)

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

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


    from a894afa  wip propagate bootstrap factory
     new 8b7cad1  wip propagate bootstrap factory, remove ClusterServiceFactory interface
     new b9406eb  Update ClientHandlerModule

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../ignite/client/handler/ClientHandlerModule.java | 38 ++++++----------------
 .../ignite/network/ClusterServiceFactory.java      | 38 ----------------------
 .../internal/network/netty/ConnectionManager.java  | 14 ++++----
 .../ignite/network/NettyBootstrapFactory.java      |  4 +++
 .../scalecube/ScaleCubeClusterServiceFactory.java  |  6 ++--
 .../org/apache/ignite/internal/app/IgniteImpl.java | 10 +++---
 6 files changed, 28 insertions(+), 82 deletions(-)
 delete mode 100644 modules/network-api/src/main/java/org/apache/ignite/network/ClusterServiceFactory.java

[ignite-3] 02/02: Update ClientHandlerModule

Posted by pt...@apache.org.
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

commit b9406ebbb63abd3e02157edebc9d4f03d03786d1
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Mon Nov 22 20:48:56 2021 +0300

    Update ClientHandlerModule
---
 .../ignite/client/handler/ClientHandlerModule.java | 38 ++++++----------------
 1 file changed, 10 insertions(+), 28 deletions(-)

diff --git a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/ClientHandlerModule.java b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/ClientHandlerModule.java
index 6708ec5..697efa6 100644
--- a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/ClientHandlerModule.java
+++ b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/ClientHandlerModule.java
@@ -17,22 +17,16 @@
 
 package org.apache.ignite.client.handler;
 
-import io.netty.bootstrap.ServerBootstrap;
 import io.netty.channel.Channel;
 import io.netty.channel.ChannelFuture;
-import io.netty.channel.ChannelFutureListener;
 import io.netty.channel.ChannelInitializer;
 import io.netty.channel.ChannelOption;
-import io.netty.channel.EventLoopGroup;
-import io.netty.channel.nio.NioEventLoopGroup;
-import io.netty.channel.socket.nio.NioServerSocketChannel;
 import java.net.BindException;
 import java.net.SocketAddress;
 import org.apache.ignite.configuration.schemas.clientconnector.ClientConnectorConfiguration;
 import org.apache.ignite.internal.client.proto.ClientMessageDecoder;
 import org.apache.ignite.internal.configuration.ConfigurationRegistry;
 import org.apache.ignite.internal.manager.IgniteComponent;
-import org.apache.ignite.internal.network.netty.ConnectionManager;
 import org.apache.ignite.internal.processors.query.calcite.QueryProcessor;
 import org.apache.ignite.lang.IgniteException;
 import org.apache.ignite.lang.IgniteLogger;
@@ -57,13 +51,10 @@ public class ClientHandlerModule implements IgniteComponent {
     private volatile Channel channel;
 
     /** Processor. */
-    private QueryProcessor processor;
-    
-    /** Connection manager. */
-    private ConnectionManager connectionManager;
+    private final QueryProcessor processor;
     
     /** Netty bootstrap factory. */
-    private NettyBootstrapFactory bootstrapFactory;
+    private final NettyBootstrapFactory bootstrapFactory;
     
     /**
      * Constructor.
@@ -138,14 +129,10 @@ public class ClientHandlerModule implements IgniteComponent {
 
         int port = 0;
         Channel ch = null;
-
-        // TODO: Reuse Netty infrastructure from network module IGNITE-15307.
-        EventLoopGroup eventLoopGroup = new NioEventLoopGroup();
-        ServerBootstrap b = new ServerBootstrap();
-
-        b.group(eventLoopGroup)
-                .channel(NioServerSocketChannel.class)
-                .childHandler(new ChannelInitializer<>() {
+    
+        var bootstrap = bootstrapFactory.createServerBootstrap();
+    
+        bootstrap.childHandler(new ChannelInitializer<>() {
                     @Override
                     protected void initChannel(Channel ch) {
                         ch.pipeline().addLast(
@@ -153,21 +140,18 @@ public class ClientHandlerModule implements IgniteComponent {
                                 new ClientInboundMessageHandler(igniteTables, processor));
                     }
                 })
-                .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, configuration.connectTimeout())
-                .childOption(ChannelOption.SO_KEEPALIVE, true)
-                .childOption(ChannelOption.TCP_NODELAY, true);
-
+                .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, configuration.connectTimeout());
+    
         for (int portCandidate = desiredPort; portCandidate <= desiredPort + portRange; portCandidate++) {
-            ChannelFuture bindRes = b.bind(portCandidate).await();
+            ChannelFuture bindRes = bootstrap.bind(portCandidate).await();
 
             if (bindRes.isSuccess()) {
                 ch = bindRes.channel();
-                ch.closeFuture().addListener((ChannelFutureListener) fut -> eventLoopGroup.shutdownGracefully());
+                ch.closeFuture();
 
                 port = portCandidate;
                 break;
             } else if (!(bindRes.cause() instanceof BindException)) {
-                eventLoopGroup.shutdownGracefully();
                 throw new IgniteException(bindRes.cause());
             }
         }
@@ -178,8 +162,6 @@ public class ClientHandlerModule implements IgniteComponent {
 
             LOG.error(msg);
 
-            eventLoopGroup.shutdownGracefully();
-
             throw new IgniteException(msg);
         }
 

[ignite-3] 01/02: wip propagate bootstrap factory, remove ClusterServiceFactory interface

Posted by pt...@apache.org.
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

commit 8b7cad1a9c8c32c97811eae6294e0740a3044995
Author: Pavel Tupitsyn <pt...@apache.org>
AuthorDate: Mon Nov 22 20:47:10 2021 +0300

    wip propagate bootstrap factory, remove ClusterServiceFactory interface
---
 .../ignite/network/ClusterServiceFactory.java      | 38 ----------------------
 .../internal/network/netty/ConnectionManager.java  | 14 ++++----
 .../ignite/network/NettyBootstrapFactory.java      |  4 +++
 .../scalecube/ScaleCubeClusterServiceFactory.java  |  6 ++--
 .../org/apache/ignite/internal/app/IgniteImpl.java | 10 +++---
 5 files changed, 18 insertions(+), 54 deletions(-)

diff --git a/modules/network-api/src/main/java/org/apache/ignite/network/ClusterServiceFactory.java b/modules/network-api/src/main/java/org/apache/ignite/network/ClusterServiceFactory.java
deleted file mode 100644
index 42c9ab7..0000000
--- a/modules/network-api/src/main/java/org/apache/ignite/network/ClusterServiceFactory.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.network;
-
-import org.apache.ignite.configuration.schemas.network.NetworkConfiguration;
-
-/**
- * Cluster service factory.
- */
-public interface ClusterServiceFactory {
-    /**
-     * Creates a new {@link ClusterService} using the provided context. The created network will not be in the "started" state.
-     *
-     * @param context              Cluster context.
-     * @param networkConfiguration Network configuration.
-     * @param nettyBootstrapFactory
-     * @return New cluster service.
-     */
-    ClusterService createClusterService(
-            ClusterLocalConfiguration context,
-            NetworkConfiguration networkConfiguration,
-            NettyBootstrapFactory nettyBootstrapFactory);
-}
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 34e2cd8..0b51cd8 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
@@ -57,8 +57,8 @@ public class ConnectionManager {
     /** Latest version of the direct marshalling protocol. */
     public static final byte DIRECT_PROTOCOL_VERSION = 1;
     
-    /** Bootstrap factory. */
-    private final NettyBootstrapFactory bootstrapFactory;
+    /** Client bootstrap. */
+    private final Bootstrap clientBootstrap;
     
     /** Server. */
     private final NettyServer server;
@@ -109,17 +109,17 @@ public class ConnectionManager {
         this.consistentId = consistentId;
         this.clientHandshakeManagerFactory = clientHandshakeManagerFactory;
 
-        this.bootstrapFactory = bootstrapFactory;
-    
         this.server = new NettyServer(
                 consistentId,
                 networkConfiguration,
                 serverHandshakeManagerFactory,
                 this::onNewIncomingChannel,
                 this::onMessage,
-                serializationRegistry
+                serializationRegistry,
+                bootstrapFactory
         );
-        this.clientBootstrap = createClientBootstrap(clientWorkerGroup, networkConfiguration.outbound());
+        
+        this.clientBootstrap = bootstrapFactory.createClientBootstrap();
     }
     
     /**
@@ -271,8 +271,6 @@ public class ConnectionManager {
         
         try {
             stopFut.join();
-            // TODO: IGNITE-14538 quietPeriod and timeout should be configurable.
-            clientWorkerGroup.shutdownGracefully(0L, 15, TimeUnit.SECONDS).sync();
         } catch (Exception e) {
             LOG.warn("Failed to stop the ConnectionManager: {}", e.getMessage());
         }
diff --git a/modules/network/src/main/java/org/apache/ignite/network/NettyBootstrapFactory.java b/modules/network/src/main/java/org/apache/ignite/network/NettyBootstrapFactory.java
index 2c2b852..4995802 100644
--- a/modules/network/src/main/java/org/apache/ignite/network/NettyBootstrapFactory.java
+++ b/modules/network/src/main/java/org/apache/ignite/network/NettyBootstrapFactory.java
@@ -62,6 +62,10 @@ public class NettyBootstrapFactory {
         bossGroup = NamedNioEventLoopGroup.create(consistentId + "-srv-accept");
         workerGroup = NamedNioEventLoopGroup.create(consistentId + "-srv-worker");
         clientWorkerGroup = NamedNioEventLoopGroup.create(consistentId + "-client");
+        
+        // TODO: When do we stop everything?
+        // TODO: IGNITE-14538 quietPeriod and timeout should be configurable.
+        // clientWorkerGroup.shutdownGracefully(0L, 15, TimeUnit.SECONDS).sync();
     }
     
     /**
diff --git a/modules/network/src/main/java/org/apache/ignite/network/scalecube/ScaleCubeClusterServiceFactory.java b/modules/network/src/main/java/org/apache/ignite/network/scalecube/ScaleCubeClusterServiceFactory.java
index e9c0d14..65dbaff 100644
--- a/modules/network/src/main/java/org/apache/ignite/network/scalecube/ScaleCubeClusterServiceFactory.java
+++ b/modules/network/src/main/java/org/apache/ignite/network/scalecube/ScaleCubeClusterServiceFactory.java
@@ -37,7 +37,6 @@ import org.apache.ignite.internal.network.recovery.RecoveryServerHandshakeManage
 import org.apache.ignite.network.AbstractClusterService;
 import org.apache.ignite.network.ClusterLocalConfiguration;
 import org.apache.ignite.network.ClusterService;
-import org.apache.ignite.network.ClusterServiceFactory;
 import org.apache.ignite.network.NettyBootstrapFactory;
 import org.apache.ignite.network.NetworkAddress;
 import org.apache.ignite.network.NodeFinder;
@@ -45,11 +44,10 @@ import org.apache.ignite.network.NodeFinderFactory;
 import org.apache.ignite.network.serialization.MessageSerializationRegistry;
 
 /**
- * {@link ClusterServiceFactory} implementation that uses ScaleCube for messaging and topology services.
+ * ScaleCube cluster service factory for messaging and topology services.
  */
-public class ScaleCubeClusterServiceFactory implements ClusterServiceFactory {
+public class ScaleCubeClusterServiceFactory {
     /** {@inheritDoc} */
-    @Override
     public ClusterService createClusterService(
             ClusterLocalConfiguration context,
             NetworkConfiguration networkConfiguration,
diff --git a/modules/runner/src/main/java/org/apache/ignite/internal/app/IgniteImpl.java b/modules/runner/src/main/java/org/apache/ignite/internal/app/IgniteImpl.java
index f58bb8d..a31356a 100644
--- a/modules/runner/src/main/java/org/apache/ignite/internal/app/IgniteImpl.java
+++ b/modules/runner/src/main/java/org/apache/ignite/internal/app/IgniteImpl.java
@@ -231,10 +231,12 @@ public class IgniteImpl implements Ignite {
 
         restModule = new RestModule(nodeCfgMgr, clusterCfgMgr);
 
-        // TODO: Create a common class to hold EventLoopGroup, and create all bootstraps.
-        // - Put it into network-api
-        // - Inject where needed
-        clientHandlerModule = new ClientHandlerModule(qryEngine, distributedTblMgr, nodeCfgMgr.configurationRegistry(), null);
+        clientHandlerModule = new ClientHandlerModule(
+                qryEngine,
+                distributedTblMgr,
+                nodeCfgMgr.configurationRegistry(),
+                nettyBootstrapFactory
+        );
     }
 
     /**