You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/09/18 09:45:04 UTC

ignite git commit: ignite-1171

Repository: ignite
Updated Branches:
  refs/heads/ignite-1171 1d028ebde -> baa1a6bee


ignite-1171


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

Branch: refs/heads/ignite-1171
Commit: baa1a6beee50c1e8c17d5b7ff0a04b7b49d93348
Parents: 1d028eb
Author: sboikov <sb...@gridgain.com>
Authored: Fri Sep 18 10:44:46 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Sep 18 10:44:46 2015 +0300

----------------------------------------------------------------------
 .../ignite/spi/discovery/tcp/ServerImpl.java    |  13 +-
 .../distributed/CacheAffEarlySelfTest.java      | 248 -------------------
 .../distributed/CacheAffinityEarlyTest.java     | 168 +++++++++++++
 .../distributed/GridCacheAffEarlySelfTest.java  | 175 -------------
 .../tcp/TcpDiscoveryMultiThreadedTest.java      |  47 ++--
 .../testsuites/IgniteCacheTestSuite4.java       |   2 +
 6 files changed, 205 insertions(+), 448 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/baa1a6be/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index c762d10..a8e2db7 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -41,6 +41,7 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Queue;
+import java.util.Set;
 import java.util.SortedMap;
 import java.util.TreeMap;
 import java.util.UUID;
