ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yzhda...@apache.org
Subject [12/13] ignite git commit: ignite-db - fix for NPE GG-11088
Date Fri, 29 Apr 2016 17:01:59 GMT
ignite-db - fix for NPE GG-11088


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

Branch: refs/heads/ignite-db-x-gg-11124
Commit: edb1692569aebcd9cd21c0b12d1ea835d086f055
Parents: 4c84e80
Author: S.Vladykin <svladykin@gridgain.com>
Authored: Fri Apr 29 15:00:20 2016 +0300
Committer: S.Vladykin <svladykin@gridgain.com>
Committed: Fri Apr 29 15:00:20 2016 +0300

----------------------------------------------------------------------
 .../query/h2/twostep/GridMergeIndex.java        | 32 +++++++++++++++++---
 .../h2/twostep/GridMergeIndexUnsorted.java      | 19 +++++++-----
 .../query/h2/twostep/GridMergeTable.java        | 16 +---------
 .../h2/twostep/GridReduceQueryExecutor.java     |  2 +-
 4 files changed, 41 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/edb16925/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndex.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndex.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndex.java
index 12c2240..3914bd7 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndex.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndex.java
@@ -28,6 +28,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 import javax.cache.CacheException;
 import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.GridKernalContext;
 import org.h2.engine.Constants;
 import org.h2.engine.Session;
 import org.h2.index.BaseIndex;
@@ -69,21 +70,31 @@ public abstract class GridMergeIndex extends BaseIndex {
     /** */
     private int fetchedCnt;
 
+    /** */
+    private final GridKernalContext ctx;
+
     /**
+     * @param ctx Context.
      * @param tbl Table.
      * @param name Index name.
      * @param type Type.
      * @param cols Columns.
      */
-    public GridMergeIndex(GridMergeTable tbl, String name, IndexType type, IndexColumn[]
cols) {
+    public GridMergeIndex(GridKernalContext ctx,
+        GridMergeTable tbl,
+        String name,
+        IndexType type,
+        IndexColumn[] cols) {
+        this.ctx = ctx;
+
         initBaseIndex(tbl, 0, name, cols, type);
     }
 
     /**
-     *
+     * @param ctx Context.
      */
-    protected GridMergeIndex() {
-        // No-op.
+    protected GridMergeIndex(GridKernalContext ctx) {
+        this.ctx = ctx;
     }
 
     /**
@@ -94,6 +105,19 @@ public abstract class GridMergeIndex extends BaseIndex {
     }
 
     /**
+     * Fails index if any source node is left.
+     */
+    protected final void checkSourceNodesAlive() {
+        for (UUID nodeId : sources()) {
+            if (!ctx.discovery().alive(nodeId)) {
+                fail(nodeId);
+
+                return;
+            }
+        }
+    }
+
+    /**
      * @param nodeId Node ID.
      * @return {@code true} If this index needs data from the given source node.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/edb16925/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndexUnsorted.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndexUnsorted.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndexUnsorted.java
index 501480a..5639340 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndexUnsorted.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeIndexUnsorted.java
@@ -24,6 +24,7 @@ import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
 import javax.cache.CacheException;
+import org.apache.ignite.internal.GridKernalContext;
 import org.h2.index.Cursor;
 import org.h2.index.IndexType;
 import org.h2.result.Row;
@@ -40,25 +41,27 @@ public class GridMergeIndexUnsorted extends GridMergeIndex {
     private final BlockingQueue<GridResultPage> queue = new LinkedBlockingQueue<>();
 
     /**
+     * @param ctx Context.
      * @param tbl  Table.
      * @param name Index name.
      */
-    public GridMergeIndexUnsorted(GridMergeTable tbl, String name) {
-        super(tbl, name, IndexType.createScan(false), IndexColumn.wrap(tbl.getColumns()));
+    public GridMergeIndexUnsorted(GridKernalContext ctx, GridMergeTable tbl, String name)
{
+        super(ctx, tbl, name, IndexType.createScan(false), IndexColumn.wrap(tbl.getColumns()));
     }
 
     /**
+     * @param ctx Context.
      * @return Dummy index instance.
      */
-    public static GridMergeIndexUnsorted createDummy() {
-        return new GridMergeIndexUnsorted();
+    public static GridMergeIndexUnsorted createDummy(GridKernalContext ctx) {
+        return new GridMergeIndexUnsorted(ctx);
     }
 
     /**
-     *
+     * @param ctx Context.
      */
-    private GridMergeIndexUnsorted() {
-        // No-op.
+    private GridMergeIndexUnsorted(GridKernalContext ctx) {
+        super(ctx);
     }
 
     /** {@inheritDoc} */
@@ -94,7 +97,7 @@ public class GridMergeIndexUnsorted extends GridMergeIndex {
                         if (page != null)
                             break;
 
-                        ((GridMergeTable)table).checkSourceNodesAlive();
+                        checkSourceNodesAlive();
                     }
 
                     if (page.isLast())

http://git-wip-us.apache.org/repos/asf/ignite/blob/edb16925/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeTable.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeTable.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeTable.java
index adfd220..a86cbcd 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeTable.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMergeTable.java
@@ -18,7 +18,6 @@
 package org.apache.ignite.internal.processors.query.h2.twostep;
 
 import java.util.ArrayList;
-import java.util.UUID;
 import org.apache.ignite.internal.GridKernalContext;
 import org.h2.command.ddl.CreateTableData;
 import org.h2.engine.Session;
@@ -47,20 +46,7 @@ public class GridMergeTable extends TableBase {
         super(data);
 
         this.ctx = ctx;
-        idx = new GridMergeIndexUnsorted(this, "merge_scan");
-    }
-
-    /**
-     * Fails merge table if any source node is left.
-     */
-    public void checkSourceNodesAlive() {
-        for (UUID nodeId : idx.sources()) {
-            if (!ctx.discovery().alive(nodeId)) {
-                idx.fail(nodeId);
-
-                return;
-            }
-        }
+        idx = new GridMergeIndexUnsorted(ctx, this, "merge_scan");
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/edb16925/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 828d9bd..47ab083 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
@@ -532,7 +532,7 @@ public class GridReduceQueryExecutor {
                     fakeTable(r.conn, tblIdx++).setInnerTable(tbl);
                 }
                 else
-                    idx = GridMergeIndexUnsorted.createDummy();
+                    idx = GridMergeIndexUnsorted.createDummy(ctx);
 
                 for (ClusterNode node : nodes)
                     idx.addSource(node.id());


Mime
View raw message