Repository: ignite Updated Branches: refs/heads/ignite-5272 a951bee81 -> 84bcfa1f0
ignite-5272 Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/84bcfa1f Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/84bcfa1f Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/84bcfa1f Branch: refs/heads/ignite-5272 Commit: 84bcfa1f0a3e003993339c723060c1e8e2a596c6 Parents: a951bee Author: sboikov <[email protected]> Authored: Tue Jun 13 15:57:44 2017 +0300 Committer: sboikov <[email protected]> Committed: Tue Jun 13 17:10:50 2017 +0300 ---------------------------------------------------------------------- .../cache/CacheAffinitySharedManager.java | 22 ++++++++---- .../processors/cache/GridCacheProcessor.java | 36 +++++++++----------- ...IgniteClientCacheInitializationFailTest.java | 6 ++-- .../CacheLateAffinityAssignmentTest.java | 8 ++--- 4 files changed, 40 insertions(+), 32 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/84bcfa1f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java index e74437c..5dafa36 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java @@ -385,14 +385,14 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap for (DynamicCacheDescriptor desc : startDescs) { try { + startedCaches.add(desc.cacheName()); + DynamicCacheChangeRequest startReq = startReqs.get(desc.cacheName()); cctx.cache().prepareCacheStart(desc, startReq.nearCacheConfiguration(), topVer); startedInfos.put(desc.cacheId(), startReq.nearCacheConfiguration() != null); - startedCaches.add(desc.cacheName()); - CacheGroupContext grp = cctx.cache().cacheGroup(desc.groupId()); assert grp != null : desc.groupId(); @@ -402,6 +402,13 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap assert grp.localStartVersion().equals(topVer) : grp.localStartVersion(); if (crd) { + ClientCacheDhtTopologyFuture topFut = new ClientCacheDhtTopologyFuture(topVer); + + grp.topology().updateTopologyVersion(topFut, + discoCache, + -1, + false); + GridClientPartitionTopology clientTop = cctx.exchange().clearClientTopology(grp.groupId()); if (clientTop != null) { @@ -2078,11 +2085,11 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap * @param caches Registered caches. */ void init(Map<Integer, CacheGroupDescriptor> grps, Map<String, DynamicCacheDescriptor> caches) { - for (CacheGroupDescriptor grp : grps.values()) - registeredGrps.put(grp.groupId(), grp); + for (CacheGroupDescriptor grpDesc : grps.values()) + registeredGrps.put(grpDesc.groupId(), grpDesc); - for (DynamicCacheDescriptor cache : caches.values()) - registeredCaches.put(cache.cacheName(), cache); + for (DynamicCacheDescriptor cacheDesc : caches.values()) + registeredCaches.put(cacheDesc.cacheName(), cacheDesc); } /** @@ -2113,6 +2120,9 @@ public class CacheAffinitySharedManager<K, V> extends GridCacheSharedManagerAdap if (!registeredGrps.containsKey(grpDesc.groupId())) registeredGrps.put(grpDesc.groupId(), grpDesc); + + if (!registeredCaches.containsKey(desc.cacheName())) + registeredCaches.put(desc.cacheName(), desc); } } http://git-wip-us.apache.org/repos/asf/ignite/blob/84bcfa1f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java index efc9555..2f7fef2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java @@ -2092,7 +2092,9 @@ public class GridCacheProcessor extends GridProcessorAdapter { try { for (String cacheName : cachesToClose) { - GridCacheContext ctx = blockGateway(cacheName, false); + blockGateway(cacheName, false); + + GridCacheContext ctx = sharedCtx.cacheContext(CU.cacheId(cacheName)); if (ctx == null) continue; @@ -2112,7 +2114,7 @@ public class GridCacheProcessor extends GridProcessorAdapter { if (!ctx.affinityNode() && ctx.transactional()) sharedCtx.tm().rollbackTransactionsForCache(ctx.cacheId()); - closeCache(cacheName, false); + closeCache(ctx, false); } return ids; @@ -2124,30 +2126,26 @@ public class GridCacheProcessor extends GridProcessorAdapter { } /** - * @param cacheName Cache name. + * @param cctx Cache context. * @param destroy Destroy flag. */ - private void closeCache(String cacheName, boolean destroy) { - IgniteCacheProxy<?, ?> proxy = jCacheProxies.get(cacheName); - - if (proxy != null) { - if (proxy.context().affinityNode()) { - GridCacheAdapter<?, ?> cache = caches.get(cacheName); + private void closeCache(GridCacheContext cctx, boolean destroy) { + if (cctx.affinityNode()) { + GridCacheAdapter<?, ?> cache = caches.get(cctx.name()); - assert cache != null : cacheName; + assert cache != null : cctx.name(); - jCacheProxies.put(cacheName, new IgniteCacheProxy(cache.context(), cache, null, false)); - } - else { - jCacheProxies.remove(cacheName); + jCacheProxies.put(cctx.name(), new IgniteCacheProxy(cache.context(), cache, null, false)); + } + else { + jCacheProxies.remove(cctx.name()); - proxy.context().gate().onStopped(); + cctx.gate().onStopped(); - CacheGroupContext grp = prepareCacheStop(cacheName, destroy); + CacheGroupContext grp = prepareCacheStop(cctx.name(), destroy); - if (grp != null && !grp.hasCaches()) - stopCacheGroup(grp.groupId()); - } + if (grp != null && !grp.hasCaches()) + stopCacheGroup(grp.groupId()); } } http://git-wip-us.apache.org/repos/asf/ignite/blob/84bcfa1f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientCacheInitializationFailTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientCacheInitializationFailTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientCacheInitializationFailTest.java index 1d616f8..19b0ea5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientCacheInitializationFailTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteClientCacheInitializationFailTest.java @@ -41,6 +41,7 @@ import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; import org.apache.ignite.internal.GridKernalContext; +import org.apache.ignite.internal.IgniteKernal; import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion; import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; import org.apache.ignite.internal.processors.query.GridQueryCancel; @@ -161,6 +162,7 @@ public class IgniteClientCacheInitializationFailTest extends GridCommonAbstractT } /** + * @param cacheName Cache name. * @throws Exception If failed. */ private void checkCacheInitialization(final String cacheName) throws Exception { @@ -170,8 +172,7 @@ public class IgniteClientCacheInitializationFailTest extends GridCommonAbstractT checkFineCache(client, CACHE_NAME + 1); - assertNull(client.cache(cacheName)); - assertNull(client.getOrCreateCache(cacheName)); + assertNull(((IgniteKernal)client).context().cache().cache(cacheName)); checkFineCache(client, CACHE_NAME + 2); } @@ -210,7 +211,6 @@ public class IgniteClientCacheInitializationFailTest extends GridCommonAbstractT else cache = client.cache(cacheName); - cache.put(1, "1"); assertEquals("1", cache.get(1)); http://git-wip-us.apache.org/repos/asf/ignite/blob/84bcfa1f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java index 20cef30..db76147 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/CacheLateAffinityAssignmentTest.java @@ -476,7 +476,7 @@ public class CacheLateAffinityAssignmentTest extends GridCommonAbstractTest { ignite0.cache(CACHE_NAME1); - checkAffinity(nodes, topVer(topVer, 2), true); + checkAffinity(nodes, topVer(topVer, 1), true); topVer++; @@ -486,7 +486,7 @@ public class CacheLateAffinityAssignmentTest extends GridCommonAbstractTest { ignite0.cache(CACHE_NAME1).close(); - checkAffinity(nodes, topVer(topVer, 2), true); + checkAffinity(nodes, topVer(topVer, 1), true); } } @@ -1240,11 +1240,11 @@ public class CacheLateAffinityAssignmentTest extends GridCommonAbstractTest { IgniteCache cache = client.cache(CACHE_NAME1); - checkAffinity(2, topVer(2, 1), true); + checkAffinity(2, topVer(2, 0), true); cache.close(); - checkAffinity(2, topVer(2, 2), true); + checkAffinity(2, topVer(2, 0), true); } /**
