You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by iv...@apache.org on 2015/07/09 12:15:55 UTC
incubator-ignite git commit: #ignite-1109: fix compatibility suite.
Repository: incubator-ignite
Updated Branches:
refs/heads/ignite-1109 e32ac42bf -> e2e3c7f08
#ignite-1109: fix compatibility suite.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/e2e3c7f0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/e2e3c7f0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/e2e3c7f0
Branch: refs/heads/ignite-1109
Commit: e2e3c7f08e21ef91d20b412bf72d4d05abf2e35a
Parents: e32ac42
Author: ivasilinets <iv...@gridgain.com>
Authored: Thu Jul 9 13:15:35 2015 +0300
Committer: ivasilinets <iv...@gridgain.com>
Committed: Thu Jul 9 13:15:35 2015 +0300
----------------------------------------------------------------------
.../AffinityNodeAddressHashResolver.java | 1 +
.../affinity/AffinityNodeIdHashResolver.java | 1 +
.../processors/cache/GridCacheProcessor.java | 75 +++++++++++++-------
3 files changed, 53 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2e3c7f0/modules/core/src/main/java/org/apache/ignite/cache/affinity/AffinityNodeAddressHashResolver.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/affinity/AffinityNodeAddressHashResolver.java b/modules/core/src/main/java/org/apache/ignite/cache/affinity/AffinityNodeAddressHashResolver.java
index 7ce49ec..723693e 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/affinity/AffinityNodeAddressHashResolver.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/affinity/AffinityNodeAddressHashResolver.java
@@ -23,6 +23,7 @@ import org.apache.ignite.internal.util.typedef.internal.*;
/**
* Node hash resolver which uses {@link org.apache.ignite.cluster.ClusterNode#consistentId()} as alternate hash value.
*/
+@Deprecated
public class AffinityNodeAddressHashResolver implements AffinityNodeHashResolver {
/** */
private static final long serialVersionUID = 0L;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2e3c7f0/modules/core/src/main/java/org/apache/ignite/cache/affinity/AffinityNodeIdHashResolver.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/affinity/AffinityNodeIdHashResolver.java b/modules/core/src/main/java/org/apache/ignite/cache/affinity/AffinityNodeIdHashResolver.java
index 65c6f13..5729b67 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/affinity/AffinityNodeIdHashResolver.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/affinity/AffinityNodeIdHashResolver.java
@@ -24,6 +24,7 @@ import org.apache.ignite.internal.util.typedef.internal.*;
* Node hash resolver which uses generated node ID as node hash value. As new node ID is generated
* on each node start, this resolver do not provide ability to map keys to the same nodes after restart.
*/
+@Deprecated
public class AffinityNodeIdHashResolver implements AffinityNodeHashResolver {
/** */
private static final long serialVersionUID = 0L;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e2e3c7f0/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 485e060..3ff682e 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
@@ -141,11 +141,13 @@ public class GridCacheProcessor extends GridProcessorAdapter {
}
/**
+ * @param internalCache Internal cache flag.
* @param cfg Initializes cache configuration with proper defaults.
* @param cacheObjCtx Cache object context.
* @throws IgniteCheckedException If configuration is not valid.
*/
- private void initialize(CacheConfiguration cfg, CacheObjectContext cacheObjCtx) throws IgniteCheckedException {
+ private void initialize(boolean internalCache, CacheConfiguration cfg, CacheObjectContext cacheObjCtx)
+ throws IgniteCheckedException {
if (cfg.getCacheMode() == null)
cfg.setCacheMode(DFLT_CACHE_MODE);
@@ -159,11 +161,17 @@ public class GridCacheProcessor extends GridProcessorAdapter {
if (cfg.getCacheMode() == PARTITIONED) {
RendezvousAffinityFunction aff = new RendezvousAffinityFunction();
+ if (internalCache)
+ aff.setHashIdResolver(new AffinityNodeAddressHashResolver());
+
cfg.setAffinity(aff);
}
else if (cfg.getCacheMode() == REPLICATED) {
RendezvousAffinityFunction aff = new RendezvousAffinityFunction(false, 512);
+ if (internalCache)
+ aff.setHashIdResolver(new AffinityNodeAddressHashResolver());
+
cfg.setAffinity(aff);
cfg.setBackups(Integer.MAX_VALUE);
@@ -171,6 +179,16 @@ public class GridCacheProcessor extends GridProcessorAdapter {
else
cfg.setAffinity(new LocalAffinityFunction());
}
+ else {
+ if (cfg.getCacheMode() == PARTITIONED) {
+ if (cfg.getAffinity() instanceof RendezvousAffinityFunction) {
+ RendezvousAffinityFunction aff = (RendezvousAffinityFunction)cfg.getAffinity();
+
+ if (internalCache && aff.getHashIdResolver() == null)
+ aff.setHashIdResolver(new AffinityNodeAddressHashResolver());
+ }
+ }
+ }
if (cfg.getCacheMode() == REPLICATED)
cfg.setBackups(Integer.MAX_VALUE);
@@ -534,27 +552,12 @@ public class GridCacheProcessor extends GridProcessorAdapter {
ctx.discovery().setCustomEventListener(DynamicCacheChangeBatch.class,
new CustomEventListener<DynamicCacheChangeBatch>() {
- @Override public void onCustomEvent(ClusterNode snd, DynamicCacheChangeBatch msg) {
- onCacheChangeRequested(msg);
- }
- });
-
- // Internal caches which should not be returned to user.
- Set<String> internalCaches = new HashSet<>();
-
- FileSystemConfiguration[] igfsCfgs = ctx.grid().configuration().getFileSystemConfiguration();
-
- if (igfsCfgs != null) {
- for (FileSystemConfiguration igfsCfg : igfsCfgs) {
- internalCaches.add(maskNull(igfsCfg.getMetaCacheName()));
- internalCaches.add(maskNull(igfsCfg.getDataCacheName()));
- }
- }
-
- if (IgniteComponentType.HADOOP.inClassPath())
- internalCaches.add(CU.SYS_CACHE_HADOOP_MR);
+ @Override public void onCustomEvent(ClusterNode snd, DynamicCacheChangeBatch msg) {
+ onCacheChangeRequested(msg);
+ }
+ });
- internalCaches.add(CU.ATOMICS_CACHE_NAME);
+ Set<String> internalCaches = internalCachesNames();
CacheConfiguration[] cfgs = ctx.config().getCacheConfiguration();
@@ -572,7 +575,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
CacheObjectContext cacheObjCtx = ctx.cacheObjects().contextForCache(cfg);
// Initialize defaults.
- initialize(cfg, cacheObjCtx);
+ initialize(internalCaches.contains(maskNull(cfg.getName())), cfg, cacheObjCtx);
cfgs[i] = cfg; // Replace original configuration value.
@@ -654,6 +657,30 @@ public class GridCacheProcessor extends GridProcessorAdapter {
log.debug("Started cache processor.");
}
+ /**
+ * @return Internal caches names.
+ */
+ private Set<String> internalCachesNames() {
+ // Internal caches which should not be returned to user.
+ Set<String> internalCaches = new HashSet<>();
+
+ FileSystemConfiguration[] igfsCfgs = ctx.grid().configuration().getFileSystemConfiguration();
+
+ if (igfsCfgs != null) {
+ for (FileSystemConfiguration igfsCfg : igfsCfgs) {
+ internalCaches.add(maskNull(igfsCfg.getMetaCacheName()));
+ internalCaches.add(maskNull(igfsCfg.getDataCacheName()));
+ }
+ }
+
+ if (IgniteComponentType.HADOOP.inClassPath())
+ internalCaches.add(CU.SYS_CACHE_HADOOP_MR);
+
+ internalCaches.add(CU.ATOMICS_CACHE_NAME);
+
+ return internalCaches;
+ }
+
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override public void onKernalStart() throws IgniteCheckedException {
@@ -663,7 +690,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
if (CU.isMarshallerCache(ccfg.getName())) {
CacheObjectContext cacheObjCtx = ctx.cacheObjects().contextForCache(ccfg);
- initialize(ccfg, cacheObjCtx);
+ initialize(internalCachesNames().contains(maskNull(ccfg.getName())), ccfg, cacheObjCtx);
GridCacheContext ctx = createCache(ccfg, null, CacheType.MARSHALLER, cacheObjCtx, true);
@@ -1955,7 +1982,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
CacheObjectContext cacheObjCtx = ctx.cacheObjects().contextForCache(cfg);
- initialize(cfg, cacheObjCtx);
+ initialize(false, cfg, cacheObjCtx);
req.startCacheConfiguration(cfg);
}