ignite-484 - minor
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/7436a512 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/7436a512 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/7436a512 Branch: refs/heads/ignite-484 Commit: 7436a5129a67700f0dee7b2d07277d8732df24b8 Parents: 5e877cc Author: S.Vladykin <svlady...@gridgain.com> Authored: Tue May 19 23:44:48 2015 +0300 Committer: S.Vladykin <svlady...@gridgain.com> Committed: Tue May 19 23:44:48 2015 +0300 ---------------------------------------------------------------------- .../processors/query/h2/IgniteH2Indexing.java | 7 +++ .../query/h2/twostep/GridMapQueryExecutor.java | 59 +------------------- .../h2/twostep/GridReduceQueryExecutor.java | 15 ++--- .../IgniteCacheQueryNodeRestartSelfTest.java | 2 + 4 files changed, 14 insertions(+), 69 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7436a512/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 31a33ef..676dce8 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 @@ -1392,6 +1392,13 @@ public class IgniteH2Indexing implements GridQueryIndexing { } /** + * @return Current topology version. + */ + public AffinityTopologyVersion topologyVersion() { + return ctx.discovery().topologyVersionEx(); + } + + /** * Wrapper to store connection and flag is schema set or not. */ private static class ConnectionWrapper { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7436a512/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 39595b1..aadc511 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 @@ -36,7 +36,6 @@ import org.apache.ignite.marshaller.*; import org.apache.ignite.plugin.extensions.communication.*; import org.h2.jdbc.*; import org.h2.result.*; -import org.h2.store.*; import org.h2.value.*; import org.jetbrains.annotations.*; import org.jsr166.*; @@ -465,68 +464,12 @@ public class GridMapQueryExecutor { loc ? null : Collections.<Message>emptyList(), loc ? Collections.<Value[]>emptyList() : null); - msg.retry(ctx.discovery().topologyVersionEx()); + msg.retry(h2.topologyVersion()); ctx.io().send(node, GridTopic.TOPIC_QUERY, msg, GridIoPolicy.PUBLIC_POOL); } /** - * @param bytes Bytes. - * @return Rows. - */ - public static List<Value[]> unmarshallRows(byte[] bytes) { - Data data = Data.create(null, bytes); - - int rowCnt = data.readVarInt(); - - if (rowCnt == 0) - return Collections.emptyList(); - - ArrayList<Value[]> rows = new ArrayList<>(rowCnt); - - int cols = data.readVarInt(); - - for (int r = 0; r < rowCnt; r++) { - Value[] row = new Value[cols]; - - for (int c = 0; c < cols; c++) - row[c] = data.readValue(); - - rows.add(row); - } - - return rows; - } - - /** - * @param rows Rows. - * @return Bytes. - */ - public static byte[] marshallRows(Collection<Value[]> rows) { - Data data = Data.create(null, 256); - - data.writeVarInt(rows.size()); - - boolean first = true; - - for (Value[] row : rows) { - if (first) { - data.writeVarInt(row.length); - - first = false; - } - - for (Value val : row) { - data.checkCapacity(data.getValueLen(val)); - - data.writeValue(val); - } - } - - return Arrays.copyOf(data.getBytes(), data.length()); - } - - /** * */ private class QueryResults { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7436a512/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 bb6801c..eb6db88 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 @@ -118,7 +118,7 @@ public class GridReduceQueryExecutor { * @param h2 H2 Indexing. * @throws IgniteCheckedException If failed. */ - public void start(final GridKernalContext ctx, IgniteH2Indexing h2) throws IgniteCheckedException { + public void start(final GridKernalContext ctx, final IgniteH2Indexing h2) throws IgniteCheckedException { this.ctx = ctx; this.h2 = h2; @@ -146,7 +146,7 @@ public class GridReduceQueryExecutor { for (GridMergeTable tbl : r.tbls) { if (tbl.getScanIndex(null).hasSource(nodeId)) { // Will attempt to retry. If reduce query was started it will fail on next page fetching. - retry(r, topologyVersion(), nodeId); + retry(r, h2.topologyVersion(), nodeId); break; } @@ -279,13 +279,6 @@ public class GridReduceQueryExecutor { } /** - * @return Current topology version. - */ - private AffinityTopologyVersion topologyVersion() { - return ctx.discovery().topologyVersionEx(); - } - - /** * @param cctx Cache context. * @param qry Query. * @return Cursor. @@ -304,7 +297,7 @@ public class GridReduceQueryExecutor { r.conn = (JdbcConnection)h2.connectionForSpace(space); - AffinityTopologyVersion topVer = topologyVersion(); + AffinityTopologyVersion topVer = h2.topologyVersion(); Collection<ClusterNode> nodes = ctx.discovery().cacheAffinityNodes(space, topVer); @@ -387,7 +380,7 @@ public class GridReduceQueryExecutor { } } else // Send failed -> retry. - retry = topologyVersion(); + retry = h2.topologyVersion(); ResultSet res = null; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7436a512/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest.java index 4edef55..128e148 100644 --- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest.java +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/IgniteCacheQueryNodeRestartSelfTest.java @@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.cache.distributed.near; import org.apache.ignite.*; import org.apache.ignite.cache.*; +import org.apache.ignite.cache.affinity.rendezvous.*; import org.apache.ignite.cache.query.*; import org.apache.ignite.configuration.*; import org.apache.ignite.events.*; @@ -79,6 +80,7 @@ public class IgniteCacheQueryNodeRestartSelfTest extends GridCacheAbstractSelfTe cc.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); cc.setAtomicityMode(TRANSACTIONAL); cc.setRebalanceMode(CacheRebalanceMode.SYNC); + cc.setAffinity(new RendezvousAffinityFunction(false, 15)); cc.setIndexedTypes( Integer.class, Integer.class );