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 2017/06/08 13:13:51 UTC
[17/18] ignite git commit: IGNITE-5267 - Fixed compilation after
merge.
IGNITE-5267 - Fixed compilation after merge.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/1a19b900
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/1a19b900
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/1a19b900
Branch: refs/heads/ignite-5267-merge-ea
Commit: 1a19b9004ab5317e8c620c55d5faa2f1a18db577
Parents: 5182384
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Thu Jun 8 15:46:34 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Thu Jun 8 15:46:34 2017 +0300
----------------------------------------------------------------------
.../apache/ignite/IgniteSystemProperties.java | 3 ++
.../cache/CacheNodeCommonDiscoveryData.java | 16 ++++++-
.../processors/cache/ClusterCachesInfo.java | 32 +++++++++++++-
.../processors/cache/ExchangeActions.java | 15 +++++++
.../processors/cache/GridCacheGateway.java | 5 +--
.../GridCachePartitionExchangeManager.java | 2 +-
.../processors/cache/GridCacheProcessor.java | 45 ++++++++++++--------
.../dht/GridDhtPartitionTopologyImpl.java | 25 ++++++-----
.../dht/preloader/GridDhtPreloader.java | 1 -
.../cache/GridCacheAbstractFullApiSelfTest.java | 2 +-
10 files changed, 105 insertions(+), 41 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a19b900/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 3eec361..b77c98e 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
@@ -610,6 +610,9 @@ public final class IgniteSystemProperties {
*/
public static final String IGNITE_PDS_SKIP_CRC = "IGNITE_PDS_SKIP_CRC";
+ /** */
+ public static final String IGNITE_EXCHANGE_HISTORY_SIZE = "IGNITE_EXCHANGE_HISTORY_SIZE";
+
/**
* WAL rebalance threshold.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a19b900/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheNodeCommonDiscoveryData.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheNodeCommonDiscoveryData.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheNodeCommonDiscoveryData.java
index 4c70cb9..796ed9d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheNodeCommonDiscoveryData.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheNodeCommonDiscoveryData.java
@@ -18,6 +18,7 @@
package org.apache.ignite.internal.processors.cache;
import java.io.Serializable;
+import java.util.Collection;
import java.util.Map;
import java.util.UUID;
import org.apache.ignite.internal.util.tostring.GridToStringInclude;
@@ -45,6 +46,9 @@ class CacheNodeCommonDiscoveryData implements Serializable {
/** */
private final Map<String, Map<UUID, Boolean>> clientNodesMap;
+ /** */
+ private Collection<String> restartingCaches;
+
/**
* @param caches Started caches.
* @param templates Configured templates.
@@ -54,7 +58,9 @@ class CacheNodeCommonDiscoveryData implements Serializable {
CacheNodeCommonDiscoveryData(Map<String, CacheData> caches,
Map<String, CacheData> templates,
Map<Integer, CacheGroupData> cacheGrps,
- Map<String, Map<UUID, Boolean>> clientNodesMap) {
+ Map<String, Map<UUID, Boolean>> clientNodesMap,
+ Collection<String> restartingCaches
+ ) {
assert caches != null;
assert templates != null;
assert cacheGrps != null;
@@ -64,6 +70,7 @@ class CacheNodeCommonDiscoveryData implements Serializable {
this.templates = templates;
this.cacheGrps = cacheGrps;
this.clientNodesMap = clientNodesMap;
+ this.restartingCaches = restartingCaches;
}
/**
@@ -94,6 +101,13 @@ class CacheNodeCommonDiscoveryData implements Serializable {
return clientNodesMap;
}
+ /**
+ * @return A collection of restarting cache names.
+ */
+ Collection<String> restartingCaches() {
+ return restartingCaches;
+ }
+
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(CacheNodeCommonDiscoveryData.class, this);
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a19b900/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
----------------------------------------------------------------------
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 e584701..b8cf6e1 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
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.cache;
import java.io.Serializable;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -72,6 +73,9 @@ class ClusterCachesInfo {
/** Cache templates. */
private final ConcurrentMap<String, DynamicCacheDescriptor> registeredTemplates = new ConcurrentHashMap<>();
+ /** Caches currently being restarted. */
+ private final Collection<String> restartingCaches = new HashSet<>();
+
/** */
private final IgniteLogger log;
@@ -161,6 +165,7 @@ class ClusterCachesInfo {
joinDiscoData = null;
gridData = null;
}
+
/**
* Checks that remote caches has configuration compatible with the local.
*
@@ -324,6 +329,7 @@ class ClusterCachesInfo {
AffinityTopologyVersion waitTopVer = null;
if (req.start()) {
+ // Starting a new cache.
if (desc == null) {
String conflictErr = checkCacheConflict(req.startCacheConfiguration());
@@ -377,6 +383,8 @@ class ClusterCachesInfo {
DynamicCacheDescriptor old = registeredCaches.put(ccfg.getName(), startDesc);
+ restartingCaches.remove(ccfg.getName());
+
assert old == null;
ctx.discovery().setCacheFilter(
@@ -477,6 +485,9 @@ class ClusterCachesInfo {
DynamicCacheDescriptor old = registeredCaches.remove(req.cacheName());
+ if (req.restart())
+ restartingCaches.add(req.cacheName());
+
assert old != null && old == desc : "Dynamic cache map was concurrently modified [req=" + req + ']';
ctx.discovery().removeCacheFilter(req.cacheName());
@@ -573,6 +584,20 @@ class ClusterCachesInfo {
}
/**
+ * @return {@code True} if there are currently restarting caches.
+ */
+ boolean hasRestartingCaches() {
+ return !F.isEmpty(restartingCaches);
+ }
+
+ /**
+ * @return Collection of currently restarting caches.
+ */
+ Collection<String> restartingCaches() {
+ return restartingCaches;
+ }
+
+ /**
* @return Discovery date sent on local node join.
*/
private Serializable joinDiscoveryData() {
@@ -759,10 +784,13 @@ class ClusterCachesInfo {
templates.put(desc.cacheName(), cacheData);
}
+ Collection<String> restarting = new HashSet<>(restartingCaches);
+
return new CacheNodeCommonDiscoveryData(caches,
templates,
cacheGrps,
- ctx.discovery().clientNodesMap());
+ ctx.discovery().clientNodesMap(),
+ restarting);
}
/**
@@ -1380,7 +1408,7 @@ class ClusterCachesInfo {
/**
*
*/
- static class GridData {
+ private static class GridData {
/** */
private final CacheNodeCommonDiscoveryData gridData;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a19b900/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeActions.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeActions.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeActions.java
index 8282b0c..3c2e47b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeActions.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ExchangeActions.java
@@ -27,6 +27,7 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.CU;
import org.jetbrains.annotations.Nullable;
/**
@@ -134,6 +135,20 @@ public class ExchangeActions {
}
/**
+ * @return {@code True} if starting system caches.
+ */
+ public boolean systemCachesStarting() {
+ if (cachesToStart != null) {
+ for (ActionData data : cachesToStart.values()) {
+ if (CU.isSystemCache(data.request().cacheName()))
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
* @param map Actions map.
* @param ctx Context.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a19b900/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheGateway.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheGateway.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheGateway.java
index 81c7b6b..b9a4b25 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheGateway.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheGateway.java
@@ -304,11 +304,8 @@ public class GridCacheGateway<K, V> {
try {
if (rwLock.writeLock().tryLock(200, TimeUnit.MILLISECONDS))
break;
- else {
+ else
U.sleep(200);
-
- ctx.affinity().cancelFutures();
- }
}
catch (IgniteInterruptedCheckedException | InterruptedException ignore) {
interrupted = true;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a19b900/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
index 2053c72..e3b0ebf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePartitionExchangeManager.java
@@ -121,7 +121,7 @@ import static org.apache.ignite.internal.processors.cache.distributed.dht.preloa
public class GridCachePartitionExchangeManager<K, V> extends GridCacheSharedManagerAdapter<K, V> {
/** Exchange history size. */
private static final int EXCHANGE_HISTORY_SIZE =
- IgniteSystemProperties.getInteger("IGNITE_EXCHANGE_HISTORY_SIZE", 1000);
+ IgniteSystemProperties.getInteger(IgniteSystemProperties.IGNITE_EXCHANGE_HISTORY_SIZE, 1000);
/** Atomic reference for pending timeout object. */
private AtomicReference<ResendTimeoutObject> pendingResend = new AtomicReference<>();
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a19b900/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 99daafc..958d9f3 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
@@ -113,7 +113,6 @@ import org.apache.ignite.internal.processors.query.schema.message.SchemaProposeD
import org.apache.ignite.internal.processors.timeout.GridTimeoutObject;
import org.apache.ignite.internal.suggestions.GridPerformanceSuggestions;
import org.apache.ignite.internal.util.F0;
-import org.apache.ignite.internal.util.GridConcurrentHashSet;
import org.apache.ignite.internal.util.future.GridCompoundFuture;
import org.apache.ignite.internal.util.future.GridFinishedFuture;
import org.apache.ignite.internal.util.future.GridFutureAdapter;
@@ -171,7 +170,7 @@ import static org.apache.ignite.internal.processors.cache.GridCacheUtils.isNearE
@SuppressWarnings({"unchecked", "TypeMayBeWeakened", "deprecation"})
public class GridCacheProcessor extends GridProcessorAdapter {
/** */
- private final boolean START_CLIENT_CACHES =
+ private final boolean startClientCaches =
IgniteSystemProperties.getBoolean(IgniteSystemProperties.IGNITE_START_CACHES_ON_JOIN, false);
/** Shared cache context. */
@@ -204,9 +203,6 @@ public class GridCacheProcessor extends GridProcessorAdapter {
/** */
private ClusterCachesInfo cachesInfo;
- /** Restarting caches */
- private final Set<String> restartingCaches = new GridConcurrentHashSet<>();
-
/** */
private IdentityHashMap<CacheStore, ThreadLocal> sesHolders = new IdentityHashMap<>();
@@ -927,6 +923,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
}
});
+ // Avoid iterator creation.
+ //noinspection ForLoopReplaceableByForEach
for (int i = 0, size = syncFuts.size(); i < size; i++)
syncFuts.get(i).get();
@@ -2117,7 +2115,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
}
}
- if (exchActions != null && exchActions.systemCacheStarting())
+ if (exchActions != null && exchActions.systemCachesStarting())
ctx.dataStructures().restoreStructuresState(ctx);
if (exchActions != null && (err == null || forceClose)) {
@@ -2327,7 +2325,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
* @return {@code True} if need locally start all existing caches on client node start.
*/
private boolean startAllCachesOnClientStart() {
- return START_CLIENT_CACHES && ctx.clientNode();
+ return startClientCaches && ctx.clientNode();
}
/** {@inheritDoc} */
@@ -2463,10 +2461,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
private CacheConfiguration getOrCreateConfigFromTemplate(String cacheName) throws IgniteCheckedException {
CacheConfiguration cfg = getConfigFromTemplate(cacheName);
- if (cfg != null)
- return cfg;
- else
- return new CacheConfiguration(cacheName);
+ return cfg != null ? cfg : new CacheConfiguration(cacheName);
}
/**
@@ -3004,7 +2999,27 @@ public class GridCacheProcessor extends GridProcessorAdapter {
/** {@inheritDoc} */
@Nullable @Override public IgniteNodeValidationResult validateNode(ClusterNode node) {
- return validateHashIdResolvers(node);
+ IgniteNodeValidationResult res = validateHashIdResolvers(node);
+
+ if (res == null)
+ res = validateRestartingCaches(node);
+
+ return res;
+ }
+
+ /**
+ * @param node Joining node to validate.
+ * @return Node validation result if there was an issue with the joining node, {@code null} otherwise.
+ */
+ private IgniteNodeValidationResult validateRestartingCaches(ClusterNode node) {
+ if (cachesInfo.hasRestartingCaches()) {
+ String msg = "Joining node during caches restart is not allowed [joiningNodeId=" + node.id() +
+ ", restartingCaches=" + new HashSet<String>(cachesInfo.restartingCaches()) + ']';
+
+ return new IgniteNodeValidationResult(node.id(), msg, msg);
+ }
+
+ return null;
}
/**
@@ -3013,12 +3028,6 @@ public class GridCacheProcessor extends GridProcessorAdapter {
*/
@Nullable private IgniteNodeValidationResult validateHashIdResolvers(ClusterNode node) {
if (!node.isClient()) {
- if (restartingCaches.size() > 0) {
- String msg = "Joining server node during cache restarting is not allowed";
-
- return new IgniteNodeValidationResult(node.id(), msg, msg);
- }
-
for (DynamicCacheDescriptor desc : cacheDescriptors().values()) {
CacheConfiguration cfg = desc.cacheConfiguration();
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a19b900/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
index d8c4018..fa5a092 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtPartitionTopologyImpl.java
@@ -156,8 +156,6 @@ public class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
timeLog = ctx.logger(GridDhtPartitionsExchangeFuture.EXCHANGE_LOG);
locParts = new AtomicReferenceArray<>(grp.affinityFunction().partitions());
-
- part2node = new HashMap<>(grp.affinityFunction().partitions(), 1.0f);
}
/** {@inheritDoc} */
@@ -1138,10 +1136,10 @@ public class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
node2part = partMap;
- AffinityTopologyVersion affVer = ctx.affinity().affinityTopologyVersion();
+ AffinityTopologyVersion affVer = grp.affinity().lastVersion();
if (diffFromAffinityVer.compareTo(affVer) <= 0) {
- AffinityAssignment affAssignment = ctx.affinity().assignment(affVer);
+ AffinityAssignment affAssignment = grp.affinity().cachedAffinity(affVer);
for (Map.Entry<UUID, GridDhtPartitionMap> e : partMap.entrySet()) {
for (Map.Entry<Integer, GridDhtPartitionState> e0 : e.getValue().entrySet()) {
@@ -1370,7 +1368,7 @@ public class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
AffinityTopologyVersion affVer = grp.affinity().lastVersion();
if (affVer.compareTo(diffFromAffinityVer) >= 0) {
- AffinityAssignment affAssignment = grp.affinity().assignment(affVer);
+ AffinityAssignment affAssignment = grp.affinity().cachedAffinity(affVer);
// Add new mappings.
for (Map.Entry<Integer, GridDhtPartitionState> e : parts.entrySet()) {
@@ -1460,7 +1458,8 @@ public class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
return;
if (FAST_DIFF_REBUILD) {
- Collection<UUID> affNodes = F.nodeIds(ctx.discovery().cacheAffinityNodes(cctx.name(), affAssignment.topologyVersion()));
+ Collection<UUID> affNodes = F.nodeIds(ctx.discovery().cacheGroupAffinityNodes(grp.groupId(),
+ affAssignment.topologyVersion()));
for (Map.Entry<Integer, Set<UUID>> e : diffFromAffinity.entrySet()) {
int p = e.getKey();
@@ -1891,17 +1890,17 @@ public class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
map.put(p, state);
if (state == MOVING || state == OWNING) {
- AffinityAssignment assignment = grp.affinity().assignment(diffFromAffinityVer);
+ AffinityAssignment assignment = grp.affinity().cachedAffinity(diffFromAffinityVer);
- if (!assignment.getIds(p).contains(ctx.localNodeId())) {
- Set<UUID> diffIds = diffFromAffinity.get(p);
+ if (!assignment.getIds(p).contains(ctx.localNodeId())) {
+ Set<UUID> diffIds = diffFromAffinity.get(p);
- if (diffIds == null)
- diffFromAffinity.put(p, diffIds = U.newHashSet(3));
+ if (diffIds == null)
+ diffFromAffinity.put(p, diffIds = U.newHashSet(3));
- diffIds.add(ctx.localNodeId());
- }
+ diffIds.add(ctx.localNodeId());
}
+ }
}
return updateSeq;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a19b900/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
index 684ce13..c71c3cc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
@@ -30,7 +30,6 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.cluster.ClusterNode;
import org.apache.ignite.events.DiscoveryEvent;
-import org.apache.ignite.events.Event;
import org.apache.ignite.internal.IgniteFutureTimeoutCheckedException;
import org.apache.ignite.internal.IgniteInternalFuture;
import org.apache.ignite.internal.NodeStoppingException;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1a19b900/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
index bf27e26..551d565 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
@@ -925,7 +925,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
final Set<String> c = new HashSet<>();
c.add("key1");
- c.add(null);
+// c.add(null);
GridTestUtils.assertThrows(log, new Callable<Void>() {
@Override public Void call() throws Exception {