You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2016/09/15 06:40:36 UTC
[38/40] ignite git commit: IGNITE-3421: Add ability to configure
maxIterCnt property in GridCacheQueryManager. - Fixes #1055.
IGNITE-3421: Add ability to configure maxIterCnt property in GridCacheQueryManager. - Fixes #1055.
Signed-off-by: shtykh_roman <rs...@yahoo.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8b8b02e2
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8b8b02e2
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8b8b02e2
Branch: refs/heads/ignite-comm-opts1
Commit: 8b8b02e27d78c89c5594fb57ec41bff8cf87a9d7
Parents: 3fb9894
Author: shtykh_roman <rs...@yahoo.com>
Authored: Thu Sep 15 10:40:38 2016 +0900
Committer: shtykh_roman <rs...@yahoo.com>
Committed: Thu Sep 15 10:40:38 2016 +0900
----------------------------------------------------------------------
.../configuration/CacheConfiguration.java | 35 ++++++++++++++++++--
.../cache/query/GridCacheQueryManager.java | 13 +++-----
...gniteCacheReplicatedFieldsQuerySelfTest.java | 6 ++--
.../IgniteCacheReplicatedQuerySelfTest.java | 4 +--
4 files changed, 42 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/8b8b02e2/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index 64b7e1f..e28aad5 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@ -191,6 +191,9 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
/** Default batch size for write-behind cache store. */
public static final int DFLT_WRITE_BEHIND_BATCH_SIZE = 512;
+ /** Default maximum number of query iterators that can be stored. */
+ public static final int DFLT_MAX_QUERY_ITERATOR_CNT = 1024;
+
/** Default value for load previous value flag. */
public static final boolean DFLT_LOAD_PREV_VAL = false;
@@ -209,7 +212,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
/** Default size for onheap SQL row cache size. */
public static final int DFLT_SQL_ONHEAP_ROW_CACHE_SIZE = 10 * 1024;
- /** Default value for keep binary in store behavior .*/
+ /** Default value for keep binary in store behavior . */
@SuppressWarnings({"UnnecessaryBoxing", "BooleanConstructorCall"})
public static final Boolean DFLT_STORE_KEEP_BINARY = new Boolean(false);
@@ -334,6 +337,9 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
/** Maximum batch size for write-behind cache store. */
private int writeBehindBatchSize = DFLT_WRITE_BEHIND_BATCH_SIZE;
+ /** Maximum number of query iterators that can be stored. */
+ private int maxQryIterCnt = DFLT_MAX_QUERY_ITERATOR_CNT;
+
/** Memory mode. */
private CacheMemoryMode memMode = DFLT_MEMORY_MODE;
@@ -886,7 +892,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
/**
* Sets factory for persistent storage for cache data.
-
+ *
* @param storeFactory Cache store factory.
* @return {@code this} for chaining.
*/
@@ -1632,6 +1638,31 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
}
/**
+ * Gets maximum number of query iterators that can be stored. Iterators are stored to
+ * support query pagination when each page of data is sent to user's node only on demand.
+ * Increase this property if you are running and processing lots of queries in parallel.
+ * <p>
+ * Default value is {@link #DFLT_MAX_QUERY_ITERATOR_CNT}.
+ *
+ * @return Maximum number of query iterators that can be stored.
+ */
+ public int getMaxQueryIteratorsCount() {
+ return maxQryIterCnt;
+ }
+
+ /**
+ * Sets maximum number of query iterators that can be stored.
+ *
+ * @param maxQryIterCnt Maximum number of query iterators that can be stored.
+ * @return {@code this} for chaining.
+ */
+ public CacheConfiguration<K, V> setMaxQueryIteratorsCount(int maxQryIterCnt) {
+ this.maxQryIterCnt = maxQryIterCnt;
+
+ return this;
+ }
+
+ /**
* Gets memory mode for cache. Memory mode helps control whether value is stored in on-heap memory,
* off-heap memory, or swap space. Refer to {@link CacheMemoryMode} for more info.
* <p>
http://git-wip-us.apache.org/repos/asf/ignite/blob/8b8b02e2/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
index 4b4275f..b1fa589 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
@@ -135,9 +135,6 @@ import static org.apache.ignite.internal.processors.cache.query.GridCacheQueryTy
@SuppressWarnings("FieldAccessedSynchronizedAndUnsynchronized")
public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapter<K, V> {
/** */
- public static int MAX_ITERATORS = 1000;
-
- /** */
protected GridQueryProcessor qryProc;
/** */
@@ -176,7 +173,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
@Override public void start0() throws IgniteCheckedException {
qryProc = cctx.kernalContext().query();
space = cctx.name();
- maxIterCnt = MAX_ITERATORS;
+ maxIterCnt = cctx.config().getMaxQueryIteratorsCount();
lsnr = new GridLocalEventListener() {
@Override public void onEvent(Event evt) {
@@ -538,7 +535,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
throw new IgniteCheckedException("Received next page request after iterator was removed. " +
"Consider increasing maximum number of stored iterators (see " +
- "GridCacheConfiguration.getMaximumQueryIteratorCount() configuration property).");
+ "CacheConfiguration.getMaxQueryIteratorsCount() configuration property).");
}
QueryResult<K, V> res;
@@ -660,7 +657,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
throw new IgniteCheckedException("Received next page request after iterator was removed. " +
"Consider increasing maximum number of stored iterators (see " +
- "GridCacheConfiguration.getMaximumQueryIteratorCount() configuration property).");
+ "CacheConfiguration.getMaxQueryIteratorsCount() configuration property).");
}
if (qry.type() == SQL_FIELDS) {
@@ -1615,7 +1612,6 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
else
data.add(!loc ? new GridCacheQueryResponseEntry<>(key, val) : F.t(key, val));
-
if (!loc) {
if (++cnt == pageSize || !iter.hasNext()) {
boolean finished = !iter.hasNext();
@@ -1776,10 +1772,9 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
if (qry.keepBinary())
entry = cctx.cache().keepBinary().getEntry(next.getKey());
- else
+ else
entry = cctx.cache().getEntry(next.getKey());
-
return transform.apply(entry);
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/8b8b02e2/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedFieldsQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedFieldsQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedFieldsQuerySelfTest.java
index a01a3ff..4ec840c 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedFieldsQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedFieldsQuerySelfTest.java
@@ -24,8 +24,8 @@ import org.apache.ignite.IgniteException;
import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.query.QueryCursor;
import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.internal.processors.cache.IgniteCacheAbstractFieldsQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager;
import org.apache.ignite.testframework.GridTestUtils;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
@@ -52,11 +52,11 @@ public class IgniteCacheReplicatedFieldsQuerySelfTest extends IgniteCacheAbstrac
QueryCursor<List<?>> qry = null;
- int maximumQueryIteratorCount = GridCacheQueryManager.MAX_ITERATORS;
+ int maximumQueryIteratorCount = cache.getConfiguration(CacheConfiguration.class).getMaxQueryIteratorsCount();
for (int i = 0; i < maximumQueryIteratorCount + 1; i++) {
QueryCursor<List<?>> q = cache
- .query(new SqlFieldsQuery("select _key from Integer where _key >= 0 order by _key"));
+ .query(new SqlFieldsQuery("select _key from Integer where _key >= 0 order by _key"));
assertEquals(0, q.iterator().next().get(0));
http://git-wip-us.apache.org/repos/asf/ignite/blob/8b8b02e2/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedQuerySelfTest.java
index 0a9f51c..048bc8c 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/IgniteCacheReplicatedQuerySelfTest.java
@@ -35,11 +35,11 @@ import org.apache.ignite.cache.CacheMode;
import org.apache.ignite.cache.query.QueryCursor;
import org.apache.ignite.cache.query.SqlQuery;
import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.events.DiscoveryEvent;
import org.apache.ignite.events.Event;
import org.apache.ignite.events.EventType;
import org.apache.ignite.internal.processors.cache.IgniteCacheAbstractQuerySelfTest;
-import org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager;
import org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing;
import org.apache.ignite.internal.util.typedef.X;
import org.apache.ignite.internal.util.typedef.internal.S;
@@ -297,7 +297,7 @@ public class IgniteCacheReplicatedQuerySelfTest extends IgniteCacheAbstractQuery
QueryCursor<Cache.Entry<Integer, Integer>> fut = null;
- for (int i = 0; i < GridCacheQueryManager.MAX_ITERATORS + 1; i++) {
+ for (int i = 0; i < cache.getConfiguration(CacheConfiguration.class).getMaxQueryIteratorsCount() + 1; i++) {
QueryCursor<Cache.Entry<Integer, Integer>> q =
cache.query(new SqlQuery<Integer, Integer>(Integer.class, "_key >= 0 order by _key"));