You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vk...@apache.org on 2015/06/19 01:55:15 UTC
[12/50] incubator-ignite git commit: ignite-484-1 - small page test +
race fix
ignite-484-1 - small page test + race fix
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/8e8433b6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/8e8433b6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/8e8433b6
Branch: refs/heads/ignite-1026
Commit: 8e8433b6cc07afcdd88a0a570887fe0353e59ee7
Parents: 7e3f924
Author: S.Vladykin <sv...@gridgain.com>
Authored: Tue Jun 16 13:37:19 2015 +0300
Committer: S.Vladykin <sv...@gridgain.com>
Committed: Tue Jun 16 13:37:19 2015 +0300
----------------------------------------------------------------------
.../query/h2/twostep/GridMergeIndex.java | 17 +++++++---
.../h2/twostep/GridMergeIndexUnsorted.java | 5 +--
.../h2/twostep/GridReduceQueryExecutor.java | 4 +--
.../query/h2/twostep/GridResultPage.java | 19 ++++++-----
.../IgniteCacheQueryNodeRestartSelfTest2.java | 34 +++++++++++++++++++-
5 files changed, 59 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8e8433b6/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 9136821..af29647 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
@@ -96,7 +96,11 @@ public abstract class GridMergeIndex extends BaseIndex {
* @param nodeId Node ID.
*/
public void fail(UUID nodeId) {
- addPage0(new GridResultPage(null, nodeId, null, false));
+ addPage0(new GridResultPage(null, nodeId, null) {
+ @Override public boolean isFail() {
+ return true;
+ }
+ });
}
/**
@@ -134,10 +138,13 @@ public abstract class GridMergeIndex extends BaseIndex {
}
}
- if (last)
- last = lastSubmitted.compareAndSet(false, true);
-
- addPage0(new GridResultPage(null, page.source(), null, last));
+ if (last && lastSubmitted.compareAndSet(false, true)) {
+ addPage0(new GridResultPage(null, page.source(), null) {
+ @Override public boolean isLast() {
+ return true;
+ }
+ });
+ }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8e8433b6/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 fdee17a..e0a07ec 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
@@ -44,8 +44,9 @@ public class GridMergeIndexUnsorted extends GridMergeIndex {
/** {@inheritDoc} */
@Override protected void addPage0(GridResultPage page) {
- if (page.rowsInPage() != 0 || page.isLast() || queue.isEmpty())
- queue.add(page);
+ assert page.rowsInPage() > 0 || page.isLast() || page.isFail();
+
+ queue.add(page);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8e8433b6/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 343a439..c570d24 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
@@ -229,7 +229,7 @@ public class GridReduceQueryExecutor {
GridResultPage page;
try {
- page = new GridResultPage(ctx, node.id(), msg, false) {
+ page = new GridResultPage(ctx, node.id(), msg) {
@Override public void fetchNextPage() {
Object errState = r.state.get();
@@ -251,7 +251,7 @@ public class GridReduceQueryExecutor {
ctx.io().send(node, GridTopic.TOPIC_QUERY, msg0, GridIoPolicy.PUBLIC_POOL);
}
catch (IgniteCheckedException e) {
- throw new CacheException(e);
+ throw new CacheException("Failed to fetch data from node: " + node.id(), e);
}
}
};
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8e8433b6/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridResultPage.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridResultPage.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridResultPage.java
index 35bfab9..c9a7e48 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridResultPage.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridResultPage.java
@@ -43,27 +43,19 @@ public class GridResultPage {
private final int rowsInPage;
/** */
- private final boolean last;
-
- /** */
private Iterator<Value[]> rows;
/**
* @param ctx Kernal context.
* @param src Source.
* @param res Response.
- * @param last If this is the globally last page.
*/
@SuppressWarnings("unchecked")
- public GridResultPage(final GridKernalContext ctx, UUID src, GridQueryNextPageResponse res, boolean last) {
+ public GridResultPage(final GridKernalContext ctx, UUID src, GridQueryNextPageResponse res) {
assert src != null;
this.src = src;
this.res = res;
- this.last = last;
-
- if (last)
- assert res == null : "The last page must be dummy.";
// res == null means that it is a terminating dummy page for the given source node ID.
if (res != null) {
@@ -117,10 +109,17 @@ public class GridResultPage {
}
/**
+ * @return {@code true} If this is a dummy fail page.
+ */
+ public boolean isFail() {
+ return false;
+ }
+
+ /**
* @return {@code true} If this is a dummy last page for all the sources.
*/
public boolean isLast() {
- return last;
+ return false;
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/8e8433b6/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java
index e65cc13..d440b13 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest2.java
@@ -32,6 +32,7 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
import org.apache.ignite.testframework.junits.common.*;
+import javax.cache.*;
import java.io.*;
import java.util.*;
import java.util.concurrent.*;
@@ -215,7 +216,38 @@ public class IgniteCacheQueryNodeRestartSelfTest2 extends GridCommonAbstractTest
if (rnd.nextBoolean()) { // Partitioned query.
IgniteCache<?,?> cache = grid(g).cache("pu");
- assertEquals(pRes, cache.query(new SqlFieldsQuery(PARTITIONED_QRY)).getAll());
+ SqlFieldsQuery qry = new SqlFieldsQuery(PARTITIONED_QRY);
+
+ boolean smallPageSize = rnd.nextBoolean();
+
+ if (smallPageSize)
+ qry.setPageSize(3);
+
+ try {
+ assertEquals(pRes, cache.query(qry).getAll());
+ }
+ catch (CacheException e) {
+ assertTrue("On large page size must retry.", smallPageSize);
+
+ boolean failedOnRemoteFetch = false;
+
+ for (Throwable th = e; th != null; th = th.getCause()) {
+ if (!(th instanceof CacheException))
+ continue;
+
+ if (th.getMessage().startsWith("Failed to fetch data from node:")) {
+ failedOnRemoteFetch = true;
+
+ break;
+ }
+ }
+
+ if (!failedOnRemoteFetch) {
+ e.printStackTrace();
+
+ fail("Must fail inside of GridResultPage.fetchNextPage or subclass.");
+ }
+ }
}
else { // Replicated query.
IgniteCache<?,?> cache = grid(g).cache("co");