Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id B4DA6200CA7 for ; Wed, 14 Jun 2017 15:51:22 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id B35E1160BE8; Wed, 14 Jun 2017 13:51:22 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id AB0F2160BC0 for ; Wed, 14 Jun 2017 15:51:21 +0200 (CEST) Received: (qmail 51583 invoked by uid 500); 14 Jun 2017 13:51:20 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 51574 invoked by uid 99); 14 Jun 2017 13:51:20 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Jun 2017 13:51:20 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B24A0DFAF5; Wed, 14 Jun 2017 13:51:20 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sboikov@apache.org To: commits@ignite.apache.org Message-Id: <1bfc7071034545f28d2b89ded65b9a3e@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: ignite git commit: ignite-5272 Date: Wed, 14 Jun 2017 13:51:20 +0000 (UTC) archived-at: Wed, 14 Jun 2017 13:51:22 -0000 Repository: ignite Updated Branches: refs/heads/ignite-5272 f765fd82a -> bfce92519 ignite-5272 Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/bfce9251 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/bfce9251 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/bfce9251 Branch: refs/heads/ignite-5272 Commit: bfce925198910d9016222bfd6cbb02a5a333c380 Parents: f765fd8 Author: sboikov Authored: Wed Jun 14 16:12:53 2017 +0300 Committer: sboikov Committed: Wed Jun 14 16:51:13 2017 +0300 ---------------------------------------------------------------------- .../apache/ignite/IgniteSystemProperties.java | 2 +- .../cache/CacheAffinitySharedManager.java | 39 ++++++++++++-------- .../ClientCacheChangeDiscoveryMessage.java | 2 +- .../ClientCacheChangeDummyDiscoveryMessage.java | 2 + .../processors/cache/GridCacheProcessor.java | 7 +--- .../dht/ClientCacheDhtTopologyFuture.java | 2 +- .../IgniteDynamicClientCacheStartSelfTest.java | 38 +++++++++++++++++-- 7 files changed, 63 insertions(+), 29 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/bfce9251/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java index 2121f38..d9c112c 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java @@ -624,7 +624,7 @@ public final class IgniteSystemProperties { public static final String IGNITE_SECURITY_COMPATIBILITY_MODE = "IGNITE_SECURITY_COMPATIBILITY_MODE"; /** - * When client cache is started or closed special discovery message is send to notify cluster (for example this is + * When client cache is started or closed special discovery message is sent to notify cluster (for example this is * needed for {@link ClusterGroup#forCacheNodes(String)} API. This timeout specifies how long to wait * after client cache start/close before sending this message. If during this timeout another client * cache changed, these events are combined into single message. http://git-wip-us.apache.org/repos/asf/ignite/blob/bfce9251/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 16850e6..c5d4b8f 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 @@ -412,28 +412,29 @@ public class CacheAffinitySharedManager extends GridCacheSharedManagerAdap assert grp.localStartVersion().equals(topVer) : grp.localStartVersion(); if (crd) { - ClientCacheDhtTopologyFuture topFut = new ClientCacheDhtTopologyFuture(topVer); + CacheGroupHolder grpHolder = grpHolders.get(grp.groupId()); - grp.topology().updateTopologyVersion(topFut, - discoCache, - -1, - false); + assert grpHolder != null && grpHolder.affinity().idealAssignment() != null; - GridClientPartitionTopology clientTop = cctx.exchange().clearClientTopology(grp.groupId()); + if (grpHolder.client()) { + ClientCacheDhtTopologyFuture topFut = new ClientCacheDhtTopologyFuture(topVer); - if (clientTop != null) { - grp.topology().update(topVer, - clientTop.partitionMap(true), - clientTop.updateCounters(false)); - } + grp.topology().updateTopologyVersion(topFut, discoCache, -1, false); - CacheGroupHolder grpHolder = grpHolders.get(grp.groupId()); + GridClientPartitionTopology clientTop = cctx.exchange().clearClientTopology(grp.groupId()); - assert grpHolder != null && grpHolder.affinity().idealAssignment() != null; + if (clientTop != null) { + grp.topology().update(topVer, + clientTop.partitionMap(true), + clientTop.updateCounters(false)); + } + + grpHolder = new CacheGroupHolder1(grp, grpHolder.affinity()); - grpHolder = new CacheGroupHolder1(grp, grpHolder.affinity()); + grpHolders.put(grp.groupId(), grpHolder); - grpHolders.put(grp.groupId(), grpHolder); + assert grpHolder.affinity().lastVersion().equals(grp.affinity().lastVersion()); + } } else if (!fetchFuts.containsKey(grp.groupId())) { GridDhtAssignmentFetchFuture fetchFut = new GridDhtAssignmentFetchFuture(cctx, @@ -555,6 +556,8 @@ public class CacheAffinitySharedManager extends GridCacheSharedManagerAdap } /** + * Process client cache start/close requests, called from exchange thread. + * * @param msg Change request. */ void processClientCachesChanges(ClientCacheChangeDummyDiscoveryMessage msg) { @@ -573,11 +576,15 @@ public class CacheAffinitySharedManager extends GridCacheSharedManagerAdap } /** - * @param timeoutObj Timeout object. + * Sends discovery message about started/closed client caches, called from exchange thread. + * + * @param timeoutObj Timeout object initiated send. */ void sendClientCacheChangesMessage(ClientCacheUpdateTimeout timeoutObj) { ClientCacheChangeDiscoveryMessage msg = clientCacheChanges.get(); + // Timeout object was changed if one more client cache changed during timeout, + // another timeoutObj was scheduled. if (msg != null && msg.updateTimeoutObject() == timeoutObj) { assert !msg.empty() : msg; http://git-wip-us.apache.org/repos/asf/ignite/blob/bfce9251/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClientCacheChangeDiscoveryMessage.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClientCacheChangeDiscoveryMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClientCacheChangeDiscoveryMessage.java index b4a1696..3d120f7 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClientCacheChangeDiscoveryMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClientCacheChangeDiscoveryMessage.java @@ -30,7 +30,7 @@ import org.apache.ignite.lang.IgniteUuid; import org.jetbrains.annotations.Nullable; /** - * + * Sent from cache client node to asynchronously notify about started.closed client caches. */ public class ClientCacheChangeDiscoveryMessage implements DiscoveryCustomMessage { /** */ http://git-wip-us.apache.org/repos/asf/ignite/blob/bfce9251/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClientCacheChangeDummyDiscoveryMessage.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClientCacheChangeDummyDiscoveryMessage.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClientCacheChangeDummyDiscoveryMessage.java index 878be94..68bca27 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClientCacheChangeDummyDiscoveryMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClientCacheChangeDummyDiscoveryMessage.java @@ -21,6 +21,7 @@ import java.util.Map; import java.util.Set; import java.util.UUID; import org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage; +import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.lang.IgniteUuid; import org.jetbrains.annotations.Nullable; @@ -40,6 +41,7 @@ public class ClientCacheChangeDummyDiscoveryMessage implements DiscoveryCustomMe private final Map startReqs; /** */ + @GridToStringInclude private final Set cachesToClose; /** http://git-wip-us.apache.org/repos/asf/ignite/blob/bfce9251/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 b1e6b7e..fb03f06 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 @@ -2015,9 +2015,8 @@ public class GridCacheProcessor extends GridProcessorAdapter { /** * @param cacheName Cache name. * @param stop {@code True} for stop cache, {@code false} for close cache. - * @return Cache context if cache found. */ - @Nullable GridCacheContext blockGateway(String cacheName, boolean stop) { + void blockGateway(String cacheName, boolean stop) { // Break the proxy before exchange future is done. IgniteCacheProxy proxy = jCacheProxies.get(cacheName); @@ -2026,11 +2025,7 @@ public class GridCacheProcessor extends GridProcessorAdapter { proxy.gate().stopped(); else proxy.closeProxy(); - - return proxy.context(); } - - return null; } /** http://git-wip-us.apache.org/repos/asf/ignite/blob/bfce9251/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/ClientCacheDhtTopologyFuture.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/ClientCacheDhtTopologyFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/ClientCacheDhtTopologyFuture.java index ac0efa7..3166159 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/ClientCacheDhtTopologyFuture.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/ClientCacheDhtTopologyFuture.java @@ -25,7 +25,7 @@ import org.apache.ignite.internal.processors.cache.CacheGroupContext; import org.apache.ignite.internal.util.typedef.internal.U; /** - * + * Topology future created for client cache start. */ public class ClientCacheDhtTopologyFuture extends GridDhtTopologyFutureAdapter implements GridDhtTopologyFuture { http://git-wip-us.apache.org/repos/asf/ignite/blob/bfce9251/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicClientCacheStartSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicClientCacheStartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicClientCacheStartSelfTest.java index 974feb5..0cb0856 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicClientCacheStartSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicClientCacheStartSelfTest.java @@ -44,6 +44,7 @@ import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.Nullable; +import static org.apache.ignite.cache.CacheAtomicityMode.*; import static org.apache.ignite.cache.CacheMode.REPLICATED; import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; import static org.apache.ignite.internal.IgniteNodeAttributes.ATTR_IGNITE_INSTANCE_NAME; @@ -302,7 +303,7 @@ public class IgniteDynamicClientCacheStartSelfTest extends GridCommonAbstractTes Ignite client = startGrid(SRVS); - for (CacheAtomicityMode atomicityMode : CacheAtomicityMode.values()) { + for (CacheAtomicityMode atomicityMode : values()) { for (boolean batch : new boolean[]{false, true}) startCachesForGroup(srv, client, grp, atomicityMode, batch); } @@ -381,7 +382,7 @@ public class IgniteDynamicClientCacheStartSelfTest extends GridCommonAbstractTes Ignite srv = startGrids(SRVS); - srv.createCaches(cacheConfigurations(null, CacheAtomicityMode.ATOMIC)); + srv.createCaches(cacheConfigurations(null, ATOMIC)); ccfg = null; @@ -391,8 +392,8 @@ public class IgniteDynamicClientCacheStartSelfTest extends GridCommonAbstractTes List cfgs = new ArrayList<>(); - cfgs.addAll(cacheConfigurations(null, CacheAtomicityMode.ATOMIC)); - cfgs.addAll(cacheConfigurations(null, CacheAtomicityMode.TRANSACTIONAL)); + cfgs.addAll(cacheConfigurations(null, ATOMIC)); + cfgs.addAll(cacheConfigurations(null, TRANSACTIONAL)); assertEquals(6, cfgs.size()); @@ -548,6 +549,35 @@ public class IgniteDynamicClientCacheStartSelfTest extends GridCommonAbstractTes } /** + * @throws Exception If failed. + */ + public void testStartClientCachesOnCoordinatorWithGroup() throws Exception { + startGrids(3); + + List ccfgs = cacheConfigurations("testGrp", ATOMIC); + + for (CacheConfiguration ccfg : ccfgs) + ccfg.setNodeFilter(new CachePredicate(F.asList(getTestIgniteInstanceName(0)))); + + ignite(1).createCaches(ccfgs); + + ccfgs = cacheConfigurations("testGrp", ATOMIC); + + for (CacheConfiguration ccfg : ccfgs) + ccfg.setNodeFilter(new CachePredicate(F.asList(getTestIgniteInstanceName(0)))); + + for (IgniteCache cache : ignite(0).getOrCreateCaches(ccfgs)) { + cache.put(1, 1); + + assertEquals(1, cache.get(1)); + + cache.close(); + } + + startGrid(4); + } + + /** * */ static class CachePredicate implements IgnitePredicate {