ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [28/28] ignite git commit: zk
Date Mon, 13 Nov 2017 09:52:22 GMT
zk


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/740c3b24
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/740c3b24
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/740c3b24

Branch: refs/heads/ignite-zk
Commit: 740c3b24f5d5d9fec166f9258d7bb0e31b1117fd
Parents: 2b75ecf
Author: sboikov <sboikov@gridgain.com>
Authored: Mon Nov 13 12:41:35 2017 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Mon Nov 13 12:51:45 2017 +0300

----------------------------------------------------------------------
 .../apache/ignite/internal/IgniteKernal.java    |  2 +-
 .../discovery/GridDiscoveryManager.java         |  5 ++-
 .../spi/discovery/zk/ZookeeperDiscoverySpi.java | 47 +++++++++++++++-----
 .../java/org/apache/ZookeeperNodeStart.java     | 46 +++++++++++++++++++
 .../zk/ZookeeperDiscoverySpiBasicTest.java      | 21 +++++++++
 5 files changed, 107 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/740c3b24/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index bde7be2..3e25b50 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -1315,7 +1315,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable
{
         ackStart(rtBean);
 
         if (!isDaemon())
-            ctx.discovery().ackTopology(localNode().order());
+            ctx.discovery().ackTopology(ctx.discovery().localJoin().joinTopologyVersion().topologyVersion());
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/740c3b24/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
index a6737dc..022dc97 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
@@ -2522,8 +2522,9 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi>
{
 
             switch (type) {
                 case EVT_NODE_JOINED: {
-                    assert !discoOrdered || topVer.topologyVersion() == node.order() : "Invalid
topology version [topVer=" + topVer +
-                        ", node=" + node + ']';
+// TODO ZK
+//                    assert !discoOrdered || topVer.topologyVersion() == node.order() :
"Invalid topology version [topVer=" + topVer +
+//                        ", node=" + node + ']';
 
                     try {
                         checkAttributes(F.asList(node));

http://git-wip-us.apache.org/repos/asf/ignite/blob/740c3b24/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpi.java
b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpi.java
index 41debd7..04dc947 100644
--- a/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpi.java
+++ b/modules/zookeeper/src/main/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpi.java
@@ -292,10 +292,18 @@ public class ZookeeperDiscoverySpi extends IgniteSpiAdapter implements
Discovery
     private void initLocalNode() {
         assert ignite != null;
 
-        locNode = new ZookeeperClusterNode(ignite.configuration().getNodeId(),
+        Serializable consistentId = consistentId();
+
+        UUID nodeId = ignite.configuration().getNodeId();
+
+        // TODO ZK
+        if (consistentId == null)
+            consistentId = nodeId;
+
+        locNode = new ZookeeperClusterNode(nodeId,
             locNodeVer,
             locNodeAttrs,
-            consistentId(),
+            consistentId,
             ignite.configuration().isClientMode());
 
         locNode.local(true);
@@ -652,19 +660,35 @@ public class ZookeeperDiscoverySpi extends IgniteSpiAdapter implements
Discovery
         if (oldNodes.ver == newNodes.ver)
             return;
 
-        long nextJoinOrder = oldNodes.nodesByOrder.isEmpty() ? 1 : oldNodes.nodesByOrder.lastKey()
+ 1;
-
         TreeMap<Integer, ZKDiscoveryEvent> evts = new TreeMap<>();
 
-        Set<Long> failed = new HashSet<>();
+        Set<Long> failedNodes = new HashSet<>();
+        Set<Long> joinedNodes = new HashSet<>();
 
         synchronized (curTop) {
             for (int v = oldNodes.ver + 1; v <= newNodes.ver; v++) {
-                ZKNodeData data = joinHist.get(nextJoinOrder);
+                ZKNodeData joined = null;
+
+                for (ZKNodeData newData : newNodes.nodesByOrder.values()) {
+                    if (!curTop.containsKey(newData.order) && !joinedNodes.contains(newData.order))
{
+                        joined = newData;
+
+                        break;
+                    }
+                }
+
+                // TODO ZK: process joinHist
+
+                if (joined != null) {
+                    joinedNodes.add(joined.order);
+
+                    ZKNodeData data = joinHist.get(joined.order);
 
-                if (data != null) {
                     ZKJoiningNodeData joinData = data.joinData;
 
+                    if (joinData == null)
+                        System.out.println();
+
                     assert joinData != null : data;
 
                     curTop.put(joinData.node.order(), joinData.node);
@@ -702,13 +726,11 @@ public class ZookeeperDiscoverySpi extends IgniteSpiAdapter implements
Discovery
                             failedNode,
                             new ArrayList<>(curTop.values())));
                     }
-
-                    nextJoinOrder++;
                 }
                 else {
                     for (ZKNodeData oldData : oldNodes.nodesByOrder.values()) {
-                        if (!failed.contains(oldData.order) && !newNodes.nodesByOrder.containsKey(oldData.order))
{
-                            failed.add(oldData.order);
+                        if (!failedNodes.contains(oldData.order) && !newNodes.nodesByOrder.containsKey(oldData.order))
{
+                            failedNodes.add(oldData.order);
 
                             ZookeeperClusterNode failedNode = curTop.remove(oldData.order);
 
@@ -1026,6 +1048,9 @@ public class ZookeeperDiscoverySpi extends IgniteSpiAdapter implements
Discovery
          * @param joiningNodeData Discovery data.
          */
         ZKJoiningNodeData(ZookeeperClusterNode node, Map<Integer, Serializable> joiningNodeData)
{
+            assert node != null && node.id() != null : node;
+            assert joiningNodeData != null;
+
             this.node = node;
             this.joiningNodeData = joiningNodeData;
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/740c3b24/modules/zookeeper/src/test/java/org/apache/ZookeeperNodeStart.java
----------------------------------------------------------------------
diff --git a/modules/zookeeper/src/test/java/org/apache/ZookeeperNodeStart.java b/modules/zookeeper/src/test/java/org/apache/ZookeeperNodeStart.java
new file mode 100644
index 0000000..89d6604
--- /dev/null
+++ b/modules/zookeeper/src/test/java/org/apache/ZookeeperNodeStart.java
@@ -0,0 +1,46 @@
+/*
+ * 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;
+
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.spi.discovery.zk.ZookeeperDiscoverySpi;
+
+/**
+ *
+ */
+public class ZookeeperNodeStart {
+    public static void main(String[] args) throws Exception {
+        try {
+            IgniteConfiguration cfg = new IgniteConfiguration();
+
+            ZookeeperDiscoverySpi spi = new ZookeeperDiscoverySpi();
+
+            spi.setConnectString("localhost:2181");
+
+            cfg.setDiscoverySpi(spi);
+
+            Ignition.start(cfg);
+        }
+        catch (Throwable e) {
+            e.printStackTrace(System.out);
+
+            System.exit(1);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/740c3b24/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpiBasicTest.java
----------------------------------------------------------------------
diff --git a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpiBasicTest.java
b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpiBasicTest.java
index e8d13a1..6e6c528 100644
--- a/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpiBasicTest.java
+++ b/modules/zookeeper/src/test/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpiBasicTest.java
@@ -107,6 +107,23 @@ public class ZookeeperDiscoverySpiBasicTest extends GridCommonAbstractTest
{
     /**
      * @throws Exception If failed.
      */
+    public void testRestarts_2_Nodes() throws Exception {
+        startGrid(0);
+
+        for (int i = 0; i < 10; i++) {
+            info("Iteration: " + i);
+
+            startGrid(1);
+
+            waitForTopology(2);
+
+            stopGrid(1);
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testStartStop_2_Nodes_WithCache() throws Exception {
         startGrids(2);
 
@@ -170,6 +187,10 @@ public class ZookeeperDiscoverySpiBasicTest extends GridCommonAbstractTest
{
         }, 3, "stop-node-thread");
 
         waitForTopology(7);
+
+        startGridsMultiThreaded(0, 3);
+
+        waitForTopology(10);
     }
 
     /**


Mime
View raw message