ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [5/6] ignite git commit: ignite-1232
Date Wed, 20 Jul 2016 12:28:15 GMT
ignite-1232


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

Branch: refs/heads/ignite-1232-1
Commit: 3351b6b2bd81e918d56ed68a34b6188e816c77c9
Parents: 33560d7
Author: sboikov <sboikov@gridgain.com>
Authored: Wed Jul 20 13:30:40 2016 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Wed Jul 20 15:26:50 2016 +0300

----------------------------------------------------------------------
 .../cache/GridCacheAffinityManager.java         |  2 +-
 .../processors/query/h2/IgniteH2Indexing.java   |  6 ++---
 .../query/h2/opt/GridH2IndexBase.java           | 14 ++--------
 .../query/h2/opt/GridH2QueryContext.java        | 28 +++++++++++---------
 .../query/h2/twostep/GridMapQueryExecutor.java  | 19 +++++--------
 .../h2/twostep/GridReduceQueryExecutor.java     |  2 +-
 6 files changed, 29 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/3351b6b2/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
index 5e843dc..5e32957 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityManager.java
@@ -218,7 +218,7 @@ public class GridCacheAffinityManager extends GridCacheManagerAdapter
{
      * @param key Key.
      * @return Affinity key.
      */
-    private Object affinityKey(Object key) {
+    public Object affinityKey(Object key) {
         if (key instanceof CacheObject && !(key instanceof BinaryObject))
             key = ((CacheObject)key).value(cctx.cacheObjectContext(), false);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/3351b6b2/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index 3012f79..9c12046 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -788,7 +788,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
             return new GridQueryFieldsResultAdapter(meta, new FieldsIterator(rs));
         }
         finally {
-            GridH2QueryContext.clear(false);
+            GridH2QueryContext.clearThreadLocal();
         }
     }
 
@@ -994,7 +994,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
             return new KeyValIterator(rs);
         }
         finally {
-            GridH2QueryContext.clear(false);
+            GridH2QueryContext.clearThreadLocal();
         }
     }
 
