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/04/12 07:43:31 UTC

[GitHub] [ignite-3] ascherbakoff commented on a change in pull request #84: IGNITE-14382 Rework network module API structure

ascherbakoff commented on a change in pull request #84:
URL: https://github.com/apache/ignite-3/pull/84#discussion_r611386864



##########
File path: modules/network/src/main/java/org/apache/ignite/network/ClusterLocalConfiguration.java
##########
@@ -0,0 +1,84 @@
+/*
+ * 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.List;
+import org.apache.ignite.network.message.MessageSerializationRegistry;
+
+/**
+ * Network configuration of a node.
+ *
+ * TODO: migrate to common configuration class when it's available, see
+ *  https://issues.apache.org/jira/browse/IGNITE-14496
+ */
+public class ClusterLocalConfiguration {
+    /** Network alias of a node. */
+    private final String name;
+
+    /** Port. */

Review comment:
       ```suggestion
       /** The port. */
   ```

##########
File path: modules/network/src/main/java/org/apache/ignite/network/AbstractMessagingService.java
##########
@@ -15,36 +15,28 @@
  * limitations under the License.
  */
 
-package org.apache.ignite.network.scalecube;
+package org.apache.ignite.network;
 
-import org.apache.ignite.network.message.NetworkMessage;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 /**
- * Test response.
+ * Base class for {@link MessagingService} implementations.
  */
-public class TestResponse implements NetworkMessage {
-    /** Public type for tests. */
-    public static final short TYPE = 2;
+public abstract class AbstractMessagingService implements MessagingService {
+    /** */
+    private final Collection<NetworkMessageHandler> messageHandlers = new CopyOnWriteArrayList<>();
 
-    /**
-     * Some response test value.
-     */
-    private final int responseNumber;
-
-    /** Constructor. */
-    public TestResponse(int responseNumber) {
-        this.responseNumber = responseNumber;
+    /** {@inheritDoc} */
+    @Override public void addMessageHandler(NetworkMessageHandler handler) {

Review comment:
       We need a way to unregister message handlers for dynamically started components.

##########
File path: modules/network/src/main/java/org/apache/ignite/network/ClusterService.java
##########
@@ -0,0 +1,49 @@
+/*
+ * 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;
+
+/**
+ * Class that represents the network-related resources of a node and provides entry points for working with the
+ * network members of a cluster.
+ */
+public interface ClusterService {
+    /**
+     * Returns the {@link TopologyService} for working with the cluster topology.
+     */
+    TopologyService getTopologyService();
+
+    /**
+     * Returns the {@link TopologyService} for sending messages to the cluster members.
+     */
+    MessagingService getMessagingService();

Review comment:
       ```suggestion
       MessagingService messagingService();
   ```

##########
File path: modules/network/src/main/java/org/apache/ignite/network/scalecube/ScaleCubeMemberResolver.java
##########
@@ -19,46 +19,39 @@
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import io.scalecube.cluster.Member;
-import org.apache.ignite.network.NetworkMember;
+import org.apache.ignite.network.ClusterNode;
 
 import static java.util.Objects.requireNonNull;
 
 /**
  * Resolver for scalecube specific member.
  */
-public class ScaleCubeMemberResolver {
+final class ScaleCubeMemberResolver {
     /** Map of public network member by its unique name. */
-    private final Map<String, NetworkMember> directMemberMap = new ConcurrentHashMap<>();
+    private final Map<String, ClusterNode> directMemberMap = new ConcurrentHashMap<>();

Review comment:
       Looks like these maps are never cleared. Maybe they should on node leaving ?

##########
File path: modules/network/src/main/java/org/apache/ignite/network/AbstractTopologyService.java
##########
@@ -15,34 +15,28 @@
  * limitations under the License.
  */
 
-package org.apache.ignite.network.scalecube;
+package org.apache.ignite.network;
 
-import org.apache.ignite.network.message.NetworkMessage;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 /**
- * Test request which requires {@link TestResponse} as a response.
+ * Base class for {@link TopologyService} implementations.
  */
-public class TestRequest implements NetworkMessage {
-    /** Public type for tests. */
-    public static final short TYPE = 1;
+public abstract class AbstractTopologyService implements TopologyService {
+    /** */
+    private final Collection<TopologyEventHandler> eventHandlers = new CopyOnWriteArrayList<>();
 
-    /** Some test value. */
-    private final int number;
-
-    /** Constructor. */
-    public TestRequest(int number) {
-        this.number = number;
+    /** {@inheritDoc} */
+    @Override public void addEventHandler(TopologyEventHandler handler) {
+        eventHandlers.add(handler);

Review comment:
       We need a way to unregister event handlers for dynamically started components.

##########
File path: modules/network/src/main/java/org/apache/ignite/network/ClusterService.java
##########
@@ -0,0 +1,49 @@
+/*
+ * 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;
+
+/**
+ * Class that represents the network-related resources of a node and provides entry points for working with the
+ * network members of a cluster.
+ */
+public interface ClusterService {
+    /**
+     * Returns the {@link TopologyService} for working with the cluster topology.
+     */
+    TopologyService getTopologyService();
+
+    /**
+     * Returns the {@link TopologyService} for sending messages to the cluster members.
+     */
+    MessagingService getMessagingService();
+
+    /**
+     * Returns the context associated with the current node.
+     */
+    ClusterLocalConfiguration getLocalConfiguration();

Review comment:
       ```suggestion
       ClusterLocalConfiguration localConfiguration();
   ```

##########
File path: modules/network/src/main/java/org/apache/ignite/network/ClusterService.java
##########
@@ -0,0 +1,49 @@
+/*
+ * 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;
+
+/**
+ * Class that represents the network-related resources of a node and provides entry points for working with the
+ * network members of a cluster.
+ */
+public interface ClusterService {
+    /**
+     * Returns the {@link TopologyService} for working with the cluster topology.
+     */
+    TopologyService getTopologyService();

Review comment:
       ```suggestion
       TopologyService topologyService();
   ```




-- 
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.

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