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 2017/05/17 14:01:42 UTC

[8/9] ignite git commit: Minors.

Minors.


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

Branch: refs/heads/ignite-5054-splitter-2
Commit: 1acf0b7f6f7c580e55514feb4c794735da9ccf34
Parents: 4a26787
Author: devozerov <vo...@gridgain.com>
Authored: Wed May 17 16:28:53 2017 +0300
Committer: devozerov <vo...@gridgain.com>
Committed: Wed May 17 16:28:53 2017 +0300

----------------------------------------------------------------------
 .../h2/twostep/GridReduceQueryExecutor.java     | 45 ++++++++++----------
 1 file changed, 23 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/1acf0b7f/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
index 4b31ef6..75914ef 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridReduceQueryExecutor.java
@@ -865,11 +865,14 @@ public class GridReduceQueryExecutor {
      * @return The first partitioned cache context.
      */
     private GridCacheContext<?,?> findFirstPartitioned(List<Integer> cacheIds) {
-        for (Integer cacheId : cacheIds) {
-            GridCacheContext<?, ?> extraCctx = cacheContext(cacheId);
+        for (int i = 0; i < cacheIds.size(); i++) {
+            GridCacheContext<?, ?> cctx = cacheContext(cacheIds.get(i));
+
+            if (i == 0 && cctx.isLocal())
+                throw new CacheException("Cache is LOCAL: " + cctx.name());
 
-            if (!extraCctx.isReplicated() && !extraCctx.isLocal())
-                return extraCctx;
+            if (!cctx.isReplicated() && !cctx.isLocal())
+                return cctx;
         }
 
         throw new IllegalStateException("Failed to find partitioned cache.");
@@ -982,10 +985,10 @@ public class GridReduceQueryExecutor {
      * @return Collection of all data nodes owning all the caches or {@code null} for retry.
      */
     private Collection<ClusterNode> replicatedUnstableDataNodes(List<Integer> cacheIds) {
-        GridCacheContext<?, ?> cctx = cacheContext(cacheIds.get(0));
-
         int i = 0;
 
+        GridCacheContext<?, ?> cctx = cacheContext(cacheIds.get(i++));
+
         // The main cache is allowed to be partitioned.
         if (!cctx.isReplicated()) {
             assert cacheIds.size() > 1: "no extra replicated caches with partitioned main cache";
@@ -1001,28 +1004,26 @@ public class GridReduceQueryExecutor {
         if (F.isEmpty(nodes))
             return null; // Retry.
 
-        if (cacheIds.size() > 1) {
-            for (;i < cacheIds.size(); i++) {
-                GridCacheContext<?, ?> extraCctx = cacheContext(cacheIds.get(i));
+        for (;i < cacheIds.size(); i++) {
+            GridCacheContext<?, ?> extraCctx = cacheContext(cacheIds.get(i));
 
-                if (extraCctx.isLocal())
-                    continue;
+            if (extraCctx.isLocal())
+                continue;
 
-                if (!extraCctx.isReplicated())
-                    throw new CacheException("Queries running on replicated cache should not contain JOINs " +
-                        "with tables in partitioned caches [replicatedCache=" + cctx.name() + ", " +
-                        "partitionedCache=" + extraCctx.name() + "]");
+            if (!extraCctx.isReplicated())
+                throw new CacheException("Queries running on replicated cache should not contain JOINs " +
+                    "with tables in partitioned caches [replicatedCache=" + cctx.name() + ", " +
+                    "partitionedCache=" + extraCctx.name() + "]");
 
-                Set<ClusterNode> extraOwners = replicatedUnstableDataNodes(extraCctx);
+            Set<ClusterNode> extraOwners = replicatedUnstableDataNodes(extraCctx);
 
-                if (F.isEmpty(extraOwners))
-                    return null; // Retry.
+            if (F.isEmpty(extraOwners))
+                return null; // Retry.
 
-                nodes.retainAll(extraOwners);
+            nodes.retainAll(extraOwners);
 
-                if (nodes.isEmpty())
-                    return null; // Retry.
-            }
+            if (nodes.isEmpty())
+                return null; // Retry.
         }
 
         return nodes;