IGNITE-6355 Calculating cache size during cache stop sporadically fails with 
ClusterGroupEmptyCheckedException - Fixes #2647.

Signed-off-by: Alexey Goncharuk <[email protected]>

(cherry picked from commit 0dd9755)

(cherry picked from commit 297ed38)


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

Branch: refs/heads/ignite-2.1.5-p1
Commit: 9f5c9e385e258c48ce29ca4e9cec222f737eb910
Parents: 7daefd2
Author: Ivan Rakov <[email protected]>
Authored: Mon Sep 18 16:58:10 2017 +0300
Committer: Dmitriy Govorukhin <[email protected]>
Committed: Fri Sep 22 15:29:09 2017 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheAdapter.java         | 17 ++++++-----------
 .../processors/cache/IgniteCacheProxyImpl.java     |  8 ++++----
 2 files changed, 10 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/9f5c9e38/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 382b94d..40f2b49 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
@@ -3730,20 +3730,15 @@ public abstract class GridCacheAdapter<K, V> implements 
IgniteInternalCache<K, V
 
         ClusterGroup grp = modes.near ? cluster.forCacheNodes(name(), true, 
true, false) : cluster.forDataNodes(name());
 
-        Collection<ClusterNode> nodes = grp.nodes();
+        Collection<ClusterNode> nodes = new ArrayList<>(grp.nodes());
 
         if (nodes.isEmpty())
             return new GridFinishedFuture<>(0);
 
         ctx.kernalContext().task().setThreadContext(TC_SUBGRID, nodes);
 
-        try {
-            return ctx.kernalContext().task().execute(
-                new SizeTask(ctx.name(), 
ctx.affinity().affinityTopologyVersion(), peekModes), null);
-        }
-        catch (ClusterGroupEmptyException e) {
-            return new GridFinishedFuture<>(0);
-        }
+        return ctx.kernalContext().task().execute(
+            new SizeTask(ctx.name(), ctx.affinity().affinityTopologyVersion(), 
peekModes), null);
     }
 
     /** {@inheritDoc} */
@@ -3756,7 +3751,7 @@ public abstract class GridCacheAdapter<K, V> implements 
IgniteInternalCache<K, V
 
         ClusterGroup grp = modes.near ? cluster.forCacheNodes(name(), true, 
true, false) : cluster.forDataNodes(name());
 
-        Collection<ClusterNode> nodes = grp.nodes();
+        Collection<ClusterNode> nodes = new ArrayList<>(grp.nodes());
 
         if (nodes.isEmpty())
             return new GridFinishedFuture<>(0L);
@@ -3779,13 +3774,13 @@ public abstract class GridCacheAdapter<K, V> implements 
IgniteInternalCache<K, V
 
         ClusterGroup grp = cluster.forDataNodes(name());
 
-        Collection<ClusterNode> nodes = grp.forPredicate(new 
IgnitePredicate<ClusterNode>() {
+        Collection<ClusterNode> nodes = new ArrayList<>(grp.forPredicate(new 
IgnitePredicate<ClusterNode>() {
             /** {@inheritDoc} */
             @Override public boolean apply(ClusterNode clusterNode) {
                 return ((modes.primary && aff.primaryByPartition(clusterNode, 
part, topVer)) ||
                         (modes.backup && aff.backupByPartition(clusterNode, 
part, topVer)));
             }
-        }).nodes();
+        }).nodes());
 
         if (nodes.isEmpty())
             return new GridFinishedFuture<>(0L);

http://git-wip-us.apache.org/repos/asf/ignite/blob/9f5c9e38/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
index 54fcafa..337c1bb 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxyImpl.java
@@ -1662,10 +1662,10 @@ public class IgniteCacheProxyImpl<K, V> extends 
AsyncSupportAdapter<IgniteCache<
     private RuntimeException cacheException(Exception e) {
         GridFutureAdapter<Void> restartFut = this.restartFut.get();
 
-        if (restartFut != null && !restartFut.isDone()) {
+        if (restartFut != null) {
             if (X.hasCause(e, CacheStoppedException.class) || 
X.hasSuppressed(e, CacheStoppedException.class))
                 throw new IgniteCacheRestartingException(new 
IgniteFutureImpl<>(restartFut), "Cache is restarting: " +
-                        ctx.name());
+                        ctx.name(), e);
         }
 
         if (e instanceof IgniteCheckedException)
@@ -1816,9 +1816,9 @@ public class IgniteCacheProxyImpl<K, V> extends 
AsyncSupportAdapter<IgniteCache<
         this.ctx = ctx;
         this.delegate = delegate;
 
-        restartFut.onDone();
-
         this.restartFut.compareAndSet(restartFut, null);
+
+        restartFut.onDone();
     }
 
     /** {@inheritDoc} */

Reply via email to