Repository: ignite
Updated Branches:
  refs/heads/ignite-zk 1e775be39 -> ca4058abb


zk


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

Branch: refs/heads/ignite-zk
Commit: ca4058abbd3bd229946ce1a913c34679d50f5b98
Parents: 1e775be
Author: sboikov <sboi...@gridgain.com>
Authored: Fri Dec 8 12:03:24 2017 +0300
Committer: sboikov <sboi...@gridgain.com>
Committed: Fri Dec 8 12:29:54 2017 +0300

----------------------------------------------------------------------
 .../spi/discovery/zk/ZookeeperDiscoverySpi.java | 13 ++----
 .../zk/internal/ZookeeperClusterNode.java       |  9 ++++
 .../zk/internal/ZookeeperDiscoveryImpl.java     | 44 ++++++++------------
 .../ignite/internal/GridDiscoverySelfTest.java  |  2 +
 .../ZookeeperDiscoverySpiBasicTest.java         | 16 +++++++
 5 files changed, 48 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/ca4058ab/modules/core/src/main/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpi.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpi.java
 
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpi.java
index b9c2431..3e73da0 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpi.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/zk/ZookeeperDiscoverySpi.java
@@ -404,16 +404,8 @@ public class ZookeeperDiscoverySpi extends 
IgniteSpiAdapter implements Discovery
 
     /** {@inheritDoc} */
     @Override public void spiStop() throws IgniteSpiException {
-        if (impl != null) {
-            try {
-                impl.stop();
-            }
-            catch (InterruptedException e) {
-                Thread.currentThread().interrupt();
-
-                throw new IgniteSpiException(e);
-            }
-        }
+        if (impl != null)
+            impl.stop();
     }
 
     /** {@inheritDoc} */
@@ -444,6 +436,7 @@ public class ZookeeperDiscoverySpi extends IgniteSpiAdapter 
implements Discovery
             locNodeVer,
             locNodeAttrs,
             consistentId,
+            sesTimeout,
             ignite.configuration().isClientMode(),
             metricsProvider);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ca4058ab/modules/core/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperClusterNode.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperClusterNode.java
 
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperClusterNode.java
index a62ee03..2bb244f 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperClusterNode.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperClusterNode.java
@@ -71,6 +71,9 @@ public class ZookeeperClusterNode implements 
IgniteClusterNode, Serializable, Co
     /** Internal discovery host names as strings. */
     private Collection<String> hostNames;
 
+    /** */
+    private long sesTimeout;
+
     /** Metrics provider. */
     private transient DiscoveryMetricsProvider metricsProvider;
 
