ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [34/50] [abbrv] ignite git commit: ignite-2205 - clear flag for query context
Date Mon, 15 Feb 2016 07:52:18 GMT
ignite-2205 - clear flag for query context


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

Branch: refs/heads/ignite-1232
Commit: d661395754eabe20a11f9745a502b7c3c74b0111
Parents: 9397c19
Author: S.Vladykin <svladykin@gridgain.com>
Authored: Fri Dec 25 13:00:39 2015 +0300
Committer: S.Vladykin <svladykin@gridgain.com>
Committed: Fri Dec 25 13:00:39 2015 +0300

----------------------------------------------------------------------
 .../query/h2/opt/GridH2QueryContext.java        | 25 +++++++++++++++-----
 .../query/h2/opt/GridH2TreeIndex.java           |  3 +++
 2 files changed, 22 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d6613957/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 d39d7ab..d5fc41d 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
@@ -47,6 +47,9 @@ public class GridH2QueryContext {
     /** */
     private final Key key;
 
+    /** */
+    private volatile boolean cleared;
+
     /** Index snapshots. */
     @GridToStringInclude
     private Map<Long, Object> snapshots;
@@ -357,7 +360,7 @@ public class GridH2QueryContext {
         qctx.remove();
 
         if (!onlyThreadLoc && x.key.type == MAP)
-            doClear(x.key);
+            doClear(x.key, false);
     }
 
     /**
@@ -367,13 +370,14 @@ public class GridH2QueryContext {
      * @param type Query type.
      */
     public static void clear(UUID locNodeId, UUID nodeId, long qryId, GridH2QueryType type)
{
-        doClear(new Key(locNodeId, nodeId, qryId, type));
+        doClear(new Key(locNodeId, nodeId, qryId, type), false);
     }
 
     /**
      * @param key Context key.
+     * @param nodeStop Node is stopping.
      */
-    private static void doClear(Key key) {
+    private static void doClear(Key key, boolean nodeStop) {
         assert key.type == MAP : key.type;
 
         GridH2QueryContext x = qctxs.remove(key);
@@ -381,6 +385,8 @@ public class GridH2QueryContext {
         if (x == null)
             return;
 
+        x.cleared = true;
+
         assert x.key.equals(key);
 
         if (!F.isEmpty(x.snapshots)) {
@@ -392,20 +398,27 @@ public class GridH2QueryContext {
 
         List<GridReservable> r = x.reservations;
 
-        if (!F.isEmpty(r)) {
+        if (!nodeStop && !F.isEmpty(r)) {
             for (int i = 0; i < r.size(); i++)
                 r.get(i).release();
         }
     }
 
     /**
+     * @return {@code true} If the context is cleared.
+     */
+    public boolean isCleared() {
+        return cleared;
+    }
+
+    /**
      * @param locNodeId Local node ID.
      * @param nodeId Dead node ID.
      */
     public static void clearAfterDeadNode(UUID locNodeId, UUID nodeId) {
         for (Key key : qctxs.keySet()) {
             if (key.locNodeId.equals(locNodeId) && key.nodeId.equals(nodeId))
-                doClear(key);
+                doClear(key, false);
         }
     }
 
@@ -415,7 +428,7 @@ public class GridH2QueryContext {
     public static void clearLocalNodeStop(UUID locNodeId) {
         for (Key key : qctxs.keySet()) {
             if (key.locNodeId.equals(locNodeId))
-                doClear(key);
+                doClear(key, true);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/d6613957/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
index 13414bd..95efc8e 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2TreeIndex.java
@@ -1409,6 +1409,9 @@ public class GridH2TreeIndex extends GridH2IndexBase implements Comparator<GridS
             assert remainingRanges > 0;
 
             for (int attempt = 0;; attempt++) {
+                if (qctx.isCleared())
+                    throw new GridH2RetryException("Query is cancelled.");
+
                 if (kernalContext().isStopping())
                     throw new GridH2RetryException("Stopping node.");
 


Mime
View raw message