ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject ignite git commit: zk
Date Tue, 28 Nov 2017 14:03:27 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-zk 24a9078be -> 287b717ad


zk


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

Branch: refs/heads/ignite-zk
Commit: 287b717ad391bdfa2d6d31fff4caeae6fd4b9f66
Parents: 24a9078
Author: sboikov <sboikov@gridgain.com>
Authored: Tue Nov 28 15:01:51 2017 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Tue Nov 28 17:03:20 2017 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/internal/IgnitionEx.java  |  11 +-
 .../cache/binary/BinaryMetadataTransport.java   |   9 +-
 .../marshaller/MarshallerMappingTransport.java  |   7 -
 .../zk/internal/ZookeeperDiscoveryImpl.java     |   4 +-
 ...RoundRobinErrorAfterClientReconnectTest.java |   8 +-
 .../zk/internal/ZookeeperClientTest.java        |  21 +++
 .../ZookeeperDiscoverySpiBasicTest.java         |  93 +++++++++---
 .../testframework/junits/GridAbstractTest.java  |  39 ++++-
 .../zookeeper/ZkTestClientCnxnSocketNIO.java    |   9 +-
 .../org/apache/zookeeper/ZKDisconnectTest1.java | 134 -----------------
 .../org/apache/zookeeper/ZKDisconnectTest2.java | 142 -------------------
 .../java/org/apache/zookeeper/ZKSimpleTest.java |  59 --------
 12 files changed, 158 insertions(+), 378 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/287b717a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
