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 2020/04/27 09:50:40 UTC

[GitHub] [ignite] ptupitsyn opened a new pull request #7744: IGNITE-12932 Thin Client Discovery

ptupitsyn opened a new pull request #7744:
URL: https://github.com/apache/ignite/pull/7744


   This is a PoC for https://cwiki.apache.org/confluence/display/IGNITE/IEP-44%3A+Thin+client+cluster+discovery
   
   Work in progress. Everything is a subject to change.


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



[GitHub] [ignite] ashapkin commented on a change in pull request #7744: IGNITE-12932 .NET: Add Thin Client Discovery

Posted by GitBox <gi...@apache.org>.
ashapkin commented on a change in pull request #7744:
URL: https://github.com/apache/ignite/pull/7744#discussion_r421861066



##########
File path: modules/core/src/main/java/org/apache/ignite/internal/processors/platform/client/cluster/ClientClusterGroupGetNodesEndpointsResponse.java
##########
@@ -0,0 +1,170 @@
+/*
+ * 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.internal.processors.platform.client.cluster;
+
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.binary.BinaryRawWriterEx;
+import org.apache.ignite.internal.cluster.IgniteClusterEx;
+import org.apache.ignite.internal.processors.odbc.ClientListenerProcessor;
+import org.apache.ignite.internal.processors.platform.client.ClientConnectionContext;
+import org.apache.ignite.internal.processors.platform.client.ClientResponse;
+
+import java.util.*;
+
+/**
+ * Cluster group get nodes endpoints response.
+ */
+public class ClientClusterGroupGetNodesEndpointsResponse extends ClientResponse {
+    /** Indicates unknown topology version. */
+    private static final long UNKNOWN_TOP_VER = -1;
+
+    /** Start topology version. -1 for earliest. */
+    private final long startTopVer;
+
+    /** End topology version. -1 for latest. */
+    private final long endTopVer;
+
+    /**
+     * Constructor.
+     *
+     * @param reqId Request identifier.
+     * @param startTopVer Start topology version.
+     * @param endTopVer End topology version.
+     */
+    public ClientClusterGroupGetNodesEndpointsResponse(long reqId,
+                                                       long startTopVer,
+                                                       long endTopVer) {
+        super(reqId);
+
+        this.startTopVer = startTopVer;
+        this.endTopVer = endTopVer;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void encode(ClientConnectionContext ctx, BinaryRawWriterEx writer) {
+        super.encode(ctx, writer);
+
+        IgniteClusterEx cluster = ctx.kernalContext().grid().cluster();
+
+        long endTopVer0 = endTopVer == UNKNOWN_TOP_VER ? cluster.topologyVersion() : endTopVer;
+
+        Collection<ClusterNode> topology = cluster.topology(endTopVer0);
+
+        writer.writeLong(endTopVer0);
+
+        if (startTopVer == UNKNOWN_TOP_VER) {
+            int pos = writer.reserveInt();
+            int size = 0;
+
+            for (ClusterNode node : topology) {
+                if (writeNode(writer, node))
+                    size++;
+            }
+
+            writer.writeInt(pos, size);
+            writer.writeInt(0);
+
+            return;
+        }
+
+        Map<UUID, ClusterNode> startNodes = toMap(cluster.topology(startTopVer));
+        Map<UUID, ClusterNode> endNodes = toMap(topology);
+
+        int pos = writer.reserveInt();
+        int cnt = 0;
+
+        for (Map.Entry<UUID, ClusterNode> endNode : endNodes.entrySet()) {
+            if (!startNodes.containsKey(endNode.getKey())) {
+                if (writeNode(writer, endNode.getValue()))
+                    cnt++;
+            }
+        }
+
+        writer.writeInt(pos, cnt);
+
+        pos = writer.reserveInt();
+        cnt = 0;
+
+        for (Map.Entry<UUID, ClusterNode> startNode : startNodes.entrySet()) {
+            if (!endNodes.containsKey(startNode.getKey()) && !startNode.getValue().isClient()) {
+                writeUuid(writer, startNode.getKey());
+                cnt++;
+            }
+        }
+
+        writer.writeInt(pos, cnt);
+    }
+
+    /**
+     * Writes node info.
+     *
+     * @param writer Writer.
+     * @param node Node.
+     */
+    private boolean writeNode(BinaryRawWriterEx writer, ClusterNode node) {

Review comment:
       make these methods static?




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