ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dma...@apache.org
Subject ignite git commit: IGNITE-2647: Cache is undeployed even when BinaryMarshaller is used. Fixed.
Date Mon, 15 Feb 2016 21:05:32 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-2647 6247ac719 -> eccb24e71


IGNITE-2647: Cache is undeployed even when BinaryMarshaller is used. Fixed.


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

Branch: refs/heads/ignite-2647
Commit: eccb24e7120775200f0c22ab8d0830bd00a0393b
Parents: 6247ac7
Author: Denis Magda <dmagda@gridgain.com>
Authored: Tue Feb 16 00:05:18 2016 +0300
Committer: Denis Magda <dmagda@gridgain.com>
Committed: Tue Feb 16 00:05:18 2016 +0300

----------------------------------------------------------------------
 .../cache/GridCacheDeploymentManager.java       |  8 +-
 .../processors/cache/GridCacheProcessor.java    |  4 +-
 .../cache/GridCacheDeploymentSelfTest.java      | 78 +++++++++++++++++++-
 3 files changed, 85 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/eccb24e7/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 d7f7521..97d58dc 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
@@ -29,6 +29,7 @@ import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.IgniteException;
+import org.apache.ignite.binary.BinaryInvalidTypeException;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.DeploymentMode;
 import org.apache.ignite.events.DiscoveryEvent;
@@ -342,6 +343,11 @@ public class GridCacheDeploymentManager<K, V> extends GridCacheSharedManagerAdap
         catch (GridCacheEntryRemovedException ignore) {
             return false;
         }
+        catch (BinaryInvalidTypeException ignore) {
+            log.error("An attempt to undeploy cache with binary objects.", ignore);
+
+            return false;
+        }
         catch (IgniteCheckedException | IgniteException ignore) {
             // Peek can throw runtime exception if unmarshalling failed.
             return true;
@@ -1004,4 +1010,4 @@ public class GridCacheDeploymentManager<K, V> extends GridCacheSharedManagerAdap
             return S.toString(CachedDeploymentInfo.class, this);
         }
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/eccb24e7/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 db9298f..d485d41 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
@@ -3287,8 +3287,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
     public void onUndeployed(ClassLoader ldr) {
         if (!ctx.isStopping()) {
             for (GridCacheAdapter<?, ?> cache : caches.values()) {
-                // Do not notify system caches.
-                if (cache.context().userCache())
+                // Do not notify system caches and caches for which deployment is disabled.
+                if (cache.context().userCache() && cache.context().deploymentEnabled())
                     cache.onUndeploy(ldr);
             }
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/eccb24e7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentSelfTest.java
index db6c882..c3c2d47 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentSelfTest.java
@@ -112,6 +112,16 @@ public class GridCacheDeploymentSelfTest extends GridCommonAbstractTest
{
         return cfg;
     }
 
+    /**
+     * Checks whether a cache should be undeployed in SHARED or CONTINUOUS modes.
+     *
+     * @param g Ignite node.
+     * @return {@code true} if the cache has to be undeployed, {@code false} otherwise.
+     */
+    protected boolean isCacheUndeployed(Ignite g) {
+        return !(g.configuration().getMarshaller() instanceof BinaryMarshaller);
+    }
+
     /** @throws Exception If failed. */
     @SuppressWarnings("unchecked")
     public void testDeployment() throws Exception {
@@ -210,8 +220,7 @@ public class GridCacheDeploymentSelfTest extends GridCommonAbstractTest
{
 
             assertEquals(0, g1.cache(null).localSize());
 
-            assertEquals(g2.configuration().getMarshaller() instanceof BinaryMarshaller ?
1 : 0,
-                g2.cache(null).localSize());
+            assertEquals(isCacheUndeployed(g1) ? 0 : 1, g2.cache(null).localSize());
 
             startGrid(3);
         }
@@ -423,6 +432,71 @@ public class GridCacheDeploymentSelfTest extends GridCommonAbstractTest
{
     }
 
     /**
+     * @throws Exception If failed.
+     */
+    public void testCacheUndeploymentSharedMode() throws Exception {
+        testCacheUndeployment(SHARED);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testCacheUndeploymentContMode() throws Exception {
+        testCacheUndeployment(CONTINUOUS);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    private void testCacheUndeployment(DeploymentMode depMode) throws Exception {
+        ClassLoader ldr = getExternalClassLoader();
+
+        Class valCls = ldr.loadClass(TEST_VALUE_1);
+        Class taskCls = ldr.loadClass(TEST_TASK_2);
+
+        try {
+            this.depMode = depMode;
+
+            Ignite g0 = startGrid(0);
+            Ignite g1 = startGrid(1);
+
+            for (int i = 0; i < 20; i++)
+                g0.cache(null).put(i, valCls.newInstance());
+
+            assert g0.cache(null).localSize(CachePeekMode.ALL) > 0 : "Cache is empty";
+            assert g1.cache(null).localSize(CachePeekMode.ALL) > 0 : "Cache is empty";
+
+            g0.compute(g0.cluster().forRemotes()).execute(taskCls, g1.cluster().localNode());
+
+            stopGrid(0);
+
+            if (depMode == SHARED && isCacheUndeployed(g1)) {
+                for (int i = 0; i < 10; i++) {
+                    if (g1.cache(null).localSize(CachePeekMode.ALL) == 0)
+                        break;
+
+                    Thread.sleep(500);
+                }
+
+                assertEquals(0, g1.cache(null).localSize(CachePeekMode.ALL));
+            }
+            else {
+                for (int i = 0; i < 4; i++) {
+                    if (g1.cache(null).localSize(CachePeekMode.ALL) == 0)
+                        break;
+
+                    Thread.sleep(500);
+                }
+
+                assert g1.cache(null).localSize(CachePeekMode.ALL) > 0 : "Cache undeployed
unexpectadly";
+            }
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
      * Looks for next key starting from {@code start} for which primary node is {@code primary}
and backup is {@code
      * backup}.
      *


Mime
View raw message