@@ -1139,7 +1139,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
                 }
             }
             finally {
-                GridH2QueryContext.clear(false);
+                GridH2QueryContext.clearThreadLocal();
             }
 
             try {

http://git-wip-us.apache.org/repos/asf/ignite/blob/3351b6b2/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
index 42a51a0..23a3ebd 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2IndexBase.java
@@ -980,18 +980,8 @@ public abstract class GridH2IndexBase extends BaseIndex {
             if (pkFirst == null || pkLast == null || !equal(pkFirst, pkLast))
                 return null;
 
-            Object pkAffKeyFirst;
-            Object pkAffKeyLast;
-
-            GridKernalContext ctx = kernalContext();
-
-            try {
-                pkAffKeyFirst = ctx.affinity().affinityKey(cctx.name(), pkFirst.getObject());
-                pkAffKeyLast = ctx.affinity().affinityKey(cctx.name(), pkLast.getObject());
-            }
-            catch (IgniteCheckedException e) {
-                throw new CacheException(e);
-            }
+            Object pkAffKeyFirst = cctx.affinity().affinityKey(pkFirst.getObject());
+            Object pkAffKeyLast = cctx.affinity().affinityKey(pkLast.getObject());
 
             if (pkAffKeyFirst == null || pkAffKeyLast == null)
                 throw new CacheException("Cache key without affinity key.");

http://git-wip-us.apache.org/repos/asf/ignite/blob/3351b6b2/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2QueryContext.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2QueryContext.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2QueryContext.java
index 14e34d9..8d17369 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2QueryContext.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2QueryContext.java
@@ -198,7 +198,7 @@ public class GridH2QueryContext {
      * @param cctx Cache context.
      * @return Owning node ID.
      */
-    public UUID nodeForPartition(int p, GridCacheContext<?,?> cctx) {
+    public UUID nodeForPartition(int p, GridCacheContext<?, ?> cctx) {
         UUID[] nodeIds = partsNodes;
 
         if (nodeIds == null) {
@@ -206,7 +206,7 @@ public class GridH2QueryContext {
 
             nodeIds = new UUID[cctx.affinity().partitions()];
 
-            for (Map.Entry<UUID,int[]> e : partsMap.entrySet()) {
+            for (Map.Entry<UUID, int[]> e : partsMap.entrySet()) {
                 UUID nodeId = e.getKey();
                 int[] nodeParts = e.getValue();
 
@@ -356,7 +356,7 @@ public class GridH2QueryContext {
          assert qctx.get() == null;
 
          // We need MAP query context to be available to other threads to run distributed
joins.
-         if (x.key.type == MAP && qctxs.putIfAbsent(x.key, x) != null)
+         if (x.key.type == MAP && x.distributedJoins() && qctxs.putIfAbsent(x.key,
x) != null)
              throw new IllegalStateException("Query context is already set.");
 
          qctx.set(x);
@@ -364,18 +364,13 @@ public class GridH2QueryContext {
 
     /**
      * Drops current thread local context.
-     *
-     * @param onlyThreadLoc Drop only thread local context but keep global.
      */
-    public static void clear(boolean onlyThreadLoc) {
+    public static void clearThreadLocal() {
         GridH2QueryContext x = qctx.get();
 
         assert x != null;
 
         qctx.remove();
-
-        if (!onlyThreadLoc && x.key.type == MAP)
-            doClear(x.key, false);
     }
 
     /**
@@ -400,13 +395,20 @@ public class GridH2QueryContext {
         if (x == null)
             return;
 
-        x.cleared = true;
-
         assert x.key.equals(key);
 
-        x.clearSnapshots();
+        x.clearContext(nodeStop);
+    }
+
+    /**
+     * @param nodeStop Node is stopping.
+     */
+    public void clearContext(boolean nodeStop) {
+        cleared = true;
+
+        clearSnapshots();
 
-        List<GridReservable> r = x.reservations;
+        List<GridReservable> r = reservations;
 
         if (!nodeStop && !F.isEmpty(r)) {
             for (int i = 0; i < r.size(); i++)

http://git-wip-us.apache.org/repos/asf/ignite/blob/3351b6b2/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
index 90776e3..35c7aa9 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
@@ -591,7 +591,10 @@ public class GridMapQueryExecutor {
                 }
             }
             finally {
-                GridH2QueryContext.clear(distributedJoins);
+                GridH2QueryContext.clearThreadLocal();
+
+                if (!distributedJoins)
+                    qctx.clearContext(false);
 
                 if (!F.isEmpty(snapshotedTbls)) {
                     for (GridH2Table dataTbl : snapshotedTbls)
@@ -772,25 +775,17 @@ public class GridMapQueryExecutor {
          * @return {@code False} if query was already cancelled.
          */
         boolean cancelled(long qryId) {
-            Boolean old = qryHist.putIfAbsent(qryId, Boolean.TRUE);
-
-            if (old != null) {
-                assert !old;
-
-                return true;
-            }
-
-            return false;
+            return qryHist.get(qryId) != null;
         }
 
         /**
          * @param qryId Query ID.
-         * @return {@code True} if cancelled started query.
+         * @return {@code True} if cancelled.
          */
         boolean onCancel(long qryId) {
             Boolean old = qryHist.putIfAbsent(qryId, Boolean.FALSE);
 
-            return old != null && old;
+            return old == null;
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/3351b6b2/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 7727b46..2e0a2c9 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
@@ -713,7 +713,7 @@ public class GridReduceQueryExecutor {
                             resIter = new Iter(res);
                         }
                         finally {
-                            GridH2QueryContext.clear(false);
+                            GridH2QueryContext.clearThreadLocal();
                         }
                     }
                 }


Mime
View raw message