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:19 UTC
[46/50] [abbrv] incubator-ignite git commit: # ignite-sprint-3
correction for ignite-680
# ignite-sprint-3 correction for ignite-680
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/3e6da9cd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/3e6da9cd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/3e6da9cd
Branch: refs/heads/ignite-sprint-4
Commit: 3e6da9cda37c094167ec7bad604c3f9baf631fc6
Parents: 9d183c5
Author: sboikov <sb...@gridgain.com>
Authored: Thu Apr 9 09:50:42 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Thu Apr 9 10:11:35 2015 +0300
----------------------------------------------------------------------
.../src/main/java/org/apache/ignite/Ignite.java | 11 ++
.../apache/ignite/internal/IgniteKernal.java | 19 ++-
.../cache/DynamicCacheChangeRequest.java | 2 +-
.../processors/cache/GridCacheProcessor.java | 119 +++++++++++--------
...teCacheConfigurationDefaultTemplateTest.java | 111 +++++++++++++++++
...eCacheConfigurationTemplateNotFoundTest.java | 114 ------------------
.../IgniteCacheConfigurationTemplateTest.java | 86 +++++++++++++-
.../ignite/testframework/junits/IgniteMock.java | 5 +
.../ignite/testsuites/IgniteCacheTestSuite.java | 2 +-
.../org/apache/ignite/IgniteSpringBean.java | 7 ++
10 files changed, 309 insertions(+), 167 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3e6da9cd/modules/core/src/main/java/org/apache/ignite/Ignite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/Ignite.java b/modules/core/src/main/java/org/apache/ignite/Ignite.java
index 6b49add..40c9bbb 100644
--- a/modules/core/src/main/java/org/apache/ignite/Ignite.java
+++ b/modules/core/src/main/java/org/apache/ignite/Ignite.java
@@ -217,6 +217,17 @@ public interface Ignite extends AutoCloseable {
public <K, V> IgniteCache<K, V> createCache(CacheConfiguration<K, V> cacheCfg);
/**
+ * Dynamically starts new cache using template configuration.
+ * <p>
+ * If local node is an affinity node, this method will return the instance of started cache.
+ * Otherwise, it will create a client cache on local node.
+ *
+ * @param cacheName Cache name.
+ * @return Instance of started cache.
+ */
+ public <K, V> IgniteCache<K, V> createCache(String cacheName);
+
+ /**
* Gets existing cache with the given name or creates new one with the given configuration.
*
* @param cacheCfg Cache configuration to use.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3e6da9cd/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 768bbd3..0db2ad6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -2282,6 +2282,23 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
}
/** {@inheritDoc} */
+ @Override public <K, V> IgniteCache<K, V> createCache(String cacheName) {
+ guard();
+
+ try {
+ ctx.cache().createFromTemplate(cacheName).get();
+
+ return ctx.cache().publicJCache(cacheName);
+ }
+ catch (IgniteCheckedException e) {
+ throw CU.convertToCacheException(e);
+ }
+ finally {
+ unguard();
+ }
+ }
+
+ /** {@inheritDoc} */
@Override public <K, V> IgniteCache<K, V> getOrCreateCache(CacheConfiguration<K, V> cacheCfg) {
A.notNull(cacheCfg, "cacheCfg");
@@ -2409,7 +2426,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable {
guard();
try {
- ctx.cache().dynamicStartCache(cacheName).get();
+ ctx.cache().getOrCreateFromTemplate(cacheName).get();
return ctx.cache().publicJCache(cacheName);
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3e6da9cd/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 bd53cdb..c08a179 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
@@ -119,7 +119,7 @@ public class DynamicCacheChangeRequest implements Serializable {
* @return {@code True} if this is a start request.
*/
public boolean start() {
- return startCfg != null;
+ return !template && startCfg != null;
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3e6da9cd/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 35cfd0c..f0db73e 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
@@ -1365,7 +1365,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
) throws IgniteCheckedException {
for (DynamicCacheChangeRequest req : reqs) {
assert req.start() : req;
- assert req.cacheType() != null : req.cacheType();
+ assert req.cacheType() != null : req;
prepareCacheStart(
req.startCacheConfiguration(),
@@ -1711,81 +1711,102 @@ public class GridCacheProcessor extends GridProcessorAdapter {
* @param cacheName Cache name.
* @return Future that will be completed when cache is deployed.
*/
- public IgniteInternalFuture<?> dynamicStartCache(String cacheName) {
+ public IgniteInternalFuture<?> createFromTemplate(String cacheName) {
+ CacheConfiguration cfg = createConfigFromTemplate(cacheName);
+
+ return dynamicStartCache(cfg, cacheName, null, true);
+ }
+
+ /**
+ * Dynamically starts cache using template configuration.
+ *
+ * @param cacheName Cache name.
+ * @return Future that will be completed when cache is deployed.
+ */
+ public IgniteInternalFuture<?> getOrCreateFromTemplate(String cacheName) {
try {
if (publicJCache(cacheName, false, true) != null) // Cache with given name already started.
return new GridFinishedFuture<>();
- CacheConfiguration cfgTemplate = null;
+ CacheConfiguration cfg = createConfigFromTemplate(cacheName);
- CacheConfiguration dfltCacheCfg = null;
+ return dynamicStartCache(cfg, cacheName, null, false);
+ }
+ catch (IgniteCheckedException e) {
+ return new GridFinishedFuture<>(e);
+ }
+ }
- List<CacheConfiguration> wildcardNameCfgs = null;
+ /**
+ * @param cacheName Cache name.
+ * @return Cache configuration.
+ */
+ private CacheConfiguration createConfigFromTemplate(String cacheName) {
+ CacheConfiguration cfgTemplate = null;
- for (DynamicCacheDescriptor desc : registeredTemplates.values()) {
- assert desc.template();
+ CacheConfiguration dfltCacheCfg = null;
- CacheConfiguration cfg = desc.cacheConfiguration();
+ List<CacheConfiguration> wildcardNameCfgs = null;
- assert cfg != null;
+ for (DynamicCacheDescriptor desc : registeredTemplates.values()) {
+ assert desc.template();
- if (F.eq(cacheName, cfg.getName())) {
- cfgTemplate = cfg;
+ CacheConfiguration cfg = desc.cacheConfiguration();
- break;
- }
+ assert cfg != null;
- if (cfg.getName() != null ) {
- if (cfg.getName().endsWith("*")) {
- if (cfg.getName().length() > 1) {
- if (wildcardNameCfgs == null)
- wildcardNameCfgs = new ArrayList<>();
+ if (F.eq(cacheName, cfg.getName())) {
+ cfgTemplate = cfg;
- wildcardNameCfgs.add(cfg);
- }
- else
- dfltCacheCfg = cfg; // Template with name '*'.
+ break;
+ }
+
+ if (cfg.getName() != null ) {
+ if (cfg.getName().endsWith("*")) {
+ if (cfg.getName().length() > 1) {
+ if (wildcardNameCfgs == null)
+ wildcardNameCfgs = new ArrayList<>();
+
+ wildcardNameCfgs.add(cfg);
}
+ else
+ dfltCacheCfg = cfg; // Template with name '*'.
}
- else if (dfltCacheCfg == null)
- dfltCacheCfg = cfg;
}
+ else if (dfltCacheCfg == null)
+ dfltCacheCfg = cfg;
+ }
- if (cfgTemplate == null && cacheName != null && wildcardNameCfgs != null) {
- Collections.sort(wildcardNameCfgs, new Comparator<CacheConfiguration>() {
- @Override public int compare(CacheConfiguration cfg1, CacheConfiguration cfg2) {
- Integer len1 = cfg1.getName() != null ? cfg1.getName().length() : 0;
- Integer len2 = cfg2.getName() != null ? cfg2.getName().length() : 0;
+ if (cfgTemplate == null && cacheName != null && wildcardNameCfgs != null) {
+ Collections.sort(wildcardNameCfgs, new Comparator<CacheConfiguration>() {
+ @Override public int compare(CacheConfiguration cfg1, CacheConfiguration cfg2) {
+ Integer len1 = cfg1.getName() != null ? cfg1.getName().length() : 0;
+ Integer len2 = cfg2.getName() != null ? cfg2.getName().length() : 0;
- return len2.compareTo(len1);
- }
- });
+ return len2.compareTo(len1);
+ }
+ });
- for (CacheConfiguration cfg : wildcardNameCfgs) {
- if (cacheName.startsWith(cfg.getName().substring(0, cfg.getName().length() - 1))) {
- cfgTemplate = cfg;
+ for (CacheConfiguration cfg : wildcardNameCfgs) {
+ if (cacheName.startsWith(cfg.getName().substring(0, cfg.getName().length() - 1))) {
+ cfgTemplate = cfg;
- break;
- }
+ break;
}
}
+ }
- if (cfgTemplate == null)
- cfgTemplate = dfltCacheCfg;
+ if (cfgTemplate == null)
+ cfgTemplate = dfltCacheCfg;
- if (cfgTemplate == null)
- throw new IllegalArgumentException("Failed to start cache " +
- "(there is no matching template configuration) : " + cacheName);
+ if (cfgTemplate == null)
+ cfgTemplate = new CacheConfiguration();
- CacheConfiguration cfg = new CacheConfiguration(cfgTemplate);
+ CacheConfiguration cfg = new CacheConfiguration(cfgTemplate);
- cfg.setName(cacheName);
+ cfg.setName(cacheName);
- return dynamicStartCache(cfg, cacheName, null, false);
- }
- catch (IgniteCheckedException e) {
- return new GridFinishedFuture<>(e);
- }
+ return cfg;
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3e6da9cd/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationDefaultTemplateTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationDefaultTemplateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationDefaultTemplateTest.java
new file mode 100644
index 0000000..0aa9683
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationDefaultTemplateTest.java
@@ -0,0 +1,111 @@
+/*
+ * 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.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.*;
+
+/**
+ *
+ */
+public class IgniteCacheConfigurationDefaultTemplateTest extends GridCommonAbstractTest {
+ /** */
+ private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+ ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
+
+ CacheConfiguration templateCfg = new CacheConfiguration();
+
+ templateCfg.setName("org.apache.ignite.template*");
+ templateCfg.setBackups(3);
+
+ cfg.setCacheConfiguration(templateCfg);
+
+ return cfg;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void afterTest() throws Exception {
+ super.afterTest();
+
+ stopAllGrids();
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testDefaultTemplate() throws Exception {
+ Ignite ignite = startGrid(0);
+
+ checkDefaultTemplate(ignite, "org.apache.ignite");
+
+ checkDefaultTemplate(ignite, "org.apache.ignite.templat");
+
+ checkDefaultTemplate(ignite, null);
+
+ checkGetOrCreate(ignite, "org.apache.ignite.template", 3);
+
+ CacheConfiguration templateCfg = new CacheConfiguration();
+
+ templateCfg.setBackups(4);
+
+ ignite.addCacheConfiguration(templateCfg);
+
+ checkGetOrCreate(ignite, "org.apache.ignite2", 4);
+ }
+
+ /**
+ * @param ignite Ignite.
+ * @param cacheName Cache name.
+ */
+ private void checkDefaultTemplate(final Ignite ignite, final String cacheName) {
+ checkGetOrCreate(ignite, cacheName, 0);
+
+ IgniteCache cache = ignite.getOrCreateCache(cacheName);
+
+ assertNotNull(cache);
+
+ CacheConfiguration cfg = (CacheConfiguration)cache.getConfiguration(CacheConfiguration.class);
+
+ assertEquals(CacheConfiguration.DFLT_CACHE_ATOMICITY_MODE, cfg.getAtomicityMode());
+ }
+
+ /**
+ * @param ignite Ignite.
+ * @param name Cache name.
+ * @param expBackups Expected number of backups.
+ */
+ private void checkGetOrCreate(Ignite ignite, String name, int expBackups) {
+ IgniteCache cache = ignite.getOrCreateCache(name);
+
+ assertNotNull(cache);
+
+ CacheConfiguration cfg = (CacheConfiguration)cache.getConfiguration(CacheConfiguration.class);
+
+ assertEquals(name, cfg.getName());
+ assertEquals(expBackups, cfg.getBackups());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3e6da9cd/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationTemplateNotFoundTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationTemplateNotFoundTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationTemplateNotFoundTest.java
deleted file mode 100644
index 53780da..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationTemplateNotFoundTest.java
+++ /dev/null
@@ -1,114 +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.cache;
-
-import org.apache.ignite.*;
-import org.apache.ignite.configuration.*;
-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.*;
-import org.apache.ignite.testframework.junits.common.*;
-
-import java.util.concurrent.*;
-
-/**
- *
- */
-public class IgniteCacheConfigurationTemplateNotFoundTest extends GridCommonAbstractTest {
- /** */
- private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(gridName);
-
- ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder);
-
- CacheConfiguration templateCfg = new CacheConfiguration();
-
- templateCfg.setName("org.apache.ignite.template*");
- templateCfg.setBackups(3);
-
- cfg.setCacheConfiguration(templateCfg);
-
- return cfg;
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- super.afterTest();
-
- stopAllGrids();
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testTemplateNotFound() throws Exception {
- Ignite ignite = startGrid(0);
-
- checkTemplateNotFound(ignite, "org.apache.ignite");
-
- checkTemplateNotFound(ignite, "org.apache.ignite.templat");
-
- checkTemplateNotFound(ignite, null);
-
- checkGetOrCreate(ignite, "org.apache.ignite.template", 3);
-
- CacheConfiguration templateCfg = new CacheConfiguration();
-
- templateCfg.setBackups(4);
-
- ignite.addCacheConfiguration(templateCfg);
-
- checkGetOrCreate(ignite, "org.apache.ignite", 4);
-
- checkGetOrCreate(ignite, null, 4);
- }
-
- /**
- * @param ignite Ignite.
- * @param cacheName Cache name.
- */
- private void checkTemplateNotFound(final Ignite ignite, final String cacheName) {
- GridTestUtils.assertThrows(log, new Callable<Void>() {
- @Override public Void call() throws Exception {
- ignite.getOrCreateCache(cacheName);
-
- return null;
- }
- }, IllegalArgumentException.class, null);
- }
-
- /**
- * @param ignite Ignite.
- * @param name Cache name.
- * @param expBackups Expected number of backups.
- */
- private void checkGetOrCreate(Ignite ignite, String name, int expBackups) {
- IgniteCache cache = ignite.getOrCreateCache(name);
-
- assertNotNull(cache);
-
- CacheConfiguration cfg = (CacheConfiguration)cache.getConfiguration(CacheConfiguration.class);
-
- assertEquals(name, cfg.getName());
- assertEquals(expBackups, cfg.getBackups());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3e6da9cd/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationTemplateTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationTemplateTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationTemplateTest.java
index d0ffab2..a030039 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationTemplateTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheConfigurationTemplateTest.java
@@ -18,6 +18,7 @@
package org.apache.ignite.internal.processors.cache;
import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.events.*;
import org.apache.ignite.lang.*;
@@ -96,7 +97,61 @@ public class IgniteCacheConfigurationTemplateTest extends GridCommonAbstractTest
/**
* @throws Exception If failed.
*/
- public void testCreateFromTemplateConfiguration() throws Exception {
+ public void testCreateFromTemplate() throws Exception {
+ addTemplate = true;
+
+ Ignite ignite0 = startGrid(0);
+
+ checkCreate(ignite0, "org.apache.ignite.test.cache1", 4);
+ checkCreated(ignite0, "org.apache.ignite.test.cache1");
+
+ Ignite ignite1 = startGrid(1);
+
+ checkCreated(ignite1, "org.apache.ignite.test.cache1");
+
+ checkCreate(ignite1, "org.apache.ignite1", 3);
+ checkCreated(ignite1, "org.apache.ignite1");
+
+ checkCreated(ignite0, "org.apache.ignite1");
+
+ checkCreate(ignite0, "org.apache1", 2);
+ checkCreated(ignite0, "org.apache1");
+
+ checkCreated(ignite1, "org.apache1");
+
+ addTemplate = false;
+ clientMode = true;
+
+ Ignite ignite2 = startGrid(2);
+
+ assertNotNull(ignite2.cache("org.apache.ignite.test.cache1"));
+ assertNotNull(ignite2.cache("org.apache.ignite1"));
+ assertNotNull(ignite2.cache("org.apache1"));
+
+ CacheConfiguration template1 = new CacheConfiguration();
+
+ template1.setName(TEMPLATE3);
+ template1.setBackups(5);
+
+ ignite2.addCacheConfiguration(template1);
+
+ checkCreate(ignite0, "org.apache.ignite.test2.cache1", 5);
+
+ checkCreated(ignite0, "org.apache.ignite.test2.cache1");
+ checkCreated(ignite1, "org.apache.ignite.test2.cache1");
+ checkCreated(ignite2, "org.apache.ignite.test2.cache1");
+
+ Ignite ignite3 = startGrid(3);
+
+ checkCreate(ignite3, "org.apache.ignite.test2.cache2", 5);
+
+ checkNoTemplateCaches(4);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testGetOrCreateFromTemplate() throws Exception {
addTemplate = true;
Ignite ignite0 = startGrid(0);
@@ -322,6 +377,35 @@ public class IgniteCacheConfigurationTemplateTest extends GridCommonAbstractTest
}
/**
+ * @param ignite Ignite.
+ * @param name Cache name.
+ * @param expBackups Expected number of backups.
+ */
+ private void checkCreate(final Ignite ignite, final String name, int expBackups) {
+ IgniteCache cache = ignite.createCache(name);
+
+ assertNotNull(cache);
+
+ CacheConfiguration cfg = (CacheConfiguration)cache.getConfiguration(CacheConfiguration.class);
+
+ assertEquals(name, cfg.getName());
+ assertEquals(expBackups, cfg.getBackups());
+ }
+
+ /**
+ * @param cacheName Cache name.
+ */
+ private void checkCreated(final Ignite ignite, final String cacheName) {
+ GridTestUtils.assertThrows(log, new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ ignite.createCache(cacheName);
+
+ return null;
+ }
+ }, CacheExistsException.class, null);
+ }
+
+ /**
* @param nodes Nodes number.
*/
private void checkNoTemplateCaches(int nodes) {
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3e6da9cd/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
index b575544..2451f59 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/IgniteMock.java
@@ -202,6 +202,11 @@ public class IgniteMock implements Ignite {
}
/** {@inheritDoc} */
+ @Override public <K, V> IgniteCache<K, V> createCache(String cacheName) {
+ return null;
+ }
+
+ /** {@inheritDoc} */
@Override public <K, V> void addCacheConfiguration(CacheConfiguration<K, V> cacheCfg) {
// No-op.
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3e6da9cd/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 649ce0f..01b45f5 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
@@ -411,7 +411,7 @@ public class IgniteCacheTestSuite extends TestSuite {
suite.addTestSuite(IgniteDynamicCacheStartSelfTest.class);
suite.addTestSuite(IgniteCacheDynamicStopSelfTest.class);
suite.addTestSuite(IgniteCacheConfigurationTemplateTest.class);
- suite.addTestSuite(IgniteCacheConfigurationTemplateNotFoundTest.class);
+ suite.addTestSuite(IgniteCacheConfigurationDefaultTemplateTest.class);
suite.addTestSuite(GridCacheTxLoadFromStoreOnLockSelfTest.class);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/3e6da9cd/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java b/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java
index cd4fd73..3228210 100644
--- a/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java
+++ b/modules/spring/src/main/java/org/apache/ignite/IgniteSpringBean.java
@@ -283,6 +283,13 @@ public class IgniteSpringBean implements Ignite, DisposableBean, InitializingBea
}
/** {@inheritDoc} */
+ @Override public <K, V> IgniteCache<K, V> createCache(String cacheName) {
+ assert g != null;
+
+ return g.createCache(cacheName);
+ }
+
+ /** {@inheritDoc} */
@Override public <K, V> void addCacheConfiguration(CacheConfiguration<K, V> cacheCfg) {
assert g != null;