index d78b51c..93a82a5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
@@ -156,13 +156,16 @@ import static org.apache.ignite.plugin.segmentation.SegmentationPolicy.RESTART_J
  */
 public class IgnitionEx {
     /** */
-    public static volatile boolean TEST_ZK = false;
+    // TODO ZK
+    public static volatile boolean TEST_ZK = IgniteSystemProperties.getBoolean("TEST_ZK",
false);
 
     /** */
     public static TestingCluster zkCluster;
 
-    static {
-        if (TEST_ZK) {
+    synchronized static void startZk() {
+        if (TEST_ZK && zkCluster == null) {
+            System.out.println("Start ZK cluster for tests");
+
             zkCluster = createTestingCluster(1);
 
             try {
@@ -2280,6 +2283,8 @@ public class IgnitionEx {
             initializeDataStorageConfiguration(myCfg);
 
             if (TEST_ZK) {
+                startZk();
+
                 ZookeeperDiscoverySpi zkSpi = new ZookeeperDiscoverySpi();
 
                 zkSpi.setZkConnectionString(zkCluster.getConnectString());

http://git-wip-us.apache.org/repos/asf/ignite/blob/287b717a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataTransport.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataTransport.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataTransport.java
index 3a77190..f80b373 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataTransport.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/BinaryMetadataTransport.java
@@ -69,9 +69,6 @@ final class BinaryMetadataTransport {
     private final IgniteLogger log;
 
     /** */
-    private final UUID locNodeId;
-
-    /** */
     private final boolean clientNode;
 
     /** */
@@ -117,8 +114,6 @@ final class BinaryMetadataTransport {
 
         discoMgr = ctx.discovery();
 
-        locNodeId = ctx.localNodeId();
-
         clientNode = ctx.clientNode();
 
         discoMgr.setCustomEventListener(MetadataUpdateProposedMessage.class, new MetadataUpdateProposedListener());
@@ -170,7 +165,7 @@ final class BinaryMetadataTransport {
             unlabeledFutures.add(resFut);
 
             if (!stopping)
-                discoMgr.sendCustomEvent(new MetadataUpdateProposedMessage(metadata, locNodeId));
+                discoMgr.sendCustomEvent(new MetadataUpdateProposedMessage(metadata, ctx.localNodeId()));
             else
                 resFut.onDone(MetadataUpdateResult.createUpdateDisabledResult());
         }
@@ -299,7 +294,7 @@ final class BinaryMetadataTransport {
                 acceptedVer = msg.acceptedVersion();
             }
 
-            if (locNodeId.equals(msg.origNodeId())) {
+            if (ctx.localNodeId().equals(msg.origNodeId())) {
                 MetadataUpdateResultFuture fut = unlabeledFutures.poll();
 
                 if (msg.rejected())

http://git-wip-us.apache.org/repos/asf/ignite/blob/287b717a/modules/core/src/main/java/org/apache/ignite/internal/processors/marshaller/MarshallerMappingTransport.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/marshaller/MarshallerMappingTransport.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/marshaller/MarshallerMappingTransport.java
index e77d4f5..b80ae36 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/marshaller/MarshallerMappingTransport.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/marshaller/MarshallerMappingTransport.java
@@ -99,13 +99,6 @@ public final class MarshallerMappingTransport {
     public GridFutureAdapter<MappingExchangeResult> proposeMapping(MarshallerMappingItem
item, ConcurrentMap<Integer, MappedName> cache) throws IgniteCheckedException {
         GridFutureAdapter<MappingExchangeResult> fut = new MappingExchangeResultFuture(item);
 
-        // TODO ZK
-        if (true) {
-            fut.onDone(MappingExchangeResult.createExchangeDisabledResult());
-
-            return fut;
-        }
-
         GridFutureAdapter<MappingExchangeResult> oldFut = mappingExchSyncMap.putIfAbsent(item,
fut);
 
         if (oldFut != null)

http://git-wip-us.apache.org/repos/asf/ignite/blob/287b717a/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 9122685..60396b0 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
@@ -467,13 +467,13 @@ public class ZookeeperDiscoveryImpl {
             state.zkClient.getChildrenAsync(zkPaths.aliveNodesDir, null, new CheckCoordinatorCallback());
 
             state.zkClient.getDataAsync(zkPaths.evtsPath, watcher, dataCallback);
-
-            connStartLatch.countDown();
         }
         catch (ZookeeperClientFailedException e) {
             throw new IgniteSpiException("Failed to initialize Zookeeper nodes", e);
         }
         finally {
+            connStartLatch.countDown();
+
             busyLock.leaveBusy();
         }
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/287b717a/modules/core/src/test/java/org/apache/ignite/internal/IgniteRoundRobinErrorAfterClientReconnectTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/IgniteRoundRobinErrorAfterClientReconnectTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/IgniteRoundRobinErrorAfterClientReconnectTest.java
index 00a33a6..deea2ea 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/IgniteRoundRobinErrorAfterClientReconnectTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/IgniteRoundRobinErrorAfterClientReconnectTest.java
@@ -91,8 +91,12 @@ public class IgniteRoundRobinErrorAfterClientReconnectTest extends GridCommonAbs
             }
         }, EventType.EVT_CLIENT_NODE_RECONNECTED);
 
-        stopGrid(SRV_IDX);
-        startGrid(SRV_IDX);
+        if (tcpDiscovery()) {
+            stopGrid(SRV_IDX);
+            startGrid(SRV_IDX);
+        }
+        else
+            reconnectClient(log, cli);
 
         assert fut.get();
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/287b717a/modules/core/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperClientTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperClientTest.java
b/modules/core/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperClientTest.java
index 81edcde..6330595 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperClientTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/zk/internal/ZookeeperClientTest.java
@@ -53,6 +53,27 @@ public class ZookeeperClientTest extends GridCommonAbstractTest {
     /**
      * @throws Exception If failed.
      */
+    public void testClose() throws Exception {
+        startZK(1);
+
+        final ZookeeperClient client = new ZookeeperClient(log, zkCluster.getConnectString(),
3000, null);
+
+        client.createIfNeeded("/apacheIgnite1", null, CreateMode.PERSISTENT);
+
+        client.zk().close();
+
+        GridTestUtils.assertThrows(log, new Callable<Void>() {
+            @Override public Void call() throws Exception {
+                client.createIfNeeded("/apacheIgnite2", null, CreateMode.PERSISTENT);
+
+                return null;
+            }
+        }, ZookeeperClientFailedException.class, null);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testCreateAll() throws Exception {
         startZK(1);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/287b717a/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 ab2dc32..bbf2945 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
@@ -222,7 +222,7 @@ public class ZookeeperDiscoverySpiBasicTest extends GridCommonAbstractTest
{
             }
 
 
-            specs.add(new InstanceSpec(file, -1, -1, -1, true, -1, -1, -1));
+            specs.add(new InstanceSpec(file, -1, -1, -1, true, -1, 1000, -1));
         }
 
         return new TestingCluster(specs);
@@ -628,7 +628,7 @@ public class ZookeeperDiscoverySpiBasicTest extends GridCommonAbstractTest
{
             }
         }
 
-        waitNoAliveZkNodes(failedZkNodes);
+        waitNoAliveZkNodes(log, zkCluster.getConnectString(), failedZkNodes, 10_000);
 
         c0.allowConnect();
 
@@ -655,8 +655,12 @@ public class ZookeeperDiscoverySpiBasicTest extends GridCommonAbstractTest
{
         return path.substring(path.lastIndexOf('/') + 1);
     }
 
-    private static void waitNoAliveZkNodes(final List<String> failedZkNodes) throws
Exception {
-        final ZookeeperClient zkClient = new ZookeeperClient(new JavaLogger(), zkCluster.getConnectString(),
10_000, null);
+    private static void waitNoAliveZkNodes(final IgniteLogger log,
+        String connectString, final List<String> failedZkNodes,
+        long timeout)
+        throws Exception
+    {
+        final ZookeeperClient zkClient = new ZookeeperClient(log, connectString, 10_000,
null);
 
         try {
             assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicate() {
@@ -665,8 +669,11 @@ public class ZookeeperDiscoverySpiBasicTest extends GridCommonAbstractTest
{
                         List<String> c = zkClient.getChildren(IGNITE_ZK_ROOT + "/alive");
 
                         for (String failedZkNode : failedZkNodes) {
-                            if (c.contains(failedZkNode))
+                            if (c.contains(failedZkNode)) {
+                                log.info("Alive node is not removed [node=" + failedZkNode
+ ", all=" + c + ']');
+
                                 return false;
+                            }
                         }
 
                         return true;
@@ -677,7 +684,7 @@ public class ZookeeperDiscoverySpiBasicTest extends GridCommonAbstractTest
{
                         return true;
                     }
                 }
-            }, 10_000));
+            }, timeout));
         }
         finally {
             zkClient.close();
@@ -1104,16 +1111,39 @@ public class ZookeeperDiscoverySpiBasicTest extends GridCommonAbstractTest
{
         startGrid(0);
 
         sesTimeout = 2000;
-        testSockNio = true;
         client = true;
+        testSockNio = true;
 
         Ignite client = startGrid(1);
 
         client.cache(DEFAULT_CACHE_NAME).put(1, 1);
 
-        reconnectClientNodes(log, Collections.singletonList(client), null);
+        reconnectClientNodes(log, Collections.singletonList(client), null, true);
 
         assertEquals(1, client.cache(DEFAULT_CACHE_NAME).get(1));
+
+        client.compute().broadcast(new DummyCallable(null));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testClientReconnectSessionExpire2() throws Exception {
+        sesTimeout = 2000;
+        client = true;
+        testSockNio = true;
+
+        Ignite client0 = startGrid(0);
+
+        reconnectClientNodes(log, Collections.singletonList(client0), null, true);
+
+        client = false;
+
+        client0.configuration().getMarshaller().marshal(new DummyCallable(null));
+
+        startGrid(1);
+
+        client0.compute().broadcast(new DummyCallable(null));
     }
 
     /**
@@ -1444,11 +1474,19 @@ public class ZookeeperDiscoverySpiBasicTest extends GridCommonAbstractTest
{
         }, 10000));
     }
 
+    private static void closeZkClient(Ignite node) {
+        DiscoverySpi spi = node.configuration().getDiscoverySpi();
+
+        assertTrue(spi.getClass().getName(), spi instanceof ZookeeperDiscoverySpi);
+
+        closeZkClient((ZookeeperDiscoverySpi)spi);
+    }
+
     /**
      * @param spi Spi instance.
      */
-    private void closeZkClient(ZookeeperDiscoverySpi spi) {
-        ZooKeeper zk = GridTestUtils.getFieldValue(spi, "impl", "zkClient", "zk");
+    private static void closeZkClient(ZookeeperDiscoverySpi spi) {
+        ZooKeeper zk = GridTestUtils.getFieldValue(spi, "impl", "state", "zkClient", "zk");
 
         try {
             zk.close();
@@ -1485,7 +1523,7 @@ public class ZookeeperDiscoverySpiBasicTest extends GridCommonAbstractTest
{
 
                 return true;
             }
-        }, 5000));
+        }, 15_000));
     }
     /**
      * Reconnect client node.
@@ -1495,9 +1533,10 @@ public class ZookeeperDiscoverySpiBasicTest extends GridCommonAbstractTest
{
      * @param disconnectedC Closure which will be run when client node disconnected.
      * @throws Exception If failed.
      */
-    static void reconnectClientNodes(final IgniteLogger log,
+    public static void reconnectClientNodes(final IgniteLogger log,
         List<Ignite> clients,
-        @Nullable Runnable disconnectedC)
+        @Nullable Runnable disconnectedC,
+        boolean closeSock)
         throws Exception {
         final CountDownLatch disconnectLatch = new CountDownLatch(clients.size());
         final CountDownLatch reconnectLatch = new CountDownLatch(clients.size());
@@ -1527,13 +1566,31 @@ public class ZookeeperDiscoverySpiBasicTest extends GridCommonAbstractTest
{
             zkNodes.add(aliveZkNodePath(client));
         }
 
-        for (Ignite client : clients)
-            ZkTestClientCnxnSocketNIO.forNode(client.name()).closeSocket(true);
+        long timeout = 10_000;
 
-        waitNoAliveZkNodes(zkNodes);
+        if (closeSock) {
+            for (Ignite client : clients) {
+                ZookeeperDiscoverySpi spi = (ZookeeperDiscoverySpi)client.configuration().getDiscoverySpi();
 
-        for (Ignite client : clients)
-            ZkTestClientCnxnSocketNIO.forNode(client.name()).allowConnect();
+                ZkTestClientCnxnSocketNIO.forNode(client.name()).closeSocket(true);
+
+                timeout = Math.max(timeout, (long)(spi.getSessionTimeout() * 1.5f));
+            }
+        }
+        else {
+            for (Ignite client : clients)
+                closeZkClient(client);
+        }
+
+        waitNoAliveZkNodes(log,
+            ((ZookeeperDiscoverySpi)clients.get(0).configuration().getDiscoverySpi()).getZkConnectionString(),
+            zkNodes,
+            timeout);
+
+        if (closeSock) {
+            for (Ignite client : clients)
+                ZkTestClientCnxnSocketNIO.forNode(client.name()).allowConnect();
+        }
 
         waitReconnectEvent(log, disconnectLatch);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/287b717a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
index 437ce4d..a858429 100755
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
@@ -43,7 +43,6 @@ import java.util.concurrent.atomic.AtomicReference;
 import javax.cache.configuration.Factory;
 import javax.cache.configuration.FactoryBuilder;
 import junit.framework.TestCase;
-import org.apache.curator.test.TestingCluster;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteCheckedException;
@@ -97,7 +96,7 @@ import org.apache.ignite.spi.discovery.tcp.TestTcpDiscoverySpi;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.spi.discovery.zk.ZookeeperDiscoverySpi;
+import org.apache.ignite.spi.discovery.zk.internal.ZookeeperDiscoverySpiBasicTest;
 import org.apache.ignite.spi.eventstorage.memory.MemoryEventStorageSpi;
 import org.apache.ignite.testframework.GridTestUtils;
 import org.apache.ignite.testframework.config.GridTestProperties;
@@ -112,6 +111,7 @@ import org.apache.log4j.Logger;
 import org.apache.log4j.PatternLayout;
 import org.apache.log4j.Priority;
 import org.apache.log4j.RollingFileAppender;
+import org.apache.zookeeper.ZkTestClientCnxnSocketNIO;
 import org.jetbrains.annotations.Nullable;
 import org.springframework.beans.BeansException;
 import org.springframework.context.ApplicationContext;
@@ -122,6 +122,7 @@ import static org.apache.ignite.IgniteSystemProperties.IGNITE_DISCO_FAILED_CLIEN
 import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL;
 import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
 import static org.apache.ignite.testframework.config.GridTestProperties.BINARY_MARSHALLER_USE_SIMPLE_NAME_MAPPER;
+import static org.apache.zookeeper.ZooKeeper.ZOOKEEPER_CLIENT_CNXN_SOCKET;
 
 /**
  * Common abstract test for Ignite tests.
@@ -193,6 +194,10 @@ public abstract class GridAbstractTest extends TestCase {
      *
      */
     static {
+        // TODO ZK
+        System.setProperty("TEST_ZK", "true");
+        System.setProperty(ZOOKEEPER_CLIENT_CNXN_SOCKET, ZkTestClientCnxnSocketNIO.class.getName());
+
         System.setProperty(IgniteSystemProperties.IGNITE_ATOMIC_CACHE_DELETE_HISTORY_SIZE,
"10000");
         System.setProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER, "false");
         System.setProperty(IGNITE_DISCO_FAILED_CLIENT_RECONNECT_DELAY, "1");
@@ -2166,6 +2171,36 @@ public abstract class GridAbstractTest extends TestCase {
     }
 
     /**
+     * @return {@code True} if nodes use {@link TcpDiscoverySpi}.
+     */
+    protected static boolean tcpDiscovery() {
+        List<Ignite> nodes = G.allGrids();
+
+        assertFalse("There are no nodes", nodes.isEmpty());
+
+        return nodes.get(0).configuration().getDiscoverySpi() instanceof TcpDiscoverySpi;
+    }
+
+    /** */
+    private static final String ZK_DISCOVERY = "org.apache.ignite.spi.discovery.zk.ZookeeperDiscoverySpi";
+
+    /**
+     * @param log Log.
+     * @param client Node to reconnect.
+     * @throws Exception If failed.
+     */
+    protected static void reconnectClient(IgniteLogger log, Ignite client) throws Exception
{
+        List<Ignite> nodes = G.allGrids();
+
+        assertFalse("There are no nodes", nodes.isEmpty());
+
+        if (nodes.get(0).configuration().getDiscoverySpi().getClass().getName().equals(ZK_DISCOVERY))
+            ZookeeperDiscoverySpiBasicTest.reconnectClientNodes(log, Collections.singletonList(client),
null, true);
+        else
+            fail("Reconnect is not supported");
+    }
+
+    /**
      *
      */
     private static interface WriteReplaceOwner {

http://git-wip-us.apache.org/repos/asf/ignite/blob/287b717a/modules/core/src/test/java/org/apache/zookeeper/ZkTestClientCnxnSocketNIO.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/zookeeper/ZkTestClientCnxnSocketNIO.java
b/modules/core/src/test/java/org/apache/zookeeper/ZkTestClientCnxnSocketNIO.java
index c8886af..fac405a 100644
--- a/modules/core/src/test/java/org/apache/zookeeper/ZkTestClientCnxnSocketNIO.java
+++ b/modules/core/src/test/java/org/apache/zookeeper/ZkTestClientCnxnSocketNIO.java
@@ -35,6 +35,9 @@ public class ZkTestClientCnxnSocketNIO extends ClientCnxnSocketNIO {
     public static final IgniteLogger log = new JavaLogger().getLogger(ZkTestClientCnxnSocketNIO.class);
 
     /** */
+    public static volatile boolean DEBUG = false;
+
+    /** */
     public volatile CountDownLatch blockConnectLatch;
 
     /** */
@@ -76,14 +79,16 @@ public class ZkTestClientCnxnSocketNIO extends ClientCnxnSocketNIO {
 
         nodeName = threadName.substring(threadName.indexOf('-') + 1);
 
-        log.info("ZkTestClientCnxnSocketNIO created for node: " + nodeName);
+        if (DEBUG)
+            log.info("ZkTestClientCnxnSocketNIO created for node: " + nodeName);
     }
 
     /** {@inheritDoc} */
     @Override void connect(InetSocketAddress addr) throws IOException {
         CountDownLatch blockConnect = this.blockConnectLatch;
 
-        log.info("ZkTestClientCnxnSocketNIO connect [node=" + nodeName + ", addr=" + addr
+ ']');
+        if (DEBUG)
+            log.info("ZkTestClientCnxnSocketNIO connect [node=" + nodeName + ", addr=" +
addr + ']');
 
         if (blockConnect != null && blockConnect.getCount() > 0) {
             try {

http://git-wip-us.apache.org/repos/asf/ignite/blob/287b717a/modules/zookeeper/src/test/java/org/apache/zookeeper/ZKDisconnectTest1.java
----------------------------------------------------------------------
diff --git a/modules/zookeeper/src/test/java/org/apache/zookeeper/ZKDisconnectTest1.java b/modules/zookeeper/src/test/java/org/apache/zookeeper/ZKDisconnectTest1.java
deleted file mode 100644
index c0d2c8f..0000000
--- a/modules/zookeeper/src/test/java/org/apache/zookeeper/ZKDisconnectTest1.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * 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.zookeeper;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.nio.channels.SelectionKey;
-import java.util.concurrent.CountDownLatch;
-import org.apache.curator.test.TestingCluster;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.zk.ZKClusterNodeNew;
-import org.apache.ignite.testframework.GridTestUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.apache.zookeeper.ZooKeeper.ZOOKEEPER_CLIENT_CNXN_SOCKET;
-
-/**
- *
- */
-public class ZKDisconnectTest1 {
-    /** */
-    private static final Logger LOG = LoggerFactory.getLogger(ZKDisconnectTest1.class);
-
-    public static class TestClientCnxnSocketNIO extends ClientCnxnSocketNIO {
-        private static TestClientCnxnSocketNIO instance;
-
-        volatile CountDownLatch blockConnect;
-
-        public TestClientCnxnSocketNIO() throws IOException {
-            super();
-
-            if (instance == null)
-                instance = this;
-        }
-
-        @Override
-        void connect(InetSocketAddress addr) throws IOException {
-            System.out.println("TestClientCnxnSocketNIO connect: " + addr);
-
-            CountDownLatch blockConnect = this.blockConnect;
-
-            if (blockConnect != null) {
-                try {
-                    LOG.info("TestClientCnxnSocketNIO block connected");
-
-                    blockConnect.await();
-
-                    LOG.info("TestClientCnxnSocketNIO finish block");
-                }
-                catch (Exception e) {
-                    e.printStackTrace();
-                }
-
-                this.blockConnect = null;
-            }
-
-            super.connect(addr);
-        }
-
-        void testClose() {
-            try {
-                SelectionKey k = GridTestUtils.getFieldValue(this, ClientCnxnSocketNIO.class,
"sockKey");
-
-                k.channel().close();
-            }
-            catch (Throwable e) {
-                e.printStackTrace();
-            }
-        }
-    }
-
-    public static void main(String[] args) {
-        try {
-            TestingCluster zkCluster = new TestingCluster(1);
-            zkCluster.start();
-
-            Thread.sleep(1000);
-
-            LOG.info("ZK started\n");
-
-            System.setProperty(ZOOKEEPER_CLIENT_CNXN_SOCKET, TestClientCnxnSocketNIO.class.getName());
-
-            ZKClusterNodeNew node1 = new ZKClusterNodeNew("n1");
-            node1.join(zkCluster.getConnectString());
-
-            ZKClusterNodeNew node2 = new ZKClusterNodeNew("n2");
-            node2.join(zkCluster.getConnectString());
-
-            LOG.info("Clients connected");
-
-            Thread.sleep(3000);
-
-            LOG.info("Close channel");
-
-            TestClientCnxnSocketNIO.instance.blockConnect = new CountDownLatch(1);
-            TestClientCnxnSocketNIO.instance.testClose();
-
-            LOG.info("Closed");
-
-            ZKClusterNodeNew node3 = new ZKClusterNodeNew("n3");
-            node3.join(zkCluster.getConnectString());
-
-            LOG.info("Node started");
-
-            node3.stop();
-
-            LOG.info("Node stopped");
-
-            TestClientCnxnSocketNIO.instance.blockConnect.countDown();
-
-            Thread.sleep(60_000);
-        }
-        catch (Throwable e) {
-            e.printStackTrace(System.out);
-
-            System.exit(1);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/287b717a/modules/zookeeper/src/test/java/org/apache/zookeeper/ZKDisconnectTest2.java
----------------------------------------------------------------------
diff --git a/modules/zookeeper/src/test/java/org/apache/zookeeper/ZKDisconnectTest2.java b/modules/zookeeper/src/test/java/org/apache/zookeeper/ZKDisconnectTest2.java
deleted file mode 100644
index 3b36e82..0000000
--- a/modules/zookeeper/src/test/java/org/apache/zookeeper/ZKDisconnectTest2.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * 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.zookeeper;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.nio.channels.SelectionKey;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CountDownLatch;
-import org.apache.curator.test.TestingCluster;
-import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.zk.ZKClusterNodeNew;
-import org.apache.ignite.testframework.GridTestUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.apache.zookeeper.ZooKeeper.ZOOKEEPER_CLIENT_CNXN_SOCKET;
-
-/**
- *
- */
-public class ZKDisconnectTest2 {
-    /** */
-    private static final Logger LOG = LoggerFactory.getLogger(ZKDisconnectTest2.class);
-
-    public static class TestClientCnxnSocketNIO extends ClientCnxnSocketNIO {
-        private static TestClientCnxnSocketNIO instance;
-
-        volatile CountDownLatch blockConnect;
-
-        public TestClientCnxnSocketNIO() throws IOException {
-            super();
-
-            if (instance == null)
-                instance = this;
-        }
-
-        @Override
-        void connect(InetSocketAddress addr) throws IOException {
-            System.out.println("TestClientCnxnSocketNIO connect: " + addr);
-
-            CountDownLatch blockConnect = this.blockConnect;
-
-            if (blockConnect != null) {
-                try {
-                    LOG.info("TestClientCnxnSocketNIO block connected");
-
-                    blockConnect.await();
-
-                    LOG.info("TestClientCnxnSocketNIO finish block");
-                }
-                catch (Exception e) {
-                    e.printStackTrace();
-                }
-
-                this.blockConnect = null;
-            }
-
-            super.connect(addr);
-        }
-
-        void testClose() {
-            try {
-                SelectionKey k = GridTestUtils.getFieldValue(this, ClientCnxnSocketNIO.class,
"sockKey");
-
-                k.channel().close();
-            }
-            catch (Throwable e) {
-                e.printStackTrace();
-            }
-        }
-    }
-
-    public static void main(String[] args) {
-        try {
-            final TestingCluster zkCluster = new TestingCluster(1);
-            zkCluster.start();
-
-            Thread.sleep(1000);
-
-            LOG.info("ZK started\n");
-
-            System.setProperty(ZOOKEEPER_CLIENT_CNXN_SOCKET, TestClientCnxnSocketNIO.class.getName());
-
-            ZKClusterNodeNew node1 = new ZKClusterNodeNew("n1");
-            node1.join(zkCluster.getConnectString());
-
-            ZKClusterNodeNew node2 = new ZKClusterNodeNew("n2");
-            node2.join(zkCluster.getConnectString());
-
-            LOG.info("Clients connected");
-
-            Thread.sleep(3000);
-
-            LOG.info("Close channel");
-
-            TestClientCnxnSocketNIO.instance.blockConnect = new CountDownLatch(1);
-            TestClientCnxnSocketNIO.instance.testClose();
-
-            IgniteInternalFuture fut = GridTestUtils.runAsync(new Callable<Void>()
{
-                @Override public Void call() throws Exception {
-                    ZKClusterNodeNew node3 = new ZKClusterNodeNew("n3");
-                    node3.join(zkCluster.getConnectString(), 2000);
-
-                    return null;
-                }
-            }, "start");
-
-            Thread.sleep(3000);
-
-            LOG.info("Stop block");
-
-            TestClientCnxnSocketNIO.instance.blockConnect.countDown();
-
-            fut.get();
-
-            LOG.info("Done");
-
-            Thread.sleep(60_000);
-        }
-        catch (Throwable e) {
-            e.printStackTrace(System.out);
-
-            System.exit(1);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/287b717a/modules/zookeeper/src/test/java/org/apache/zookeeper/ZKSimpleTest.java
----------------------------------------------------------------------
diff --git a/modules/zookeeper/src/test/java/org/apache/zookeeper/ZKSimpleTest.java b/modules/zookeeper/src/test/java/org/apache/zookeeper/ZKSimpleTest.java
deleted file mode 100644
index c48e6d1..0000000
--- a/modules/zookeeper/src/test/java/org/apache/zookeeper/ZKSimpleTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.zookeeper;
-
-import org.apache.curator.test.TestingCluster;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.zk.ZKClusterNodeNew;
-
-/**
- *
- */
-public class ZKSimpleTest {
-    public static void main(String[] args) throws Exception {
-        TestingCluster zkCluster = new TestingCluster(1);
-        zkCluster.start();
-
-        System.out.println("ZK started\n");
-
-        ZKClusterNodeNew node1 = new ZKClusterNodeNew("n1");
-        node1.join(zkCluster.getConnectString());
-
-        ZKClusterNodeNew node2 = new ZKClusterNodeNew("n2");
-        node2.join(zkCluster.getConnectString());
-
-        ZKClusterNodeNew node3 = new ZKClusterNodeNew("n3");
-        node3.join(zkCluster.getConnectString());
-
-//        ZKClusterNodeNew node4 = new ZKClusterNodeNew("n4");
-//        node4.join(zkCluster.getConnectString());
-
-        System.out.println("Stop n2");
-
-        node2.stop();
-
-        //Thread.sleep(5000);
-
-        System.out.println("Stop n3");
-
-        node3.stop();
-
-        System.out.println("Done");
-
-        Thread.sleep(60_000);
-    }
-}


Mime
View raw message