@@ -97,10 +100,14 @@ public class ZookeeperClusterNode implements 
IgniteClusterNode, Serializable, Co
 
     /**
      * @param id Node ID.
+     * @param addrs Node addresses.
+     * @param hostNames Node host names.
      * @param ver Node version.
      * @param attrs Node attributes.
      * @param consistentId Consistent ID.
+     * @param sesTimeout Zookeeper session timeout.
      * @param client Client node flag.
+     * @param metricsProvider Metrics provider.
      */
     public ZookeeperClusterNode(
         UUID id,
@@ -109,6 +116,7 @@ public class ZookeeperClusterNode implements 
IgniteClusterNode, Serializable, Co
         IgniteProductVersion ver,
         Map<String, Object> attrs,
         Serializable consistentId,
+        long sesTimeout,
         boolean client,
         DiscoveryMetricsProvider metricsProvider
     ) {
@@ -121,6 +129,7 @@ public class ZookeeperClusterNode implements 
IgniteClusterNode, Serializable, Co
         this.addrs = addrs;
         this.hostNames = hostNames;
         this.consistentId = consistentId;
+        this.sesTimeout = sesTimeout;
         this.metricsProvider = metricsProvider;
 
         if (client)

http://git-wip-us.apache.org/repos/asf/ignite/blob/ca4058ab/modules/core/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryImpl.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryImpl.java
 
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryImpl.java
index caa60ea..105f71b 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryImpl.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoveryImpl.java
@@ -2150,6 +2150,20 @@ public class ZookeeperDiscoveryImpl {
      *
      */
     public void onStop() {
+        // No-op.
+    }
+
+    /**
+     *
+     */
+    public void stop() {
+        stop0(new IgniteSpiException("Node stopped"));
+    }
+
+    /**
+     * @param e Error.
+     */
+    private void stop0(Throwable e) {
         if (!stop.compareAndSet(false, true))
             return;
 
@@ -2161,32 +2175,17 @@ public class ZookeeperDiscoveryImpl {
 
         if (zkClient != null)
             zkClient.onCloseStart();
-    }
-
-    /**
-     * @throws InterruptedException If interrupted.
-     */
-    public void stop() throws InterruptedException {
-        stop0(new IgniteSpiException("Node stopped"));
-    }
 
-    /**
-     * @param e Error.
-     * @throws InterruptedException If interrupted.
-     */
-    private void stop0(Throwable e) throws InterruptedException {
         busyLock.block();
 
         busyLock.unblock();
 
         joinFut.onDone(e);
 
-        IgniteUtils.shutdownNow(ZookeeperDiscoveryImpl.class, utilityPool, 
log);
-
-        ZookeeperClient zkClient = rtState.zkClient;
-
         if (zkClient != null)
             zkClient.close();
+
+        IgniteUtils.shutdownNow(ZookeeperDiscoveryImpl.class, utilityPool, 
log);
     }
 
     /**
@@ -2205,16 +2204,9 @@ public class ZookeeperDiscoveryImpl {
         // TODO ZK
         U.error(log, "Fatal error in ZookeeperDiscovery.", err);
 
-        try {
-            onStop();
-
-            stop0(err);
-        }
-        catch (InterruptedException e) {
-            U.warn(log, "Failed to finish stop procedure, thread was 
interrupted.");
+        onStop();
 
-            Thread.currentThread().interrupt();
-        }
+        stop0(err);
 
         if (err instanceof Error)
             throw (Error)err;

http://git-wip-us.apache.org/repos/asf/ignite/blob/ca4058ab/modules/core/src/test/java/org/apache/ignite/internal/GridDiscoverySelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/GridDiscoverySelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/GridDiscoverySelfTest.java
index 9af2df3..c462df0 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/GridDiscoverySelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/GridDiscoverySelfTest.java
@@ -243,6 +243,8 @@ public class GridDiscoverySelfTest extends 
GridCommonAbstractTest {
             for (int i = 0; i < NODES_CNT; i++)
                 stopGrid(i);
 
+            waitForTopology(1);
+
             final long topVer = discoMgr.topologyVersion();
 
             assert topVer == topVer0 + NODES_CNT * 2 : "Unexpected topology 
version: " + topVer;

http://git-wip-us.apache.org/repos/asf/ignite/blob/ca4058ab/modules/core/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySpiBasicTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySpiBasicTest.java
 
b/modules/core/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySpiBasicTest.java
index e0062c1..455bf06 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySpiBasicTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperDiscoverySpiBasicTest.java
@@ -65,6 +65,7 @@ import org.apache.ignite.lang.IgniteInClosure;
 import org.apache.ignite.lang.IgnitePredicate;
 import org.apache.ignite.logger.java.JavaLogger;
 import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
 import org.apache.ignite.spi.discovery.DiscoverySpi;
 import org.apache.ignite.spi.discovery.zk.ZookeeperDiscoverySpi;
 import org.apache.ignite.testframework.GridTestUtils;
@@ -1534,6 +1535,21 @@ public class ZookeeperDiscoverySpiBasicTest extends 
GridCommonAbstractTest {
     }
 
     /**
+     * @throws Exception If failed.
+     */
+    public void _testCommunicationFailure() throws Exception {
+        Ignite srv0 = startGrid(0);
+
+        Ignite srv1 = startGrid(1);
+
+        info("Close communication");
+
+        
((TcpCommunicationSpi)srv1.configuration().getCommunicationSpi()).simulateNodeFailure();
+
+        Thread.sleep(60_000);
+    }
+
+    /**
      * @param clients Clients.
      * @param c Closure to run.
      * @throws Exception If failed.

Reply via email to