Repository: ignite Updated Branches: refs/heads/ignite-1741 37fedb351 -> 96860ed13
ignite-1741 Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/96860ed1 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/96860ed1 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/96860ed1 Branch: refs/heads/ignite-1741 Commit: 96860ed13d159fe41b0be05282fdfc668edbd366 Parents: 37fedb3 Author: sboikov <[email protected]> Authored: Wed Dec 19 00:20:21 2018 +0300 Committer: sboikov <[email protected]> Committed: Wed Dec 19 00:20:21 2018 +0300 ---------------------------------------------------------------------- .../cache/CacheAffinityCallSelfTest.java | 45 +++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/96860ed1/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheAffinityCallSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheAffinityCallSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheAffinityCallSelfTest.java index f1d4740..dab045a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheAffinityCallSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheAffinityCallSelfTest.java @@ -18,13 +18,17 @@ package org.apache.ignite.internal.processors.cache; import java.util.concurrent.Callable; +import java.util.concurrent.ThreadLocalRandom; + import org.apache.ignite.Ignite; import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteCompute; +import org.apache.ignite.cache.affinity.Affinity; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.cluster.ClusterTopologyException; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.IgniteEx; import org.apache.ignite.internal.IgniteInternalFuture; import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; @@ -158,9 +162,10 @@ public class CacheAffinityCallSelfTest extends GridCommonAbstractTest { final Integer key = 1; - final Ignite client = grid(SRVS); + final IgniteEx client = grid(SRVS); assertTrue(client.configuration().isClientMode()); + assertNull(client.context().cache().cache(CACHE_NAME)); final IgniteInternalFuture<Object> fut = GridTestUtils.runAsync(new Callable<Object>() { @Override public Object call() { @@ -184,6 +189,44 @@ public class CacheAffinityCallSelfTest extends GridCommonAbstractTest { } /** + * @throws Exception If failed. + */ + @Test + public void testAffinityFailoverNoCacheOnClient() throws Exception { + startGridsMultiThreaded(SRVS + 1); + + final Integer key = 1; + + final IgniteEx client = grid(SRVS); + + assertTrue(client.configuration().isClientMode()); + + final IgniteInternalFuture<Object> fut = GridTestUtils.runAsync(new Callable<Object>() { + @Override public Object call() throws Exception { + for (int i = 0; i < SRVS - 1; ++i) { + U.sleep(ThreadLocalRandom.current().nextLong(100) + 50); + + stopGrid(i, false); + } + + return null; + } + }); + + try { + Affinity<Integer> aff = client.affinity(CACHE_NAME); + + assertNull(client.context().cache().cache(CACHE_NAME)); + + while (!fut.isDone()) + assertNotNull(aff.mapKeyToNode(key)); + } + finally { + stopAllGrids(); + } + } + + /** * Test callable. */ public static class CheckCallable implements IgniteCallable<Object> {