@@ -1944,8 +1945,8 @@ class ServerImpl extends TcpDiscoveryImpl {
         /** Pending custom messages that should not be sent between NodeAdded and NodeAddFinished messages. */
         private Queue<TcpDiscoveryCustomEventMessage> pendingCustomMsgs = new LinkedList<>();
 
-        /** Counter to track when a new node starts join process. */
-        private int joiningNodeCnt;
+        /** Collection to track when a new node starts join process. */
+        private Set<UUID> joiningNodes = new HashSet<>();
 
         /**
          */
@@ -3113,7 +3114,7 @@ class ServerImpl extends TcpDiscoveryImpl {
                     return;
                 }
 
-                joiningNodeCnt++;
+                joiningNodes.add(node.id());
 
                 if (!isLocalNodeCoordinator() && spi.nodeAuth != null && spi.nodeAuth.isGlobalNodeAuthentication()) {
                     boolean authFailed = true;
@@ -3340,7 +3341,7 @@ class ServerImpl extends TcpDiscoveryImpl {
             }
 
             if (msg.verified() && !locNodeId.equals(nodeId) && spiStateCopy() == CONNECTED && fireEvt) {
-                joiningNodeCnt--;
+                joiningNodes.remove(nodeId);
 
                 spi.stats.onNodeJoined();
 
@@ -4099,7 +4100,7 @@ class ServerImpl extends TcpDiscoveryImpl {
          */
         private void processCustomMessage(TcpDiscoveryCustomEventMessage msg) {
             if (isLocalNodeCoordinator()) {
-                if (joiningNodeCnt != 0) {
+                if (!joiningNodes.isEmpty()) {
                     pendingCustomMsgs.add(msg);
 
                     return;
@@ -4162,7 +4163,7 @@ class ServerImpl extends TcpDiscoveryImpl {
          * Checks and flushes custom event messages if no nodes are attempting to join the grid.
          */
         private void checkPendingCustomMessages() {
-            if (joiningNodeCnt == 0 && isLocalNodeCoordinator()) {
+            if (joiningNodes.isEmpty() && isLocalNodeCoordinator()) {
                 TcpDiscoveryCustomEventMessage msg;
 
                 while ((msg = pendingCustomMsgs.poll()) != null)

http://git-wip-us.apache.org/repos/asf/ignite/blob/baa1a6be/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAffEarlySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAffEarlySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAffEarlySelfTest.java
deleted file mode 100644
index 453b6f6..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAffEarlySelfTest.java
+++ /dev/null
@@ -1,248 +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.ignite.internal.processors.cache.distributed;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Random;
-import java.util.UUID;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.cache.CacheAtomicityMode;
-import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException;
-import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.IgniteKernal;
-import org.apache.ignite.internal.util.typedef.G;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteFuture;
-import org.apache.ignite.lang.IgniteFutureTimeoutException;
-import org.apache.ignite.lang.IgniteInClosure;
-import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
-import org.apache.ignite.spi.checkpoint.noop.NoopCheckpointSpi;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-/**
- *
- */
-public class CacheAffEarlySelfTest extends GridCommonAbstractTest {
-    /** Grid count. */
-    private static int GRID_CNT = 8;
-
-    /** Operation timeout. */
-    private static long OP_TIMEOUT = 5000;
-
-    /** Always dump threads or only once per operation. */
-    private static boolean ALWAYS_DUMP_THREADS = false;
-
-    /** Stopped. */
-    private volatile boolean stopped;
-
-    /** Iteration. */
-    private int iters = 10;
-
-    /** Concurrent. */
-    private boolean concurrent = true;
-
-    /** Futs. */
-    private Collection<IgniteInternalFuture<?>> futs = new ArrayList<>(GRID_CNT);
-
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(gridName);
-
-        TcpDiscoveryVmIpFinder finder = new TcpDiscoveryVmIpFinder(true);
-        finder.setAddresses(Collections.singletonList("127.0.0.1:47500..47510"));
-
-        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
-        discoSpi.setIpFinder(finder);
-
-        cfg.setDiscoverySpi(discoSpi);
-
-        OptimizedMarshaller marsh = new OptimizedMarshaller();
-        marsh.setRequireSerializable(false);
-
-        cfg.setMarshaller(marsh);
-
-        cfg.setCheckpointSpi(new NoopCheckpointSpi());
-
-        return cfg;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected long getTestTimeout() {
-        return 6 * 60 * 1000L;
-    }
-
-    /**
-     *
-     */
-    public void testStartNodes() throws Exception {
-        for (int i = 0; i < iters; i++) {
-            try {
-                System.out.println("*** Iteration " + (i + 1) + '/' + iters);
-
-                IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
-                    @Override public void run() {
-                        try {
-                            doTest();
-                        }
-                        catch (Exception e) {
-                            e.printStackTrace();
-                        }
-                    }
-                }, 1);
-
-                fut.get(30000);
-            }
-            catch (IgniteFutureTimeoutCheckedException e) {
-                // No-op.
-            }
-            finally {
-                stopAllGrids(true);
-            }
-        }
-    }
-
-    /**
-     *
-     */
-    public void doTest() throws Exception {
-        for (int i = 0; i < GRID_CNT; i++) {
-            final int idx = i;
-
-            final Ignite grid = concurrent ? null : startGrid(idx);
-
-            IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
-                @Override public void run() {
-                    Random rnd = new Random();
-
-                    try {
-                        final Ignite ignite = grid == null ? startGrid(idx) : grid;
-
-                        final IgniteCache<UUID, UUID> cache = getCache(ignite).withAsync();
-
-                        CacheAffEarlySelfTest.this.execute(cache, new IgniteInClosure<IgniteCache<UUID,UUID>>() {
-                            @Override public void apply(IgniteCache<UUID, UUID> entries) {
-                                cache.put(ignite.cluster().localNode().id(), UUID.randomUUID());
-                            }
-                        });
-
-                        while (!stopped) {
-                            int val = Math.abs(rnd.nextInt(100));
-                            if (val >= 0 && val < 40)
-                                execute(cache, new IgniteInClosure<IgniteCache<UUID, UUID>>() {
-                                    @Override public void apply(IgniteCache<UUID, UUID> entries) {
-                                        cache.containsKey(ignite.cluster().localNode().id());
-                                    }
-                                });
-                            else if (val >= 40 && val < 80)
-                                execute(cache, new IgniteInClosure<IgniteCache<UUID, UUID>>() {
-                                    @Override public void apply(IgniteCache<UUID, UUID> entries) {
-                                        cache.get(ignite.cluster().localNode().id());
-                                    }
-                                });
-                            else
-                                execute(cache, new IgniteInClosure<IgniteCache<UUID, UUID>>() {
-                                    @Override public void apply(IgniteCache<UUID, UUID> entries) {
-                                        cache.put(ignite.cluster().localNode().id(), UUID.randomUUID());
-                                    }
-                                });
-
-                            Thread.sleep(50);
-                        }
-                    }
-                    catch (Exception e) {
-                        e.printStackTrace();
-                    }
-                }
-            }, 1);
-
-            futs.add(fut);
-        }
-
-        Thread.sleep(10000);
-
-        stopped = true;
-
-        for (IgniteInternalFuture<?> fut : futs)
-            fut.get();
-    }
-
-    /**
-     * @param cache Cache.
-     * @param c Closure.
-     */
-    private void execute(IgniteCache<UUID, UUID> cache, IgniteInClosure<IgniteCache<UUID, UUID>> c) {
-        c.apply(cache);
-
-        IgniteFuture<Object> fut = cache.future();
-
-        boolean success = false;
-
-        int iter = 0;
-
-        while (!success) {
-            try {
-                fut.get(OP_TIMEOUT);
-
-                success = true;
-            }
-            catch (IgniteFutureTimeoutException e) {
-                debug(iter == 0 || ALWAYS_DUMP_THREADS);
-            }
-
-            iter++;
-        }
-    }
-
-    /**
-     *
-     */
-    private void debug(boolean dumpThreads) {
-        log.info("DUMPING DEBUG INFO:");
-
-        for (Ignite ignite : G.allGrids())
-            ((IgniteKernal)ignite).dumpDebugInfo();
-
-        if (dumpThreads) {
-            U.dumpThreads(null);
-
-            U.dumpThreads(log);
-        }
-    }
-
-    /**
-     * @param grid Grid.
-     */
-    private IgniteCache<UUID, UUID> getCache(Ignite grid) {
-        CacheConfiguration<UUID, UUID> ccfg = defaultCacheConfiguration();
-
-        ccfg.setCacheMode(CacheMode.PARTITIONED);
-        ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
-        ccfg.setBackups(1);
-        ccfg.setNearConfiguration(null);
-
-        return grid.getOrCreateCache(ccfg);
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/baa1a6be/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAffinityEarlyTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAffinityEarlyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAffinityEarlyTest.java
new file mode 100644
index 0000000..6b67139
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheAffinityEarlyTest.java
@@ -0,0 +1,168 @@
+/*
+ * 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.cache.distributed;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Random;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicBoolean;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ *
+ */
+public class CacheAffinityEarlyTest extends GridCommonAbstractTest {
+    /** Grid count. */
+    private static int GRID_CNT = 8;
+
+    /** Stopped. */
+    private volatile boolean stopped;
+
+    /** Iteration. */
+    private static final int iters = 10;
+
+    /** Concurrent. */
+    private static final boolean concurrent = true;
+
+    /** Futs. */
+    private Collection<IgniteInternalFuture<?>> futs = new ArrayList<>(GRID_CNT);
+
+    /** */
+    private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+        discoSpi.setIpFinder(ipFinder);
+
+        cfg.setDiscoverySpi(discoSpi);
+
+        OptimizedMarshaller marsh = new OptimizedMarshaller();
+        marsh.setRequireSerializable(false);
+
+        cfg.setMarshaller(marsh);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected long getTestTimeout() {
+        return 6 * 60 * 1000L;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testStartNodes() throws Exception {
+        for (int i = 0; i < iters; i++) {
+            try {
+                log.info("Iteration: " + (i + 1) + '/' + iters);
+
+                doTest();
+            }
+            finally {
+                stopAllGrids(true);
+            }
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    private void doTest() throws Exception {
+        final AtomicBoolean failed = new AtomicBoolean();
+
+        for (int i = 0; i < GRID_CNT; i++) {
+            final int idx = i;
+
+            final Ignite grid = concurrent ? null : startGrid(idx);
+
+            IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
+                @Override public void run() {
+                    Random rnd = new Random();
+
+                    try {
+                        Ignite ignite = grid == null ? startGrid(idx) : grid;
+
+                        IgniteCache<Object, Object> cache = getCache(ignite);
+
+                        cache.put(ignite.cluster().localNode().id(), UUID.randomUUID());
+
+                        while (!stopped) {
+                            int val = Math.abs(rnd.nextInt(100));
+
+                            if (val >= 0 && val < 40)
+                                cache.containsKey(ignite.cluster().localNode().id());
+                            else if (val >= 40 && val < 80)
+                                cache.get(ignite.cluster().localNode().id());
+                            else
+                                cache.put(ignite.cluster().localNode().id(), UUID.randomUUID());
+
+                            Thread.sleep(50);
+                        }
+                    }
+                    catch (Exception e) {
+                        log.error("Unexpected error: " + e, e);
+
+                        failed.set(true);
+                    }
+                }
+            }, 1);
+
+            futs.add(fut);
+        }
+
+        Thread.sleep(10_000);
+
+        stopped = true;
+
+        for (IgniteInternalFuture<?> fut : futs)
+            fut.get();
+
+        assertFalse(failed.get());
+    }
+
+    /**
+     * @param grid Grid.
+     * @return Cache.
+     */
+    private IgniteCache getCache(Ignite grid) {
+        CacheConfiguration ccfg = defaultCacheConfiguration();
+
+        ccfg.setCacheMode(CacheMode.PARTITIONED);
+        ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
+        ccfg.setBackups(1);
+        ccfg.setNearConfiguration(null);
+
+        return grid.getOrCreateCache(ccfg);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/baa1a6be/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAffEarlySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAffEarlySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAffEarlySelfTest.java
deleted file mode 100644
index d915f09..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAffEarlySelfTest.java
+++ /dev/null
@@ -1,175 +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.ignite.internal.processors.cache.distributed;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cache.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.internal.*;
-import org.apache.ignite.marshaller.optimized.*;
-import org.apache.ignite.spi.discovery.tcp.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
-import org.apache.ignite.testframework.junits.common.*;
-
-import java.util.*;
-import java.util.concurrent.atomic.*;
-
-/**
- *
- */
-public class GridCacheAffEarlySelfTest extends GridCommonAbstractTest {
-    /** Grid count. */
-    private static int GRID_CNT = 8;
-
-    /** Stopped. */
-    private volatile boolean stopped;
-
-    /** Iteration. */
-    private static final int iters = 10;
-
-    /** Concurrent. */
-    private static final boolean concurrent = true;
-
-    /** Futs. */
-    private Collection<IgniteInternalFuture<?>> futs = new ArrayList<>(GRID_CNT);
-
-    /** */
-    private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
-
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(gridName);
-
-        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
-        discoSpi.setIpFinder(ipFinder);
-
-        cfg.setDiscoverySpi(discoSpi);
-
-        OptimizedMarshaller marsh = new OptimizedMarshaller();
-        marsh.setRequireSerializable(false);
-
-        cfg.setMarshaller(marsh);
-
-        return cfg;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected long getTestTimeout() {
-        return 6 * 60 * 1000L;
-    }
-
-    /**
-     *
-     */
-    public void testStartNodes() throws Exception {
-        for (int i = 0; i < iters; i++) {
-            try {
-                System.out.println("*** Iteration " + (i + 1) + '/' + iters);
-
-                IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
-                    @Override public void run() {
-                        try {
-                            doTest();
-                        }
-                        catch (Exception e) {
-                            e.printStackTrace();
-                        }
-                    }
-                }, 1);
-
-                fut.get(30000);
-            }
-            catch (IgniteFutureTimeoutCheckedException e) {
-                // No-op.
-            }
-            finally {
-                stopAllGrids(true);
-            }
-        }
-    }
-
-    /**
-     *
-     */
-    public void doTest() throws Exception {
-        final AtomicBoolean failed = new AtomicBoolean();
-
-        for (int i = 0; i < GRID_CNT; i++) {
-            final int idx = i;
-
-            final Ignite grid = concurrent ? null : startGrid(idx);
-
-            IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
-                @Override
-                public void run() {
-                    Random rnd = new Random();
-
-                    try {
-                        Ignite ignite = grid == null ? startGrid(idx) : grid;
-
-                        IgniteCache cache = getCache(ignite);
-
-                        cache.put(ignite.cluster().localNode().id(), UUID.randomUUID());
-
-                        while (!stopped) {
-                            int val = Math.abs(rnd.nextInt(100));
-                            if (val >= 0 && val < 40)
-                                cache.containsKey(ignite.cluster().localNode().id());
-                            else if (val >= 40 && val < 80)
-                                cache.get(ignite.cluster().localNode().id());
-                            else
-                                cache.put(ignite.cluster().localNode().id(), UUID.randomUUID());
-
-                            Thread.sleep(50);
-                        }
-                    } catch (Exception e) {
-                        e.printStackTrace();
-
-                        failed.set(true);
-                    }
-                }
-            }, 1);
-
-            futs.add(fut);
-        }
-
-        Thread.sleep(10000);
-
-        stopped = true;
-
-        for (IgniteInternalFuture<?> fut : futs)
-            fut.get();
-
-        assertFalse(failed.get());
-    }
-
-    /**
-     * @param grid Grid.
-     */
-    private IgniteCache getCache(Ignite grid) {
-        CacheConfiguration ccfg = defaultCacheConfiguration();
-
-        ccfg.setCacheMode(CacheMode.PARTITIONED);
-        ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
-        ccfg.setBackups(1);
-        ccfg.setNearConfiguration(null);
-
-        return grid.getOrCreateCache(ccfg);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/baa1a6be/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMultiThreadedTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMultiThreadedTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMultiThreadedTest.java
index 16fa662..86825aa 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMultiThreadedTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryMultiThreadedTest.java
@@ -102,7 +102,7 @@ public class TcpDiscoveryMultiThreadedTest extends GridCommonAbstractTest {
 
     /** {@inheritDoc} */
     @Override protected long getTestTimeout() {
-        return 3 * 60 * 1000;
+        return 5 * 60 * 1000;
     }
 
     /**
@@ -249,35 +249,44 @@ public class TcpDiscoveryMultiThreadedTest extends GridCommonAbstractTest {
      * @throws Exception If any error occurs.
      */
     public void testMultipleStartOnCoordinatorStop() throws Exception{
-        clientFlagGlobal = false;
+        for (int k = 0; k < 3; k++) {
+            log.info("Iteration: " + k);
 
-        startGrids(GRID_CNT);
+            clientFlagGlobal = false;
 
-        final CyclicBarrier barrier = new CyclicBarrier(GRID_CNT + 4);
+            final int START_NODES = 5;
+            final int JOIN_NODES = 10;
 
-        final AtomicInteger startIdx = new AtomicInteger(GRID_CNT);
+            startGrids(START_NODES);
 
-        IgniteInternalFuture<?> fut = GridTestUtils.runMultiThreadedAsync(new Callable<Object>() {
-            @Override public Object call() throws Exception {
-                barrier.await();
+            final CyclicBarrier barrier = new CyclicBarrier(JOIN_NODES + 1);
 
-                Ignite ignite = startGrid(startIdx.getAndIncrement());
+            final AtomicInteger startIdx = new AtomicInteger(START_NODES);
 
-                assertFalse(ignite.configuration().isClientMode());
+            IgniteInternalFuture<?> fut = GridTestUtils.runMultiThreadedAsync(new Callable<Object>() {
+                @Override public Object call() throws Exception {
+                    barrier.await();
 
-                log.info("Started node: " + ignite.name());
+                    Ignite ignite = startGrid(startIdx.getAndIncrement());
 
-                return null;
-            }
-        }, GRID_CNT + 3, "start-thread");
+                    assertFalse(ignite.configuration().isClientMode());
 
-        barrier.await();
+                    log.info("Started node: " + ignite.name());
 
-        U.sleep(ThreadLocalRandom.current().nextInt(10, 100));
+                    return null;
+                }
+            }, JOIN_NODES, "start-thread");
 
-        for (int i = 0; i < GRID_CNT; i++)
-            stopGrid(i);
+            barrier.await();
 
-        fut.get();
+            U.sleep(ThreadLocalRandom.current().nextInt(10, 100));
+
+            for (int i = 0; i < START_NODES; i++)
+                stopGrid(i);
+
+            fut.get();
+
+            stopAllGrids();
+        }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/baa1a6be/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
index 88977fb..289da3d 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java
@@ -74,6 +74,7 @@ import org.apache.ignite.internal.processors.cache.IgniteInternalCacheTypesTest;
 import org.apache.ignite.internal.processors.cache.IgniteStartCacheInTransactionAtomicSelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteStartCacheInTransactionSelfTest;
 import org.apache.ignite.internal.processors.cache.IgniteSystemCacheOnClientTest;
+import org.apache.ignite.internal.processors.cache.distributed.CacheAffinityEarlyTest;
 import org.apache.ignite.internal.processors.cache.distributed.CacheNoValueClassOnServerNodeTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCacheLockFailoverSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCacheMultiTxLockSelfTest;
@@ -195,6 +196,7 @@ public class IgniteCacheTestSuite4 extends TestSuite {
         suite.addTestSuite(IgniteCacheConfigurationDefaultTemplateTest.class);
         suite.addTestSuite(IgniteDynamicClientCacheStartSelfTest.class);
         suite.addTestSuite(IgniteDynamicCacheStartNoExchangeTimeoutTest.class);
+        suite.addTestSuite(CacheAffinityEarlyTest.class);
 
         suite.addTestSuite(GridCacheTxLoadFromStoreOnLockSelfTest.class);