ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject [15/50] [abbrv] ignite git commit: ignite-1.4.2 - Fixed resource cleanup for caches created from template.
Date Thu, 22 Oct 2015 10:47:27 GMT
ignite-1.4.2 - Fixed resource cleanup for caches created from template.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/30b731b3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/30b731b3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/30b731b3

Branch: refs/heads/ignite-1016
Commit: 30b731b3c54609b77293e08c401db2d96e48e8d9
Parents: 94f549f
Author: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Authored: Mon Oct 12 16:09:59 2015 +0300
Committer: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Committed: Mon Oct 12 16:09:59 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheProcessor.java    | 23 ++++++++++-----
 .../IgniteCacheConfigurationTemplateTest.java   | 31 ++++++++++++++++++++
 2 files changed, 46 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/30b731b3/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 8c96c0c..722e570 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
@@ -639,7 +639,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
             if (ctx.config().isDaemon() && !CU.isMarshallerCache(cfgs[i].getName()))
                 continue;
 
-            checkSerializable(cfgs[i]);
+            cloneCheckSerializable(cfgs[i]);
 
             CacheConfiguration<?, ?> cfg = new CacheConfiguration(cfgs[i]);
 
@@ -2023,9 +2023,14 @@ public class GridCacheProcessor extends GridProcessorAdapter {
      * @return Future that will be completed when cache is deployed.
      */
     public IgniteInternalFuture<?> createFromTemplate(String cacheName) {
-        CacheConfiguration cfg = createConfigFromTemplate(cacheName);
+        try {
+            CacheConfiguration cfg = createConfigFromTemplate(cacheName);
 
-        return dynamicStartCache(cfg, cacheName, null, true, true);
+            return dynamicStartCache(cfg, cacheName, null, true, true);
+        }
+        catch (IgniteCheckedException e) {
+            throw U.convertException(e);
+        }
     }
 
     /**
@@ -2052,7 +2057,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
      * @param cacheName Cache name.
      * @return Cache configuration.
      */
-    private CacheConfiguration createConfigFromTemplate(String cacheName) {
+    private CacheConfiguration createConfigFromTemplate(String cacheName) throws IgniteCheckedException
{
         CacheConfiguration cfgTemplate = null;
 
         CacheConfiguration dfltCacheCfg = null;
@@ -2112,6 +2117,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
 
         if (cfgTemplate == null)
             cfgTemplate = new CacheConfiguration();
+        else
+            cfgTemplate = cloneCheckSerializable(cfgTemplate);
 
         CacheConfiguration cfg = new CacheConfiguration(cfgTemplate);
 
@@ -2168,7 +2175,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
 
         if (ccfg != null) {
             try {
-                checkSerializable(ccfg);
+                cloneCheckSerializable(ccfg);
             }
             catch (IgniteCheckedException e) {
                 return new GridFinishedFuture<>(e);
@@ -3340,9 +3347,9 @@ public class GridCacheProcessor extends GridProcessorAdapter {
      * @param val Object to check.
      * @throws IgniteCheckedException If validation failed.
      */
-    private void checkSerializable(CacheConfiguration val) throws IgniteCheckedException
{
+    private CacheConfiguration cloneCheckSerializable(CacheConfiguration val) throws IgniteCheckedException
{
         if (val == null)
-            return;
+            return null;
 
         if (val.getCacheStoreFactory() != null) {
             try {
@@ -3356,7 +3363,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
         }
 
         try {
-            marshaller.unmarshal(marshaller.marshal(val), val.getClass().getClassLoader());
+            return marshaller.unmarshal(marshaller.marshal(val), val.getClass().getClassLoader());
         }
         catch (IgniteCheckedException e) {
             throw new IgniteCheckedException("Failed to validate cache configuration " +

http://git-wip-us.apache.org/repos/asf/ignite/blob/30b731b3/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 d3ba2d6..87a30a6 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
@@ -24,6 +24,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
 import org.apache.ignite.cache.CacheExistsException;
+import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
 import org.apache.ignite.events.Event;
@@ -365,6 +366,36 @@ public class IgniteCacheConfigurationTemplateTest extends GridCommonAbstractTest
     }
 
     /**
+     * @throws Exception If failed.
+     */
+    public void testTemplateCleanup() throws Exception {
+        startGridsMultiThreaded(3);
+
+        try {
+            CacheConfiguration ccfg = new CacheConfiguration("affTemplate-*");
+
+            ccfg.setAffinity(new RendezvousAffinityFunction());
+
+            ignite(0).addCacheConfiguration(ccfg);
+
+            ignite(0).getOrCreateCache("affTemplate-1");
+
+            IgniteCache<Object, Object> cache = ignite(0).getOrCreateCache("affTemplate-2");
+
+            ignite(0).destroyCache("affTemplate-1");
+
+            startGrid(3);
+
+            cache.put(1, 1);
+
+            assertEquals(1, cache.get(1));
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
      * @param ignite Ignite.
      * @param name Cache name.
      * @param expBackups Expected number of backups.


Mime
View raw message