You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2019/02/06 15:06:28 UTC
[ignite] branch master updated: IGNITE-11159 Filter all collections
in LocalJoinCacheContext when forming a new ring - Fixes #5988.
This is an automated email from the ASF dual-hosted git repository.
agoncharuk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new 7ecd53f IGNITE-11159 Filter all collections in LocalJoinCacheContext when forming a new ring - Fixes #5988.
7ecd53f is described below
commit 7ecd53fb6ea0c871d83f188a17d2fb410fc289b9
Author: Sergey Chugunov <se...@gmail.com>
AuthorDate: Wed Feb 6 18:04:24 2019 +0300
IGNITE-11159 Filter all collections in LocalJoinCacheContext when forming a new ring - Fixes #5988.
Signed-off-by: Alexey Goncharuk <al...@gmail.com>
---
.../processors/cache/ClusterCachesInfo.java | 54 +++++++++++++++++++---
...gniteDiscoveryDataHandlingInNewClusterTest.java | 15 +++++-
2 files changed, 60 insertions(+), 9 deletions(-)
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
index 7d5816a..91e4704 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
@@ -145,20 +145,45 @@ class ClusterCachesInfo {
if (ctx.isDaemon())
return;
- Map<String, CacheJoinNodeDiscoveryData.CacheInfo> caches = localConfigData.caches();
+ filterRegisteredCachesAndCacheGroups(localConfigData.caches());
+ List<T2<DynamicCacheDescriptor, NearCacheConfiguration>> locJoinStartCaches = locJoinCachesCtx.caches();
+
+ filterLocalJoinStartCaches(locJoinStartCaches);
+
+ List<DynamicCacheDescriptor> initCaches = locJoinCachesCtx.initCaches();
+
+ filterInitCaches(initCaches);
+
+ locJoinCachesCtx = new LocalJoinCachesContext(
+ locJoinStartCaches,
+ initCaches,
+ registeredCacheGrps,
+ registeredCaches);
+ }
+
+ /**
+ * Filters from registered caches all caches that are not presented in node's local configuration.
+ *
+ * Then filters from registered cache groups all groups that became empty after registered caches were filtered.
+ *
+ * @param locCaches Caches from local node configuration (static configuration and persistent caches).
+ */
+ private void filterRegisteredCachesAndCacheGroups(Map<String, CacheJoinNodeDiscoveryData.CacheInfo> locCaches) {
+ //filter registered caches
Iterator<Map.Entry<String, DynamicCacheDescriptor>> cachesIter = registeredCaches.entrySet().iterator();
while (cachesIter.hasNext()) {
Map.Entry<String, DynamicCacheDescriptor> e = cachesIter.next();
- if (!caches.containsKey(e.getKey())) {
+ if (!locCaches.containsKey(e.getKey())) {
cachesIter.remove();
ctx.discovery().removeCacheFilter(e.getKey());
}
}
+ //filter registered cache groups
Iterator<Map.Entry<Integer, CacheGroupDescriptor>> grpsIter = registeredCacheGrps.entrySet().iterator();
while (grpsIter.hasNext()) {
@@ -180,12 +205,27 @@ class ClusterCachesInfo {
ctx.discovery().removeCacheGroup(e.getValue());
}
}
+ }
- locJoinCachesCtx = new LocalJoinCachesContext(
- locJoinCachesCtx.caches(),
- locJoinCachesCtx.initCaches(),
- registeredCacheGrps,
- registeredCaches);
+ /**
+ * Filters from local join context cache descriptors that should be started on join.
+ *
+ * @param locJoinStartCaches Collection to filter.
+ */
+ private void filterLocalJoinStartCaches(
+ List<T2<DynamicCacheDescriptor, NearCacheConfiguration>> locJoinStartCaches) {
+
+ locJoinStartCaches.removeIf(next -> !registeredCaches.containsKey(next.getKey().cacheName()));
+ }
+
+ /**
+ * Filters from local join context cache descriptors that require init of query infrastructure without cache
+ * start.
+ *
+ * @param initCaches Collection to filter.
+ */
+ private void filterInitCaches(List<DynamicCacheDescriptor> initCaches) {
+ initCaches.removeIf(desc -> !registeredCaches.containsKey(desc.cacheName()));
}
/**
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDiscoveryDataHandlingInNewClusterTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDiscoveryDataHandlingInNewClusterTest.java
index 329d5e5..351d660 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDiscoveryDataHandlingInNewClusterTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDiscoveryDataHandlingInNewClusterTest.java
@@ -57,11 +57,17 @@ public class IgniteDiscoveryDataHandlingInNewClusterTest extends GridCommonAbstr
/** */
private static final String DYNAMIC_CACHE_NAME_2 = "dynamicCache2";
+ /** */
+ private static final String DYNAMIC_CACHE_NAME_3 = "dynamicCache3";
+
/** Group where static and dynamic caches reside. */
private static final String GROUP_WITH_STATIC_CACHES = "group1";
/** Group where only dynamic caches reside. */
- private static final String GROUP_WITH_DYNAMIC_CACHES = "group2";
+ private static final String DYNAMIC_CACHES_GROUP_WITH_FILTER = "group2";
+
+ /** Group where only dynamic caches reside. */
+ private static final String DYNAMIC_CACHES_GROUP_WITHOUT_FILTER = "group3";
/** Node filter to pin dynamic caches to a specific node. */
private static final IgnitePredicate<ClusterNode> nodeFilter = new IgnitePredicate<ClusterNode>() {
@@ -184,10 +190,15 @@ public class IgniteDiscoveryDataHandlingInNewClusterTest extends GridCommonAbstr
);
ig.getOrCreateCache(new CacheConfiguration<>(DYNAMIC_CACHE_NAME_2)
- .setGroupName(GROUP_WITH_DYNAMIC_CACHES)
+ .setGroupName(DYNAMIC_CACHES_GROUP_WITH_FILTER)
.setAffinity(new RendezvousAffinityFunction(false, 16))
.setNodeFilter((IgnitePredicate<ClusterNode>)node -> node.consistentId().toString().contains(NODE_1_CONS_ID))
);
+
+ ig.getOrCreateCache(new CacheConfiguration<>(DYNAMIC_CACHE_NAME_3)
+ .setGroupName(DYNAMIC_CACHES_GROUP_WITHOUT_FILTER)
+ .setAffinity(new RendezvousAffinityFunction(false, 16))
+ );
}
/**