You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2021/10/11 19:44:03 UTC

[GitHub] [ignite-3] sashapolo commented on a change in pull request #294: IGNITE-14538 Network configuration

sashapolo commented on a change in pull request #294:
URL: https://github.com/apache/ignite-3/pull/294#discussion_r726525637



##########
File path: modules/network/src/integrationTest/java/org/apache/ignite/utils/ClusterServiceTestUtils.java
##########
@@ -105,4 +125,31 @@ public static ClusterService clusterService(
             }
         };
     }
+
+    /**
+     * Creates a closure that configures {@link StaticNodeFinder}.
+     *
+     * @param addresses List of nodes' addresses.
+     * @return Configuration closure.
+     */
+    public static Consumer<NodeFinderChange> createStaticNodeFinderConfiguration(List<NetworkAddress> addresses) {
+        String[] addrs = addresses.stream().map(NetworkAddress::toString).toArray(String[]::new);
+
+        return change ->
+            change.changeType(NodeFinderType.STATIC.name())
+                .changeNetClusterNodes(addrs);
+    }
+
+    /**
+     *
+     *
+     * @param startPort Start port.

Review comment:
       ```suggestion
        * @param startPort Start port (inclusive).
   ```

##########
File path: modules/network/src/main/java/org/apache/ignite/network/NodeFinderFactory.java
##########
@@ -0,0 +1,61 @@
+/*
+ * 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 java.util.Arrays;
+import org.apache.ignite.configuration.schemas.network.NodeFinderType;
+import org.apache.ignite.configuration.schemas.network.NodeFinderView;
+import org.apache.ignite.lang.IgniteInternalException;
+
+import static java.util.stream.Collectors.collectingAndThen;
+import static java.util.stream.Collectors.toUnmodifiableList;
+
+/**
+ * {@link NodeFinder} factory.
+ */
+public class NodeFinderFactory {
+    /**
+     * Creates a {@link NodeFinder} based on the provided configuration.
+     *
+     * @param nodeFinderConfiguration Node finder configuration.
+     * @return Node finder.
+     */
+    public static NodeFinder createNodeFinder(NodeFinderView nodeFinderConfiguration) {
+        String typeString = nodeFinderConfiguration.type();
+
+        NodeFinderType type;
+
+        try {
+            type = NodeFinderType.valueOf(typeString);
+        }
+        catch (IllegalArgumentException e) {
+            throw new IgniteInternalException("Failed to create NodeFinder " + typeString, e);

Review comment:
       Why is this an internal exception? Shouldn't it be the same as below?

##########
File path: modules/api/src/main/java/org/apache/ignite/configuration/schemas/network/ClusterMembershipConfigurationSchema.java
##########
@@ -0,0 +1,40 @@
+/*
+ * 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.configuration.schemas.network;
+
+import org.apache.ignite.configuration.annotation.Config;
+import org.apache.ignite.configuration.annotation.ConfigValue;
+import org.apache.ignite.configuration.annotation.Value;
+
+/**
+ * Cluster membership configuration.
+ */
+@Config
+public class ClusterMembershipConfigurationSchema {

Review comment:
       Why do we need this class? Why `membershipSyncInterval` and `failurePingInterval` are separate properties?

##########
File path: modules/network/src/integrationTest/java/org/apache/ignite/utils/ClusterServiceTestUtils.java
##########
@@ -105,4 +125,31 @@ public static ClusterService clusterService(
             }
         };
     }
+
+    /**
+     * Creates a closure that configures {@link StaticNodeFinder}.
+     *
+     * @param addresses List of nodes' addresses.
+     * @return Configuration closure.
+     */
+    public static Consumer<NodeFinderChange> createStaticNodeFinderConfiguration(List<NetworkAddress> addresses) {
+        String[] addrs = addresses.stream().map(NetworkAddress::toString).toArray(String[]::new);
+
+        return change ->
+            change.changeType(NodeFinderType.STATIC.name())
+                .changeNetClusterNodes(addrs);
+    }
+
+    /**
+     *
+     *
+     * @param startPort Start port.
+     * @param endPort End port.

Review comment:
       ```suggestion
        * @param endPort End port (exclusive).
   ```

##########
File path: modules/network/src/main/java/org/apache/ignite/internal/network/netty/NettyServer.java
##########
@@ -260,6 +258,28 @@ public NettyServer(
         }
     }
 
+    /**
+     * Try bind this server to the port.

Review comment:
       ```suggestion
        * Try bind this server to a port.
   ```

##########
File path: modules/network/src/integrationTest/java/org/apache/ignite/utils/ClusterServiceTestUtils.java
##########
@@ -105,4 +125,31 @@ public static ClusterService clusterService(
             }
         };
     }
+
+    /**
+     * Creates a closure that configures {@link StaticNodeFinder}.
+     *
+     * @param addresses List of nodes' addresses.
+     * @return Configuration closure.
+     */
+    public static Consumer<NodeFinderChange> createStaticNodeFinderConfiguration(List<NetworkAddress> addresses) {

Review comment:
       Is this method still used?

##########
File path: modules/network/src/integrationTest/java/org/apache/ignite/network/scalecube/ITNodeRestartsTest.java
##########
@@ -107,14 +107,16 @@ public void testRestarts(TestInfo testInfo) {
      *
      * @param testInfo Test info.
      * @param addr Node address.
-     * @param nodeFinder Node finder.
+     * @param portStart Localhost node finder start port.
+     * @param portEnd Localhost node finder end port.
      * @return Created Cluster Service.
      */
-    private ClusterService startNetwork(TestInfo testInfo, NetworkAddress addr, NodeFinder nodeFinder) {
+    private ClusterService startNetwork(TestInfo testInfo, NetworkAddress addr, int portStart, int portEnd) {

Review comment:
       Should this method accept a list of addresses instead of a port range?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org