You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/04/09 10:59:05 UTC
[32/50] [abbrv] incubator-ignite git commit: # IGNITE-685 NPE on node
start if client discovery is used.
# IGNITE-685 NPE on node start if client discovery is used.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/654b4e98
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/654b4e98
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/654b4e98
Branch: refs/heads/ignite-sprint-4
Commit: 654b4e98f2f618e4ffffad6486d13f883a1a5d7d
Parents: 0cf79e4
Author: sevdokimov <se...@gridgain.com>
Authored: Wed Apr 8 13:03:01 2015 +0300
Committer: sevdokimov <se...@gridgain.com>
Committed: Wed Apr 8 13:29:06 2015 +0300
----------------------------------------------------------------------
.../org/apache/ignite/internal/IgnitionEx.java | 172 +++++++------------
1 file changed, 65 insertions(+), 107 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/654b4e98/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
index fe81006..a4aea66 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
@@ -1675,23 +1675,32 @@ public class IgnitionEx {
*/
@SuppressWarnings("unchecked")
public void initializeDefaultCacheConfiguration(IgniteConfiguration cfg) throws IgniteCheckedException {
- CacheConfiguration[] cacheCfgs = cfg.getCacheConfiguration();
+ List<CacheConfiguration> cacheCfgs = new ArrayList<>();
- final boolean hasHadoop = IgniteComponentType.HADOOP.inClassPath();
+ boolean clientDisco = cfg.getDiscoverySpi() instanceof TcpClientDiscoverySpi;
- final boolean hasAtomics = cfg.getAtomicConfiguration() != null;
+ // Add marshaller and utility caches.
+ if (!clientDisco) {
+ cacheCfgs.add(marshallerSystemCache());
- final boolean clientDisco = cfg.getDiscoverySpi() instanceof TcpClientDiscoverySpi;
+ cacheCfgs.add(utilitySystemCache());
+ }
+
+ if (IgniteComponentType.HADOOP.inClassPath())
+ cacheCfgs.add(CU.hadoopSystemCache());
- CacheConfiguration[] copies;
+ if (cfg.getAtomicConfiguration() != null && !clientDisco)
+ cacheCfgs.add(atomicsSystemCache(cfg.getAtomicConfiguration()));
- if (cacheCfgs != null && cacheCfgs.length > 0) {
+ CacheConfiguration[] userCaches = cfg.getCacheConfiguration();
+
+ if (userCaches != null && userCaches.length > 0) {
if (!U.discoOrdered(cfg.getDiscoverySpi()) && !U.relaxDiscoveryOrdered())
throw new IgniteCheckedException("Discovery SPI implementation does not support node ordering and " +
"cannot be used with cache (use SPI with @GridDiscoverySpiOrderSupport annotation, " +
"like GridTcpDiscoverySpi)");
- for (CacheConfiguration ccfg : cacheCfgs) {
+ for (CacheConfiguration ccfg : userCaches) {
if (CU.isHadoopSystemCache(ccfg.getName()))
throw new IgniteCheckedException("Cache name cannot be \"" + CU.SYS_CACHE_HADOOP_MR +
"\" because it is reserved for internal purposes.");
@@ -1709,52 +1718,15 @@ public class IgnitionEx {
"\" because it is reserved for internal purposes.");
}
- int addCacheCnt = 2; // Always add marshaller and utility caches.
-
- if (hasHadoop)
- addCacheCnt++;
-
- if (hasAtomics)
- addCacheCnt++;
-
- copies = new CacheConfiguration[cacheCfgs.length + addCacheCnt];
-
- int cloneIdx = 2;
-
- if (hasHadoop)
- copies[cloneIdx++] = CU.hadoopSystemCache();
-
- if (hasAtomics)
- copies[cloneIdx++] = atomicsSystemCache(cfg.getAtomicConfiguration(), clientDisco);
-
- for (CacheConfiguration ccfg : cacheCfgs)
- copies[cloneIdx++] = new CacheConfiguration(ccfg);
- }
- else {
- int cacheCnt = 2; // Always add marshaller and utility caches.
-
- if (hasHadoop)
- cacheCnt++;
-
- if (hasAtomics)
- cacheCnt++;
+ for (CacheConfiguration ccfg : userCaches) {
+ if (ccfg == null)
+ throw new NullPointerException("Cache configuration list must not contains null element");
- copies = new CacheConfiguration[cacheCnt];
-
- int cacheIdx = 2;
-
- if (hasHadoop)
- copies[cacheIdx++] = CU.hadoopSystemCache();
-
- if (hasAtomics)
- copies[cacheIdx] = atomicsSystemCache(cfg.getAtomicConfiguration(), clientDisco);
+ cacheCfgs.add(ccfg);
+ }
}
- // Always add marshaller and utility caches.
- copies[0] = marshallerSystemCache(clientDisco);
- copies[1] = utilitySystemCache(clientDisco);
-
- cfg.setCacheConfiguration(copies);
+ cfg.setCacheConfiguration(cacheCfgs.toArray(new CacheConfiguration[cacheCfgs.size()]));
}
/**
@@ -1899,78 +1871,64 @@ public class IgnitionEx {
*
* @return Marshaller system cache configuration.
*/
- private static CacheConfiguration marshallerSystemCache(boolean client) {
- if (!client) {
- CacheConfiguration cache = new CacheConfiguration();
-
- cache.setName(CU.MARSH_CACHE_NAME);
- cache.setCacheMode(REPLICATED);
- cache.setAtomicityMode(ATOMIC);
- cache.setSwapEnabled(false);
- cache.setRebalanceMode(SYNC);
- cache.setWriteSynchronizationMode(FULL_SYNC);
- cache.setAffinity(new RendezvousAffinityFunction(false, 20));
- cache.setNodeFilter(CacheConfiguration.ALL_NODES);
- cache.setStartSize(300);
-
- return cache;
- }
-
- return null;
+ private static CacheConfiguration marshallerSystemCache() {
+ CacheConfiguration cache = new CacheConfiguration();
+
+ cache.setName(CU.MARSH_CACHE_NAME);
+ cache.setCacheMode(REPLICATED);
+ cache.setAtomicityMode(ATOMIC);
+ cache.setSwapEnabled(false);
+ cache.setRebalanceMode(SYNC);
+ cache.setWriteSynchronizationMode(FULL_SYNC);
+ cache.setAffinity(new RendezvousAffinityFunction(false, 20));
+ cache.setNodeFilter(CacheConfiguration.ALL_NODES);
+ cache.setStartSize(300);
+
+ return cache;
}
/**
* Creates utility system cache configuration.
*
- * @param client If {@code true} creates client-only cache configuration.
* @return Utility system cache configuration.
*/
- private static CacheConfiguration utilitySystemCache(boolean client) {
- if (!client) {
- CacheConfiguration cache = new CacheConfiguration();
-
- cache.setName(CU.UTILITY_CACHE_NAME);
- cache.setCacheMode(REPLICATED);
- cache.setAtomicityMode(TRANSACTIONAL);
- cache.setSwapEnabled(false);
- cache.setRebalanceMode(SYNC);
- cache.setWriteSynchronizationMode(FULL_SYNC);
- cache.setAffinity(new RendezvousAffinityFunction(false, 100));
- cache.setNodeFilter(CacheConfiguration.ALL_NODES);
-
- return cache;
- }
-
- return null;
+ private static CacheConfiguration utilitySystemCache() {
+ CacheConfiguration cache = new CacheConfiguration();
+
+ cache.setName(CU.UTILITY_CACHE_NAME);
+ cache.setCacheMode(REPLICATED);
+ cache.setAtomicityMode(TRANSACTIONAL);
+ cache.setSwapEnabled(false);
+ cache.setRebalanceMode(SYNC);
+ cache.setWriteSynchronizationMode(FULL_SYNC);
+ cache.setAffinity(new RendezvousAffinityFunction(false, 100));
+ cache.setNodeFilter(CacheConfiguration.ALL_NODES);
+
+ return cache;
}
/**
* Creates cache configuration for atomic data structures.
*
* @param cfg Atomic configuration.
- * @param client If {@code true} creates client-only cache configuration.
* @return Cache configuration for atomic data structures.
*/
- private static CacheConfiguration atomicsSystemCache(AtomicConfiguration cfg, boolean client) {
- if (!client) {
- CacheConfiguration ccfg = new CacheConfiguration();
-
- ccfg.setName(CU.ATOMICS_CACHE_NAME);
- ccfg.setAtomicityMode(TRANSACTIONAL);
- ccfg.setSwapEnabled(false);
- ccfg.setRebalanceMode(SYNC);
- ccfg.setWriteSynchronizationMode(FULL_SYNC);
- ccfg.setCacheMode(cfg.getCacheMode());
- ccfg.setNodeFilter(CacheConfiguration.ALL_NODES);
- ccfg.setNearConfiguration(new NearCacheConfiguration());
-
- if (cfg.getCacheMode() == PARTITIONED)
- ccfg.setBackups(cfg.getBackups());
-
- return ccfg;
- }
-
- return null;
+ private static CacheConfiguration atomicsSystemCache(AtomicConfiguration cfg) {
+ CacheConfiguration ccfg = new CacheConfiguration();
+
+ ccfg.setName(CU.ATOMICS_CACHE_NAME);
+ ccfg.setAtomicityMode(TRANSACTIONAL);
+ ccfg.setSwapEnabled(false);
+ ccfg.setRebalanceMode(SYNC);
+ ccfg.setWriteSynchronizationMode(FULL_SYNC);
+ ccfg.setCacheMode(cfg.getCacheMode());
+ ccfg.setNodeFilter(CacheConfiguration.ALL_NODES);
+ ccfg.setNearConfiguration(new NearCacheConfiguration());
+
+ if (cfg.getCacheMode() == PARTITIONED)
+ ccfg.setBackups(cfg.getBackups());
+
+ return ccfg;
}
/**