You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ak...@apache.org on 2015/04/06 17:43:44 UTC
[04/29] incubator-ignite git commit: # ignite-668
# ignite-668
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/cd7f1a90
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/cd7f1a90
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/cd7f1a90
Branch: refs/heads/ignite-593
Commit: cd7f1a9003b76081f706faa6050f1af80ea70dc2
Parents: 6c3f101
Author: sboikov <sb...@gridgain.com>
Authored: Fri Apr 3 11:35:11 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Fri Apr 3 12:38:28 2015 +0300
----------------------------------------------------------------------
.../internal/processors/cache/CacheType.java | 77 ++++++++++
.../cache/DynamicCacheChangeRequest.java | 17 +++
.../cache/DynamicCacheDescriptor.java | 15 +-
.../processors/cache/GridCacheAdapter.java | 6 +-
.../processors/cache/GridCacheContext.java | 26 ++--
.../cache/GridCacheDeploymentManager.java | 2 +-
.../processors/cache/GridCacheEventManager.java | 4 +-
.../processors/cache/GridCacheProcessor.java | 127 +++++++++++------
.../cache/GridCacheSharedContext.java | 4 +-
.../dht/GridDhtTransactionalCacheAdapter.java | 4 +-
.../near/GridNearTransactionalCache.java | 2 +-
.../continuous/CacheContinuousQueryManager.java | 2 +-
.../transactions/IgniteTransactionsImpl.java | 19 ++-
.../transactions/IgniteTxLocalAdapter.java | 2 +-
.../cache/transactions/IgniteTxManager.java | 8 +-
.../cache/IgniteDynamicCacheStartSelfTest.java | 47 +++----
.../cache/IgniteInternalCacheTypesTest.java | 132 +++++++++++++++++
.../IgniteCacheSystemTransactionsSelfTest.java | 3 +-
.../processors/igfs/IgfsStartCacheTest.java | 140 +++++++++++++++++++
.../processors/igfs/IgsfStartCacheTest.java | 115 ---------------
.../loadtests/hashmap/GridCacheTestContext.java | 1 +
.../ignite/testsuites/IgniteCacheTestSuite.java | 2 +
.../ignite/testsuites/IgniteIgfsTestSuite.java | 2 +
23 files changed, 544 insertions(+), 213 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd7f1a90/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheType.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheType.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheType.java
new file mode 100644
index 0000000..e0747b9
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheType.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import org.apache.ignite.internal.managers.communication.*;
+
+import static org.apache.ignite.internal.managers.communication.GridIoPolicy.*;
+
+/**
+ *
+ */
+public enum CacheType {
+ /**
+ * Regular cache created by user, visible via public API (e.g. {@link org.apache.ignite.Ignite#cache(String)}).
+ */
+ USER(true, SYSTEM_POOL),
+
+ /**
+ * Internal cache, should not be visible via public API (caches used by IGFS, Hadoop, data structures).
+ */
+ INTERNAL(false, SYSTEM_POOL),
+
+ /**
+ * Internal replicated cache, should use separate thread pool.
+ */
+ UTILITY(false, UTILITY_CACHE_POOL),
+
+ /**
+ * Internal marshaller cache, should use separate thread pool.
+ */
+ MARSHALLER(false, MARSH_CACHE_POOL);
+
+ /** */
+ private final boolean userCache;
+
+ /** */
+ private final GridIoPolicy ioPlc;
+
+ /**
+ * @param userCache {@code True} if cache created by user.
+ * @param ioPlc Cache IO policy.
+ */
+ CacheType(boolean userCache, GridIoPolicy ioPlc) {
+ this.userCache = userCache;
+ this.ioPlc = ioPlc;
+ }
+
+ /**
+ * @return Cache IO policy.
+ */
+ public GridIoPolicy ioPolicy() {
+ return ioPlc;
+ }
+
+ /**
+ * @return {@code True} if cache created by user.
+ */
+ public boolean userCache() {
+ return userCache;
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd7f1a90/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java
index 830078c..f7c8769 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheChangeRequest.java
@@ -42,6 +42,9 @@ public class DynamicCacheChangeRequest implements Serializable {
/** Cache start configuration. */
private CacheConfiguration startCfg;
+ /** Cache type. */
+ private CacheType cacheType;
+
/** Near node ID in case if near cache is being started. */
private UUID initiatingNodeId;
@@ -159,6 +162,20 @@ public class DynamicCacheChangeRequest implements Serializable {
}
/**
+ * @param cacheType Cache type.
+ */
+ public void cacheType(CacheType cacheType) {
+ this.cacheType = cacheType;
+ }
+
+ /**
+ * @return Cache type.
+ */
+ public CacheType cacheType() {
+ return cacheType;
+ }
+
+ /**
* @return Client start only.
*/
public boolean clientStartOnly() {
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd7f1a90/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java
index 8c9ed16..4f07658 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/DynamicCacheDescriptor.java
@@ -47,18 +47,31 @@ public class DynamicCacheDescriptor {
/** Started flag. */
private boolean started;
+ /** Cache type. */
+ private CacheType cacheType;
+
/** */
private volatile Map<UUID, CacheConfiguration> rmtCfgs;
/**
* @param cacheCfg Cache configuration.
+ * @param cacheType Cache type.
+ * @param deploymentId Deployment ID.
*/
- public DynamicCacheDescriptor(CacheConfiguration cacheCfg, IgniteUuid deploymentId) {
+ public DynamicCacheDescriptor(CacheConfiguration cacheCfg, CacheType cacheType, IgniteUuid deploymentId) {
this.cacheCfg = cacheCfg;
+ this.cacheType = cacheType;
this.deploymentId = deploymentId;
}
/**
+ * @return Cache type.
+ */
+ public CacheType cacheType() {
+ return cacheType;
+ }
+
+ /**
* @return Start ID.
*/
public IgniteUuid deploymentId() {
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd7f1a90/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 64d8794..d6da425 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -2015,7 +2015,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>,
return new GridFinishedFuture<>(e);
}
- tx = ctx.tm().threadLocalTx(ctx.system() ? ctx : null);
+ tx = ctx.tm().threadLocalTx(ctx.systemTx() ? ctx : null);
}
if (tx == null || tx.implicit()) {
@@ -4368,7 +4368,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>,
tx = ctx.tm().newTx(
true,
op.single(),
- ctx.system() ? ctx : null,
+ ctx.systemTx() ? ctx : null,
OPTIMISTIC,
READ_COMMITTED,
tCfg.getDefaultTxTimeout(),
@@ -4439,7 +4439,7 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K, V>,
tx = ctx.tm().newTx(
true,
op.single(),
- ctx.system() ? ctx : null,
+ ctx.systemTx() ? ctx : null,
OPTIMISTIC,
READ_COMMITTED,
ctx.kernalContext().config().getTransactionConfiguration().getDefaultTxTimeout(),
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd7f1a90/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
index dfa82e6..748a3a1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
@@ -166,8 +166,8 @@ public class GridCacheContext<K, V> implements Externalizable {
/** Cache ID. */
private int cacheId;
- /** System cache flag. */
- private boolean sys;
+ /** Cache type. */
+ private CacheType cacheType;
/** IO policy. */
private GridIoPolicy plc;
@@ -207,6 +207,8 @@ public class GridCacheContext<K, V> implements Externalizable {
* @param ctx Kernal context.
* @param sharedCtx Cache shared context.
* @param cacheCfg Cache configuration.
+ * @param cacheType Cache type.
+ * @param affNode {@code True} if local node is affinity node.
* @param evtMgr Cache event manager.
* @param swapMgr Cache swap manager.
* @param storeMgr Store manager.
@@ -218,6 +220,7 @@ public class GridCacheContext<K, V> implements Externalizable {
* @param ttlMgr TTL manager.
* @param drMgr Data center replication manager.
* @param jtaMgr JTA manager.
+ * @param rslvrMgr Conflict resolution manager.
* @param pluginMgr Cache plugin manager.
*/
@SuppressWarnings({"unchecked"})
@@ -225,6 +228,7 @@ public class GridCacheContext<K, V> implements Externalizable {
GridKernalContext ctx,
GridCacheSharedContext sharedCtx,
CacheConfiguration cacheCfg,
+ CacheType cacheType,
boolean affNode,
/*
@@ -265,6 +269,7 @@ public class GridCacheContext<K, V> implements Externalizable {
this.ctx = ctx;
this.sharedCtx = sharedCtx;
this.cacheCfg = cacheCfg;
+ this.cacheType = cacheType;
this.affNode = affNode;
/*
@@ -297,9 +302,7 @@ public class GridCacheContext<K, V> implements Externalizable {
cacheId = CU.cacheId(cacheName);
- sys = ctx.cache().systemCache(cacheName);
-
- plc = CU.isMarshallerCache(cacheName) ? MARSH_CACHE_POOL : sys ? UTILITY_CACHE_POOL : SYSTEM_POOL;
+ plc = cacheType.ioPolicy();
Factory<ExpiryPolicy> factory = cacheCfg.getExpiryPolicyFactory();
@@ -434,10 +437,17 @@ public class GridCacheContext<K, V> implements Externalizable {
}
/**
- * @return System cache flag.
+ * @return {@code True} if should use system transactions which are isolated from user transactions.
+ */
+ public boolean systemTx() {
+ return cacheType == CacheType.UTILITY;
+ }
+
+ /**
+ * @return {@code True} if cache created by user.
*/
- public boolean system() {
- return sys;
+ public boolean userCache() {
+ return cacheType.userCache();
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd7f1a90/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java
index ee17893..eb3c5e3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java
@@ -256,7 +256,7 @@ public class GridCacheDeploymentManager<K, V> extends GridCacheSharedManagerAdap
cacheCtx.near().dht().context().swap().onUndeploy(ldr) :
cacheCtx.swap().onUndeploy(ldr);
- if (!cacheCtx.system()) {
+ if (cacheCtx.userCache()) {
U.quietAndWarn(log, "");
U.quietAndWarn(
log,
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd7f1a90/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java
index f543e3b..f56566e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEventManager.java
@@ -339,9 +339,7 @@ public class GridCacheEventManager extends GridCacheManagerAdapter {
* @return {@code True} if event is recordable.
*/
public boolean isRecordable(int type) {
- return !cctx.system() &&
- !CU.isAtomicsCache(cctx.name()) &&
- cctx.gridEvents().isRecordable(type);
+ return cctx.userCache() && cctx.gridEvents().isRecordable(type);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd7f1a90/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 c366520..1d04fd2 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
@@ -100,9 +100,6 @@ public class GridCacheProcessor extends GridProcessorAdapter {
/** Maximum detected rebalance order. */
private int maxRebalanceOrder;
- /** System cache names. */
- private final Set<String> sysCaches;
-
/** Caches stop sequence. */
private final Deque<String> stopSeq;
@@ -131,15 +128,14 @@ public class GridCacheProcessor extends GridProcessorAdapter {
jCacheProxies = new ConcurrentHashMap<>();
preloadFuts = new TreeMap<>();
- sysCaches = new HashSet<>();
stopSeq = new LinkedList<>();
}
/**
* @param cfg Initializes cache configuration with proper defaults.
+ * @param cacheObjCtx Cache object context.
* @throws IgniteCheckedException If configuration is not valid.
*/
- @SuppressWarnings("unchecked")
private void initialize(CacheConfiguration cfg, CacheObjectContext cacheObjCtx) throws IgniteCheckedException {
if (cfg.getCacheMode() == null)
cfg.setCacheMode(DFLT_CACHE_MODE);
@@ -275,13 +271,15 @@ public class GridCacheProcessor extends GridProcessorAdapter {
}
/**
- * @param c Grid configuration.
+ * @param c Ignite configuration.
* @param cc Configuration to validate.
+ * @param cacheType Cache type.
* @param cfgStore Cache store.
* @throws IgniteCheckedException If failed.
*/
private void validate(IgniteConfiguration c,
CacheConfiguration cc,
+ CacheType cacheType,
@Nullable CacheStore cfgStore) throws IgniteCheckedException {
if (cc.getCacheMode() == REPLICATED) {
if (cc.getAffinity() instanceof FairAffinityFunction)
@@ -399,7 +397,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
}
case ONHEAP_TIERED:
- if (!systemCache(cc.getName()) && cc.getEvictionPolicy() == null && cc.getOffHeapMaxMemory() >= 0)
+ if (cacheType.userCache() && cc.getEvictionPolicy() == null && cc.getOffHeapMaxMemory() >= 0)
U.quietAndWarn(log, "Eviction policy not enabled with ONHEAP_TIERED mode for cache " +
"(entries will not be moved to off-heap store): " + U.maskName(cc.getName()));
@@ -542,21 +540,21 @@ public class GridCacheProcessor extends GridProcessorAdapter {
});
// 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) {
- sysCaches.add(maskNull(igfsCfg.getMetaCacheName()));
- sysCaches.add(maskNull(igfsCfg.getDataCacheName()));
+ internalCaches.add(maskNull(igfsCfg.getMetaCacheName()));
+ internalCaches.add(maskNull(igfsCfg.getDataCacheName()));
}
}
if (IgniteComponentType.HADOOP.inClassPath())
- sysCaches.add(CU.SYS_CACHE_HADOOP_MR);
+ internalCaches.add(CU.SYS_CACHE_HADOOP_MR);
- sysCaches.add(CU.MARSH_CACHE_NAME);
- sysCaches.add(CU.UTILITY_CACHE_NAME);
- sysCaches.add(CU.ATOMICS_CACHE_NAME);
+ internalCaches.add(CU.ATOMICS_CACHE_NAME);
CacheConfiguration[] cfgs = ctx.config().getCacheConfiguration();
@@ -590,7 +588,18 @@ public class GridCacheProcessor extends GridProcessorAdapter {
"assign unique name to each cache).");
}
- DynamicCacheDescriptor desc = new DynamicCacheDescriptor(cfg, IgniteUuid.randomUuid());
+ CacheType cacheType;
+
+ if (CU.isUtilityCache(cfg.getName()))
+ cacheType = CacheType.UTILITY;
+ else if (CU.isMarshallerCache(cfg.getName()))
+ cacheType = CacheType.MARSHALLER;
+ else if (internalCaches.contains(maskNull(cfg.getName())))
+ cacheType = CacheType.INTERNAL;
+ else
+ cacheType = CacheType.USER;
+
+ DynamicCacheDescriptor desc = new DynamicCacheDescriptor(cfg, cacheType, IgniteUuid.randomUuid());
desc.locallyConfigured(true);
desc.staticallyConfigured(true);
@@ -603,7 +612,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
cfg.getNearConfiguration() != null,
cfg.getCacheMode() == LOCAL);
- if (sysCaches.contains(maskNull(cfg.getName())))
+ if (!cacheType.userCache())
stopSeq.addLast(cfg.getName());
else
stopSeq.addFirst(cfg.getName());
@@ -661,7 +670,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
if (filter.apply(locNode)) {
CacheObjectContext cacheObjCtx = ctx.cacheObjects().contextForCache(null, ccfg.getName(), ccfg);
- GridCacheContext ctx = createCache(ccfg, cacheObjCtx);
+ GridCacheContext ctx = createCache(ccfg, desc.cacheType(), cacheObjCtx);
ctx.dynamicDeploymentId(desc.deploymentId());
@@ -975,23 +984,28 @@ public class GridCacheProcessor extends GridProcessorAdapter {
/**
* @param cfg Cache configuration to use to create cache.
+ * @param cacheType Cache type.
+ * @param cacheObjCtx Cache object context.
* @return Cache context.
* @throws IgniteCheckedException If failed to create cache.
*/
- @SuppressWarnings({"unchecked"})
- private GridCacheContext createCache(CacheConfiguration<?, ?> cfg, CacheObjectContext cacheObjCtx) throws IgniteCheckedException {
+ private GridCacheContext createCache(CacheConfiguration<?, ?> cfg,
+ CacheType cacheType,
+ CacheObjectContext cacheObjCtx)
+ throws IgniteCheckedException
+ {
assert cfg != null;
CacheStore cfgStore = cfg.getCacheStoreFactory() != null ? cfg.getCacheStoreFactory().create() : null;
- validate(ctx.config(), cfg, cfgStore);
+ validate(ctx.config(), cfg, cacheType, cfgStore);
CacheJtaManagerAdapter jta = JTA.create(cfg.getTransactionManagerLookupClassName() == null);
jta.createTmLookup(cfg);
- // Skip suggestions for system caches.
- if (!sysCaches.contains(maskNull(cfg.getName())))
+ // Skip suggestions for internal caches.
+ if (cacheType.userCache())
suggestOptimizations(cfg, cfgStore != null);
Collection<Object> toPrepare = new ArrayList<>();
@@ -1034,6 +1048,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
ctx,
sharedCtx,
cfg,
+ cacheType,
ctx.discovery().cacheAffinityNode(ctx.discovery().localNode(), cfg.getName()),
/*
@@ -1162,6 +1177,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
ctx,
sharedCtx,
cfg,
+ cacheType,
ctx.discovery().cacheAffinityNode(ctx.discovery().localNode(), cfg.getName()),
/*
@@ -1286,6 +1302,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
/**
* @param reqs Requests to start.
+ * @param topVer Topology version.
* @throws IgniteCheckedException If failed to start cache.
*/
@SuppressWarnings("TypeMayBeWeakened")
@@ -1294,11 +1311,13 @@ public class GridCacheProcessor extends GridProcessorAdapter {
AffinityTopologyVersion topVer
) throws IgniteCheckedException {
for (DynamicCacheChangeRequest req : reqs) {
- assert req.start();
+ assert req.start() : req;
+ assert req.cacheType() != null : req.cacheType();
prepareCacheStart(
req.startCacheConfiguration(),
req.nearCacheConfiguration(),
+ req.cacheType(),
req.clientStartOnly(),
req.initiatingNodeId(),
req.deploymentId(),
@@ -1313,6 +1332,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
prepareCacheStart(
desc.cacheConfiguration(),
null,
+ desc.cacheType(),
false,
null,
desc.deploymentId(),
@@ -1326,13 +1346,17 @@ public class GridCacheProcessor extends GridProcessorAdapter {
/**
* @param cfg Start configuration.
* @param nearCfg Near configuration.
+ * @param cacheType Cache type.
* @param clientStartOnly Client only start request.
* @param initiatingNodeId Initiating node ID.
* @param deploymentId Deployment ID.
+ * @param topVer Topology version.
+ * @throws IgniteCheckedException If failed.
*/
private void prepareCacheStart(
CacheConfiguration cfg,
NearCacheConfiguration nearCfg,
+ CacheType cacheType,
boolean clientStartOnly,
UUID initiatingNodeId,
IgniteUuid deploymentId,
@@ -1358,7 +1382,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
CacheObjectContext cacheObjCtx = ctx.cacheObjects().contextForCache(null, ccfg.getName(), ccfg);
- GridCacheContext cacheCtx = createCache(ccfg, cacheObjCtx);
+ GridCacheContext cacheCtx = createCache(ccfg, cacheType, cacheObjCtx);
cacheCtx.startTopologyVersion(topVer);
@@ -1520,6 +1544,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
req.startCacheConfiguration(desc.cacheConfiguration());
+ req.cacheType(desc.cacheType());
+
req.deploymentId(desc.deploymentId());
reqs.add(req);
@@ -1558,8 +1584,11 @@ public class GridCacheProcessor extends GridProcessorAdapter {
}
}
else {
+ assert req.cacheType() != null : req;
+
DynamicCacheDescriptor desc = new DynamicCacheDescriptor(
ccfg,
+ req.cacheType(),
req.deploymentId());
// Received statically configured cache.
@@ -1592,6 +1621,9 @@ public class GridCacheProcessor extends GridProcessorAdapter {
* Dynamically starts cache.
*
* @param ccfg Cache configuration.
+ * @param cacheName Cache name.
+ * @param nearCfg Near cache configuration.
+ * @param failIfExists Fail if exists flag.
* @return Future that will be completed when cache is deployed.
*/
@SuppressWarnings("IfMayBeConditional")
@@ -1650,7 +1682,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
initialize(cfg, cacheObjCtx);
req.startCacheConfiguration(cfg);
- } catch (IgniteCheckedException e) {
+ }
+ catch (IgniteCheckedException e) {
return new GridFinishedFuture(e);
}
}
@@ -1680,6 +1713,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
if (nearCfg != null)
req.nearCacheConfiguration(nearCfg);
+ req.cacheType(CacheType.USER);
+
return F.first(initiateCacheChanges(F.asList(req)));
}
@@ -1700,7 +1735,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
public Collection<DynamicCacheStartFuture> initiateCacheChanges(Collection<DynamicCacheChangeRequest> reqs) {
Collection<DynamicCacheStartFuture> res = new ArrayList<>(reqs.size());
- Collection<DynamicCacheChangeRequest> sendReqs = new ArrayList<>(reqs.size());
+ Collection<DynamicCacheChangeRequest> sndReqs = new ArrayList<>(reqs.size());
for (DynamicCacheChangeRequest req : reqs) {
DynamicCacheStartFuture fut = new DynamicCacheStartFuture(req.cacheName(), req.deploymentId(), req);
@@ -1744,7 +1779,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
if (fut.isDone())
continue;
- sendReqs.add(req);
+ sndReqs.add(req);
}
catch (Exception e) {
fut.onDone(e);
@@ -1754,8 +1789,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
}
}
- if (!sendReqs.isEmpty())
- ctx.discovery().sendCustomEvent(new DynamicCacheChangeBatch(sendReqs));
+ if (!sndReqs.isEmpty())
+ ctx.discovery().sendCustomEvent(new DynamicCacheChangeBatch(sndReqs));
return res;
}
@@ -1801,7 +1836,10 @@ public class GridCacheProcessor extends GridProcessorAdapter {
}
if (!req.clientStartOnly() && desc == null) {
- DynamicCacheDescriptor startDesc = new DynamicCacheDescriptor(ccfg, req.deploymentId());
+ assert req.cacheType() != null : req;
+
+ DynamicCacheDescriptor startDesc =
+ new DynamicCacheDescriptor(ccfg, req.cacheType(), req.deploymentId());
DynamicCacheDescriptor old = registeredCaches.put(maskNull(ccfg.getName()), startDesc);
@@ -1815,7 +1853,9 @@ public class GridCacheProcessor extends GridProcessorAdapter {
ccfg.getCacheMode() == LOCAL);
}
- ctx.discovery().addClientNode(req.cacheName(), req.initiatingNodeId(), req.nearCacheConfiguration() != null);
+ ctx.discovery().addClientNode(req.cacheName(),
+ req.initiatingNodeId(),
+ req.nearCacheConfiguration() != null);
}
else {
if (desc == null) {
@@ -2230,13 +2270,18 @@ public class GridCacheProcessor extends GridProcessorAdapter {
if (log.isDebugEnabled())
log.debug("Getting public cache for name: " + name);
- if (sysCaches.contains(name))
- throw new IllegalStateException("Failed to get cache because it is system cache: " + name);
+ DynamicCacheDescriptor desc = registeredCaches.get(maskNull(name));
+
+ if (desc == null || desc.cancelled())
+ throw new IllegalArgumentException("Cache is not started: " + name);
+
+ if (!desc.cacheType().userCache())
+ throw new IllegalStateException("Failed to get cache because it is a system cache: " + name);
IgniteCacheProxy<K, V> jcache = (IgniteCacheProxy<K, V>)jCacheProxies.get(maskNull(name));
if (jcache == null)
- throw new IllegalArgumentException("Cache is not configured: " + name);
+ throw new IllegalArgumentException("Cache is not started: " + name);
return jcache.legacyProxy();
}
@@ -2252,9 +2297,6 @@ public class GridCacheProcessor extends GridProcessorAdapter {
if (log.isDebugEnabled())
log.debug("Getting public cache for name: " + cacheName);
- if (sysCaches.contains(maskNull(cacheName)))
- throw new IllegalStateException("Failed to get cache because it is a system cache: " + cacheName);
-
try {
String masked = maskNull(cacheName);
@@ -2266,6 +2308,9 @@ public class GridCacheProcessor extends GridProcessorAdapter {
if (desc == null || desc.cancelled())
throw new IllegalArgumentException("Cache is not started: " + cacheName);
+ if (!desc.cacheType().userCache())
+ throw new IllegalStateException("Failed to get cache because it is a system cache: " + cacheName);
+
DynamicCacheChangeRequest req = new DynamicCacheChangeRequest(cacheName, ctx.localNodeId());
req.cacheName(cacheName);
@@ -2278,6 +2323,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
req.startCacheConfiguration(cfg);
+ req.cacheType(desc.cacheType());
+
req.clientStartOnly(true);
F.first(initiateCacheChanges(F.asList(req))).get();
@@ -2316,7 +2363,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
Collection<IgniteCacheProxy<?, ?>> res = new ArrayList<>(jCacheProxies.size());
for (Map.Entry<String, IgniteCacheProxy<?, ?>> entry : jCacheProxies.entrySet()) {
- if (!sysCaches.contains(entry.getKey()))
+ if (entry.getValue().context().userCache())
res.add(entry.getValue());
}
@@ -2366,7 +2413,9 @@ public class GridCacheProcessor extends GridProcessorAdapter {
* @return {@code True} if specified cache is system, {@code false} otherwise.
*/
public boolean systemCache(@Nullable String name) {
- return sysCaches.contains(maskNull(name));
+ DynamicCacheDescriptor desc = registeredCaches.get(maskNull(name));
+
+ return desc != null && !desc.cacheType().userCache();
}
/** {@inheritDoc} */
@@ -2390,7 +2439,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
if (!ctx.isStopping()) {
for (GridCacheAdapter<?, ?> cache : caches.values()) {
// Do not notify system caches.
- if (!cache.context().system() && !CU.isAtomicsCache(cache.context().name()))
+ if (cache.context().userCache())
cache.onUndeploy(ldr);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd7f1a90/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java
index af38faf..12086b9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java
@@ -430,14 +430,14 @@ public class GridCacheSharedContext<K, V> {
* @return {@code True} if cross-cache transaction can include this new cache.
*/
public boolean txCompatible(IgniteInternalTx tx, Iterable<Integer> activeCacheIds, GridCacheContext<K, V> cacheCtx) {
- if (cacheCtx.system() ^ tx.system())
+ if (cacheCtx.systemTx() ^ tx.system())
return false;
for (Integer cacheId : activeCacheIds) {
GridCacheContext<K, V> activeCacheCtx = cacheContext(cacheId);
// System transactions may sap only one cache.
- if (cacheCtx.system()) {
+ if (cacheCtx.systemTx()) {
if (activeCacheCtx.cacheId() != cacheCtx.cacheId())
return false;
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd7f1a90/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
index 737e3ed..017b363 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTransactionalCacheAdapter.java
@@ -196,7 +196,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
req.topologyVersion(),
req.version(),
/*commitVer*/null,
- ctx.system(),
+ ctx.systemTx(),
ctx.ioPolicy(),
PESSIMISTIC,
req.isolation(),
@@ -794,7 +794,7 @@ public abstract class GridDhtTransactionalCacheAdapter<K, V> extends GridDhtCach
req.threadId(),
req.implicitTx(),
req.implicitSingleTx(),
- ctx.system(),
+ ctx.systemTx(),
ctx.ioPolicy(),
PESSIMISTIC,
req.isolation(),
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd7f1a90/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
index 5f982e6..44ff756 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
@@ -289,7 +289,7 @@ public class GridNearTransactionalCache<K, V> extends GridNearCacheAdapter<K, V>
req.threadId(),
req.version(),
null,
- ctx.system(),
+ ctx.systemTx(),
ctx.ioPolicy(),
PESSIMISTIC,
req.isolation(),
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd7f1a90/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
index 70c5c9d..0d28120 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/continuous/CacheContinuousQueryManager.java
@@ -129,7 +129,7 @@ public class CacheContinuousQueryManager extends GridCacheManagerAdapter {
assert e != null;
assert key != null;
- boolean internal = e.isInternal() || e.context().system();
+ boolean internal = e.isInternal() || !e.context().userCache();
if (preload && !internal)
return;
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd7f1a90/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTransactionsImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTransactionsImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTransactionsImpl.java
index c3ad32b..044c3d7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTransactionsImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTransactionsImpl.java
@@ -100,11 +100,13 @@ public class IgniteTransactionsImpl<K, V> implements IgniteTransactionsEx {
A.ensure(timeout >= 0, "timeout cannot be negative");
A.ensure(txSize >= 0, "transaction size cannot be negative");
+ checkTransactional(ctx);
+
return txStart0(concurrency,
isolation,
timeout,
txSize,
- ctx.system() ? ctx : null);
+ ctx.systemTx() ? ctx : null);
}
/** {@inheritDoc} */
@@ -116,13 +118,15 @@ public class IgniteTransactionsImpl<K, V> implements IgniteTransactionsEx {
A.notNull(concurrency, "concurrency");
A.notNull(isolation, "isolation");
+ checkTransactional(ctx);
+
TransactionConfiguration cfg = cctx.gridConfig().getTransactionConfiguration();
return txStart0(concurrency,
isolation,
cfg.getDefaultTxTimeout(),
0,
- ctx.system() ? ctx : null);
+ ctx.systemTx() ? ctx : null);
}
/**
@@ -138,9 +142,6 @@ public class IgniteTransactionsImpl<K, V> implements IgniteTransactionsEx {
long timeout, int txSize, @Nullable GridCacheContext sysCacheCtx) {
TransactionConfiguration cfg = cctx.gridConfig().getTransactionConfiguration();
- if (sysCacheCtx != null && !sysCacheCtx.transactional())
- throw new IgniteException("Failed to start transaction on non-transactional cache: " + sysCacheCtx.name());
-
if (!cfg.isTxSerializableEnabled() && isolation == SERIALIZABLE)
throw new IllegalArgumentException("SERIALIZABLE isolation level is disabled (to enable change " +
"'txSerializableEnabled' configuration property)");
@@ -185,4 +186,12 @@ public class IgniteTransactionsImpl<K, V> implements IgniteTransactionsEx {
@Override public void resetMetrics() {
cctx.resetTxMetrics();
}
+
+ /**
+ * @param ctx Cache context.
+ */
+ private void checkTransactional(GridCacheContext ctx) {
+ if (!ctx.transactional())
+ throw new IgniteException("Failed to start transaction on non-transactional cache: " + ctx.name());
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd7f1a90/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
index 10146a4..2cbf0c8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
@@ -3081,7 +3081,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
"(cache configurations are not compatible) [" +
"activeCaches=[" + cacheNames + "]" +
", cacheName=" + cacheCtx.name() +
- ", cacheSystem=" + cacheCtx.system() +
+ ", cacheSystem=" + cacheCtx.systemTx() +
", txSystem=" + system() + ']');
}
else
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd7f1a90/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
index a8ff280..12f57b4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
@@ -366,7 +366,7 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
int txSize,
@Nullable IgniteTxKey grpLockKey,
boolean partLock) {
- assert sysCacheCtx == null || sysCacheCtx.system();
+ assert sysCacheCtx == null || sysCacheCtx.systemTx();
UUID subjId = null; // TODO GG-9141 how to get subj ID?
@@ -392,6 +392,7 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
}
/**
+ * @param cacheCtx Cache context.
* @param tx Created transaction.
* @return Started transaction.
*/
@@ -415,7 +416,7 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
// Do not add remote and dht local transactions as remote node may have the same thread ID
// and overwrite local transaction.
if (tx.local() && !tx.dht()) {
- if (cacheCtx == null || !cacheCtx.system())
+ if (cacheCtx == null || !cacheCtx.systemTx())
threadMap.put(tx.threadId(), tx);
else
sysThreadMap.put(new TxThreadKey(tx.threadId(), cacheCtx.cacheId()), tx);
@@ -692,12 +693,13 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
}
/**
+ * @param cctx Cache context.
* @param threadId Id of thread for transaction.
* @return Transaction for thread with given ID.
*/
@SuppressWarnings({"unchecked"})
private <T> T tx(GridCacheContext cctx, long threadId) {
- if (cctx == null || !cctx.system())
+ if (cctx == null || !cctx.systemTx())
return (T)threadMap.get(threadId);
TxThreadKey key = new TxThreadKey(threadId, cctx.cacheId());
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd7f1a90/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java
index e57a0a2..b83924b25 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java
@@ -75,8 +75,7 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest {
/**
* {@inheritDoc}
*/
- @Override
- protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
cfg.setUserAttributes(F.asMap(TEST_ATTRIBUTE_NAME, testAttribute));
@@ -100,16 +99,14 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest {
/**
* {@inheritDoc}
*/
- @Override
- protected void beforeTestsStarted() throws Exception {
+ @Override protected void beforeTestsStarted() throws Exception {
startGridsMultiThreaded(nodeCount());
}
/**
* {@inheritDoc}
*/
- @Override
- protected void afterTestsStopped() throws Exception {
+ @Override protected void afterTestsStopped() throws Exception {
stopAllGrids();
}
@@ -124,8 +121,7 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest {
int threadNum = 20;
GridTestUtils.runMultiThreaded(new Callable<Object>() {
- @Override
- public Object call() throws Exception {
+ @Override public Object call() throws Exception {
CacheConfiguration ccfg = new CacheConfiguration();
ccfg.setName(DYNAMIC_CACHE_NAME);
@@ -184,8 +180,7 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest {
int threadNum = 20;
GridTestUtils.runMultiThreaded(new Callable<Object>() {
- @Override
- public Object call() throws Exception {
+ @Override public Object call() throws Exception {
CacheConfiguration ccfg = new CacheConfiguration();
ccfg.setName(DYNAMIC_CACHE_NAME);
@@ -254,6 +249,7 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest {
}
/**
+ * @param mode Cache atomicity mode.
* @throws Exception If failed.
*/
private void checkStartStopCacheSimple(CacheAtomicityMode mode) throws Exception {
@@ -300,15 +296,13 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest {
f.get();
GridTestUtils.assertThrows(log, new Callable<Object>() {
- @Override
- public Object call() throws Exception {
+ @Override public Object call() throws Exception {
return kernal0.cache(DYNAMIC_CACHE_NAME);
}
}, IllegalArgumentException.class, null);
GridTestUtils.assertThrows(log, new Callable<Object>() {
- @Override
- public Object call() throws Exception {
+ @Override public Object call() throws Exception {
return caches[idx].get("1");
}
}, IllegalStateException.class, null);
@@ -360,13 +354,13 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest {
f.get();
GridTestUtils.assertThrows(log, new Callable<Object>() {
- @Override
- public Object call() throws Exception {
+ @Override public Object call() throws Exception {
return kernal0.cache(DYNAMIC_CACHE_NAME);
}
}, IllegalArgumentException.class, null);
}
- } finally {
+ }
+ finally {
stopGrid(nodeCount() + 1);
stopGrid(nodeCount());
}
@@ -423,8 +417,7 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest {
assertNotNull(grid(g).cache(DYNAMIC_CACHE_NAME));
else
GridTestUtils.assertThrows(log, new Callable<Object>() {
- @Override
- public Object call() throws Exception {
+ @Override public Object call() throws Exception {
return kernal0.getCache(DYNAMIC_CACHE_NAME);
}
}, IllegalArgumentException.class, null);
@@ -434,7 +427,8 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest {
stopGrid(nodeCount() + 1);
stopGrid(nodeCount());
- } finally {
+ }
+ finally {
testAttribute = true;
}
}
@@ -444,8 +438,7 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest {
*/
public void testFailWhenConfiguredCacheExists() throws Exception {
GridTestUtils.assertThrowsInherited(log, new Callable<Object>() {
- @Override
- public Object call() throws Exception {
+ @Override public Object call() throws Exception {
final Ignite kernal = grid(0);
CacheConfiguration ccfg = new CacheConfiguration();
@@ -482,8 +475,7 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest {
kernal.createCache(ccfg);
GridTestUtils.assertThrows(log, new Callable<Object>() {
- @Override
- public Object call() throws Exception {
+ @Override public Object call() throws Exception {
IgniteKernal ignite = (IgniteKernal) grid(nodeCount());
return ignite.getCache(DYNAMIC_CACHE_NAME);
@@ -499,7 +491,8 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest {
assertEquals("1", ignite(g).cache(DYNAMIC_CACHE_NAME).get("1"));
kernal.context().cache().dynamicStopCache(DYNAMIC_CACHE_NAME).get();
- } finally {
+ }
+ finally {
stopGrid(nodeCount());
}
}
@@ -540,7 +533,8 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest {
assertEquals("1", ignite(g).cache(DYNAMIC_CACHE_NAME).get("1"));
kernal.context().cache().dynamicStopCache(DYNAMIC_CACHE_NAME).get();
- } finally {
+ }
+ finally {
stopGrid(nodeCount());
}
}
@@ -810,6 +804,7 @@ public class IgniteDynamicCacheStartSelfTest extends GridCommonAbstractTest {
}
/**
+ * @param nearOnly Near only flag.
* @throws Exception If failed.
*/
public void checkGetOrCreateNear(final boolean nearOnly) throws Exception {
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd7f1a90/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteInternalCacheTypesTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteInternalCacheTypesTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteInternalCacheTypesTest.java
new file mode 100644
index 0000000..37bde6c
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteInternalCacheTypesTest.java
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import org.apache.ignite.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.managers.communication.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+import static org.apache.ignite.internal.managers.communication.GridIoPolicy.*;
+
+/**
+ * Sanity test for cache types.
+ */
+public class IgniteInternalCacheTypesTest extends GridCommonAbstractTest {
+ /** */
+ private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+ /** */
+ private static final String CACHE1 = "cache1";
+
+ /** */
+ private static final String CACHE2 = "cache2";
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+
+ if (gridName.equals(getTestGridName(0))) {
+ CacheConfiguration ccfg = defaultCacheConfiguration();
+
+ ccfg.setName(CACHE1);
+
+ cfg.setCacheConfiguration(ccfg);
+ }
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTestsStopped() throws Exception {
+ super.afterTestsStopped();
+
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCacheTypes() throws Exception {
+ Ignite ignite0 = startGrid(0);
+
+ checkCacheTypes(ignite0, CACHE1);
+
+ Ignite ignite1 = startGrid(1);
+
+ checkCacheTypes(ignite1, CACHE1);
+
+ CacheConfiguration ccfg = defaultCacheConfiguration();
+
+ ccfg.setName(CACHE2);
+
+ assertNotNull(ignite0.createCache(ccfg));
+
+ checkCacheTypes(ignite0, CACHE1, CACHE2);
+ checkCacheTypes(ignite1, CACHE1, CACHE2);
+
+ Ignite ignite2 = startGrid(2);
+
+ checkCacheTypes(ignite0, CACHE1, CACHE2);
+ checkCacheTypes(ignite1, CACHE1, CACHE2);
+ checkCacheTypes(ignite2, CACHE1, CACHE2);
+ }
+
+ /**
+ * @param ignite Ignite.
+ * @param userCaches User caches.
+ */
+ private void checkCacheTypes(Ignite ignite, String... userCaches) {
+ checkCache(ignite, CU.UTILITY_CACHE_NAME, UTILITY_CACHE_POOL, false, true);
+
+ checkCache(ignite, CU.MARSH_CACHE_NAME, MARSH_CACHE_POOL, false, false);
+
+ checkCache(ignite, CU.ATOMICS_CACHE_NAME, SYSTEM_POOL, false, false);
+
+ for (String cache : userCaches)
+ checkCache(ignite, cache, SYSTEM_POOL, true, false);
+ }
+
+ /**
+ * @param ignite Ignite.
+ * @param name Cache name.
+ * @param plc Expected IO policy.
+ * @param user Expected user cache flag.
+ * @param sysTx Expected system transaction flag.
+ */
+ private void checkCache(
+ Ignite ignite,
+ String name,
+ GridIoPolicy plc,
+ boolean user,
+ boolean sysTx) {
+ GridCacheAdapter cache = ((IgniteKernal)ignite).context().cache().internalCache(name);
+
+ assertNotNull("No cache " + name, cache);
+ assertEquals("Unexpected property for cache: " + cache.name(), plc, cache.context().ioPolicy());
+ assertEquals("Unexpected property for cache: " + cache.name(), user, cache.context().userCache());
+ assertEquals("Unexpected property for cache: " + cache.name(), sysTx, cache.context().systemTx());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd7f1a90/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java
index d4c3a1b..7c3d31a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCacheSystemTransactionsSelfTest.java
@@ -110,8 +110,7 @@ public class IgniteCacheSystemTransactionsSelfTest extends GridCacheAbstractSelf
ignite.context().cache().marshallerCache();
GridTestUtils.assertThrows(log, new Callable<Object>() {
- @Override
- public Object call() throws Exception {
+ @Override public Object call() throws Exception {
return marshallerCache.txStartEx(PESSIMISTIC, REPEATABLE_READ);
}
}, IgniteException.class, null);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd7f1a90/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStartCacheTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStartCacheTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStartCacheTest.java
new file mode 100644
index 0000000..09fa455
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStartCacheTest.java
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.igfs;
+
+import org.apache.ignite.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.igfs.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.cache.*;
+import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+
+import java.io.*;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.*;
+import static org.apache.ignite.cache.CacheMode.*;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*;
+import static org.apache.ignite.igfs.IgfsMode.*;
+import static org.apache.ignite.internal.managers.communication.GridIoPolicy.*;
+
+/**
+ *
+ */
+public class IgfsStartCacheTest extends IgfsCommonAbstractTest {
+ /** IP finder. */
+ private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
+
+ /**
+ * @param igfs If {@code true} created IGFS configuration.
+ * @param idx Node index.
+ * @return Configuration
+ */
+ private IgniteConfiguration config(boolean igfs, int idx) {
+ IgniteConfiguration cfg = new IgniteConfiguration();
+
+ TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+
+ discoSpi.setIpFinder(IP_FINDER);
+
+ cfg.setDiscoverySpi(discoSpi);
+
+ if (igfs) {
+ FileSystemConfiguration igfsCfg = new FileSystemConfiguration();
+
+ igfsCfg.setDataCacheName("dataCache");
+ igfsCfg.setMetaCacheName("metaCache");
+ igfsCfg.setName("igfs");
+ igfsCfg.setDefaultMode(PRIMARY);
+ igfsCfg.setFragmentizerEnabled(false);
+
+ CacheConfiguration dataCacheCfg = new CacheConfiguration();
+
+ dataCacheCfg.setName("dataCache");
+ dataCacheCfg.setCacheMode(PARTITIONED);
+ dataCacheCfg.setAtomicityMode(TRANSACTIONAL);
+ dataCacheCfg.setWriteSynchronizationMode(FULL_SYNC);
+ dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(1));
+
+ CacheConfiguration metaCacheCfg = new CacheConfiguration();
+
+ metaCacheCfg.setName("metaCache");
+ metaCacheCfg.setCacheMode(REPLICATED);
+ metaCacheCfg.setAtomicityMode(TRANSACTIONAL);
+ dataCacheCfg.setWriteSynchronizationMode(FULL_SYNC);
+
+ cfg.setCacheConfiguration(dataCacheCfg, metaCacheCfg);
+ cfg.setFileSystemConfiguration(igfsCfg);
+ }
+
+ cfg.setGridName("node-" + idx);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testCacheStart() throws Exception {
+ Ignite g0 = G.start(config(true, 0));
+
+ checkIgfsCaches(g0);
+
+ Ignite g1 = G.start(config(false, 1));
+
+ checkIgfsCaches(g1);
+
+ IgniteFileSystem igfs = g0.fileSystem("igfs");
+
+ igfs.mkdirs(new IgfsPath("/test"));
+
+ try (BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(igfs.create(
+ new IgfsPath("/test/test.file"), true)))) {
+
+ for (int i = 0; i < 1000; i++)
+ bw.write("test-" + i);
+ }
+ }
+
+ /**
+ * @param ignite Ignite.
+ */
+ private void checkIgfsCaches(Ignite ignite) {
+ checkCache(((IgniteKernal)ignite).internalCache("dataCache"));
+ checkCache(((IgniteKernal)ignite).internalCache("metaCache"));
+ }
+
+ /**
+ * @param cache Cache.
+ */
+ private void checkCache(GridCacheAdapter cache) {
+ assertNotNull(cache);
+ assertFalse(cache.context().userCache());
+ assertFalse(cache.context().systemTx());
+ assertEquals(SYSTEM_POOL, cache.context().ioPolicy());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd7f1a90/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgsfStartCacheTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgsfStartCacheTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgsfStartCacheTest.java
deleted file mode 100644
index e2eedbe..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgsfStartCacheTest.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.igfs;
-
-import org.apache.ignite.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.igfs.*;
-import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.spi.discovery.tcp.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
-
-import java.io.*;
-
-import static org.apache.ignite.cache.CacheAtomicityMode.*;
-import static org.apache.ignite.cache.CacheMode.*;
-import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*;
-import static org.apache.ignite.igfs.IgfsMode.*;
-
-/**
- *
- */
-public class IgsfStartCacheTest extends IgfsCommonAbstractTest {
- /** IP finder. */
- private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
-
- /**
- * @param igfs If {@code true} created IGFS configuration.
- * @param idx Node index.
- * @return Configuration
- */
- private IgniteConfiguration config(boolean igfs, int idx) {
- IgniteConfiguration cfg = new IgniteConfiguration();
-
- TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
-
- discoSpi.setIpFinder(IP_FINDER);
-
- cfg.setDiscoverySpi(discoSpi);
-
- if (igfs) {
- FileSystemConfiguration igfsCfg = new FileSystemConfiguration();
-
- igfsCfg.setDataCacheName("dataCache");
- igfsCfg.setMetaCacheName("metaCache");
- igfsCfg.setName("igfs");
- igfsCfg.setDefaultMode(PRIMARY);
- igfsCfg.setFragmentizerEnabled(false);
-
- CacheConfiguration dataCacheCfg = new CacheConfiguration();
-
- dataCacheCfg.setName("dataCache");
- dataCacheCfg.setCacheMode(PARTITIONED);
- dataCacheCfg.setAtomicityMode(TRANSACTIONAL);
- dataCacheCfg.setWriteSynchronizationMode(FULL_SYNC);
- dataCacheCfg.setAffinityMapper(new IgfsGroupDataBlocksKeyMapper(1));
-
- CacheConfiguration metaCacheCfg = new CacheConfiguration();
-
- metaCacheCfg.setName("metaCache");
- metaCacheCfg.setCacheMode(REPLICATED);
- metaCacheCfg.setAtomicityMode(TRANSACTIONAL);
- dataCacheCfg.setWriteSynchronizationMode(FULL_SYNC);
-
- cfg.setCacheConfiguration(dataCacheCfg, metaCacheCfg);
- cfg.setFileSystemConfiguration(igfsCfg);
- }
-
- cfg.setGridName("node-" + idx);
-
- return cfg;
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- super.afterTest();
-
- stopAllGrids();
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testCacheStart() throws Exception {
- Ignite g0 = G.start(config(true, 0));
-
- G.start(config(false, 1));
-
- IgniteFileSystem igfs = g0.fileSystem("igfs");
-
- igfs.mkdirs(new IgfsPath("/test"));
-
- try (BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(igfs.create(
- new IgfsPath("/test/test.file"), true)))) {
-
- for (int i = 0; i < 1000; i++)
- bw.write("test-" + i);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd7f1a90/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java b/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java
index b277d48..0b0f099 100644
--- a/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java
+++ b/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java
@@ -57,6 +57,7 @@ public class GridCacheTestContext<K, V> extends GridCacheContext<K, V> {
new GridCacheIoManager()
),
defaultCacheConfiguration(),
+ CacheType.USER,
true,
new GridCacheEventManager(),
new GridCacheSwapManager(false),
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd7f1a90/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
index d5ae2e6..00dfc76 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@ -427,6 +427,8 @@ public class IgniteCacheTestSuite extends TestSuite {
suite.addTestSuite(IgniteCacheTxStoreValueTest.class);
suite.addTestSuite(IgniteCacheTxNearEnabledStoreValueTest.class);
+ suite.addTestSuite(IgniteInternalCacheTypesTest.class);
+
return suite;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/cd7f1a90/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
index c0893cc..11e22b1 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteIgfsTestSuite.java
@@ -74,6 +74,8 @@ public class IgniteIgfsTestSuite extends TestSuite {
suite.addTestSuite(IgfsGroupDataBlockKeyMapperHashSelfTest.class);
+ suite.addTestSuite(IgfsStartCacheTest.class);
+
return suite;
}
}