ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject incubator-ignite git commit: ignite-929
Date Wed, 10 Jun 2015 18:15:19 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-929 9faf635b6 -> 00eb9f192


ignite-929


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

Branch: refs/heads/ignite-929
Commit: 00eb9f192c104c855a42832978086a282bcdb12e
Parents: 9faf635
Author: avinogradov <avinogradov@gridgain.com>
Authored: Wed Jun 10 21:15:06 2015 +0300
Committer: avinogradov <avinogradov@gridgain.com>
Committed: Wed Jun 10 21:15:06 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheGateway.java      | 27 ++++++++++-
 .../processors/cache/GridCacheProcessor.java    |  9 ++++
 .../processors/cache/IgniteCacheProxy.java      |  4 +-
 .../cache/CacheStopAndDestroySelfTest.java      | 48 ++++++++++++++++++--
 4 files changed, 80 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/00eb9f19/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheGateway.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheGateway.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheGateway.java
index d9d151c..b66fe7b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheGateway.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheGateway.java
@@ -35,6 +35,9 @@ public class GridCacheGateway<K, V> {
     /** Stopped flag for dynamic caches. */
     private volatile boolean stopped;
 
+    /** Closed flag for dynamic caches. */
+    private volatile boolean closed;
+
     /** */
     private GridSpinReadWriteLock rwLock = new GridSpinReadWriteLock();
 
@@ -68,7 +71,7 @@ public class GridCacheGateway<K, V> {
      *
      * @return {@code True} if enter successful, {@code false} if the cache or the node was
stopped.
      */
-    public boolean enterIfNotClosed() {
+    public boolean enterIfNotStopped() {
         onEnter();
 
         // Must unlock in case of unexpected errors to avoid
@@ -89,7 +92,7 @@ public class GridCacheGateway<K, V> {
      *
      * @return {@code True} if enter successful, {@code false} if the cache or the node was
stopped.
      */
-    public boolean enterIfNotClosedNoLock() {
+    public boolean enterIfNotStoppedNoLock() {
         onEnter();
 
         return !stopped;
@@ -150,6 +153,12 @@ public class GridCacheGateway<K, V> {
             throw new IllegalStateException("Cache has been stopped: " + ctx.name());
         }
 
+        if (closed) {
+            rwLock.readUnlock();
+
+            throw new IllegalStateException("Cache has been closed: " + ctx.name());
+        }
+
         // Must unlock in case of unexpected errors to avoid
         // deadlocks during kernal stop.
         try {
@@ -236,6 +245,20 @@ public class GridCacheGateway<K, V> {
     /**
      *
      */
+    public void open() {
+        closed = false;
+    }
+
+    /**
+     *
+     */
+    public void close() {
+        closed = true;
+    }
+
+    /**
+     *
+     */
     public void onStopped() {
         boolean interrupted = false;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/00eb9f19/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 c81e6aa..5415b22 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
@@ -1988,6 +1988,12 @@ public class GridCacheProcessor extends GridProcessorAdapter {
         if (cfg.getCacheMode() == LOCAL)
             return dynamicDestroyCache(cacheName);
         else {
+            IgniteCacheProxy<?, ?> proxy = jCacheProxies.get(maskNull(cacheName));
+
+            // Closing gateway first.
+            if (proxy != null)
+                proxy.gate().close();
+
             GridCacheAdapter<?, ?> cache = caches.get(maskNull(cacheName));
 
             if (cache != null && !cache.context().affinityNode()) {
@@ -2668,6 +2674,9 @@ public class GridCacheProcessor extends GridProcessorAdapter {
         if (cache == null)
            cache = startJCache(cacheName, failIfNotStarted);
 
+        if (cache != null)
+            cache.gate().open();
+
         return (IgniteCacheProxy<K, V>)cache;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/00eb9f19/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
index ff8135b..f3240d9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
@@ -1588,9 +1588,9 @@ public class IgniteCacheProxy<K, V> extends AsyncSupportAdapter<IgniteCache<K,
V
      */
     private boolean onEnterIfNoClose() {
         if (lock)
-            return gate.enterIfNotClosed();
+            return gate.enterIfNotStopped();
         else
-            return gate.enterIfNotClosedNoLock();
+            return gate.enterIfNotStoppedNoLock();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/00eb9f19/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStopAndDestroySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStopAndDestroySelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStopAndDestroySelfTest.java
index 6812bb7..e0c18cb 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStopAndDestroySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheStopAndDestroySelfTest.java
@@ -116,6 +116,7 @@ public class CacheStopAndDestroySelfTest extends GridCommonAbstractTest
{
         CacheConfiguration cfg = defaultCacheConfiguration();
         cfg.setName(CACHE_NAME_DHT);
         cfg.setCacheMode(CacheMode.PARTITIONED);
+        cfg.setNearConfiguration(null);
         return cfg;
     }
 
@@ -126,6 +127,7 @@ public class CacheStopAndDestroySelfTest extends GridCommonAbstractTest
{
         CacheConfiguration cfg = defaultCacheConfiguration();
         cfg.setName(CACHE_NAME_CLIENT);
         cfg.setCacheMode(CacheMode.PARTITIONED);
+        cfg.setNearConfiguration(null);
         return cfg;
     }
 
@@ -147,6 +149,7 @@ public class CacheStopAndDestroySelfTest extends GridCommonAbstractTest
{
         CacheConfiguration cfg = defaultCacheConfiguration();
         cfg.setName(CACHE_NAME_LOC);
         cfg.setCacheMode(CacheMode.LOCAL);
+        cfg.setNearConfiguration(null);
         return cfg;
     }
 
@@ -374,7 +377,14 @@ public class CacheStopAndDestroySelfTest extends GridCommonAbstractTest
{
 
         dhtCache0.close();
 
-        assert dhtCache0.get(KEY_VAL).equals(KEY_VAL);// Not affected.
+        try {
+            dhtCache0.get(KEY_VAL);// Not affected, but can not be taken.
+            assert false;
+        }
+        catch (IllegalStateException ignored) {
+            // No-op
+        }
+
         assert dhtCache1.get(KEY_VAL).equals(KEY_VAL);// Not affected.
         assert dhtCache2.get(KEY_VAL).equals(KEY_VAL);// Not affected.
 
@@ -382,11 +392,41 @@ public class CacheStopAndDestroySelfTest extends GridCommonAbstractTest
{
 
         dhtCache0 = grid(0).cache(CACHE_NAME_DHT);
 
-        dhtCache0.put(KEY_VAL, KEY_VAL + "recreated");
+        assert dhtCache0.get(KEY_VAL).equals(KEY_VAL);// Not affected, can be taken since
cache reopened.
+
+        dhtCache2.put(KEY_VAL, KEY_VAL + "recreated");
 
         assert dhtCache0.get(KEY_VAL).equals(KEY_VAL + "recreated");
-        assert dhtCache0.get(KEY_VAL).equals(KEY_VAL + "recreated");
-        assert dhtCache0.get(KEY_VAL).equals(KEY_VAL + "recreated");
+
+        //Check close at last node.
+
+        stopAllGrids(true);
+
+        startGrid(0);
+
+        dhtCache0 = grid(0).getOrCreateCache(getDhtConfig());
+
+        assert dhtCache0.get(KEY_VAL) == null;
+
+        dhtCache0.put(KEY_VAL, KEY_VAL);
+
+        assert dhtCache0.get(KEY_VAL).equals(KEY_VAL);
+
+        // Closing last node.
+        dhtCache0.close();
+
+        try {
+            dhtCache0.get(KEY_VAL);// Can not be taken.
+            assert false;
+        }
+        catch (IllegalStateException ignored) {
+            // No-op
+        }
+
+        // Reopening cache.
+        dhtCache0 = grid(0).cache(CACHE_NAME_DHT);
+
+        assert dhtCache0.get(KEY_VAL).equals(KEY_VAL);// Entry not loosed.
     }
 
     /**


Mime
View raw message