You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2016/05/18 10:58:37 UTC
[31/38] ignite git commit: ignite-2921: ScanQueries over local
partitions performance optimisation
http://git-wip-us.apache.org/repos/asf/ignite/blob/bcb3e104/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedPreloadLifecycleSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedPreloadLifecycleSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedPreloadLifecycleSelfTest.java
index e434b49..0d45324 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedPreloadLifecycleSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedPreloadLifecycleSelfTest.java
@@ -17,19 +17,12 @@
package org.apache.ignite.internal.processors.cache.distributed.near;
-import java.util.Map;
-import javax.cache.CacheException;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.IgniteKernal;
-import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
import org.apache.ignite.internal.processors.cache.distributed.GridCachePreloadLifecycleAbstractTest;
-import org.apache.ignite.internal.processors.cache.query.CacheQuery;
-import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.G;
-import org.apache.ignite.lang.IgniteReducer;
import org.apache.ignite.lifecycle.LifecycleBean;
import org.apache.ignite.lifecycle.LifecycleEventType;
import org.apache.ignite.resources.IgniteInstanceResource;
@@ -164,34 +157,6 @@ public class GridCachePartitionedPreloadLifecycleSelfTest extends GridCachePrelo
}
/**
- * @param keys Keys.
- * @throws Exception If failed.
- */
- public void checkScanQuery(Object[] keys) throws Exception {
- preloadMode = SYNC;
-
- lifecycleBean = lifecycleBean(keys);
-
- for (int i = 0; i < gridCnt; i++) {
- startGrid(i);
-
- info("Checking '" + (i + 1) + "' nodes...");
-
- for (int j = 0; j < G.allGrids().size(); j++) {
- GridCacheAdapter<Object, MyValue> c2 = ((IgniteKernal)grid(j)).internalCache("two");
-
- CacheQuery<Map.Entry<Object, MyValue>> qry = c2.context().queries().createScanQuery(null, null, false);
-
- int totalCnt = F.sumInt(qry.execute(new EntryIntegerIgniteReducer()).get());
-
- info("Total entry count [grid=" + j + ", totalCnt=" + totalCnt + ']');
-
- assertEquals(keys.length / 2, totalCnt);
- }
- }
- }
-
- /**
* @throws Exception If failed.
*/
public void testLifecycleBean1() throws Exception {
@@ -218,69 +183,4 @@ public class GridCachePartitionedPreloadLifecycleSelfTest extends GridCachePrelo
public void testLifecycleBean4() throws Exception {
checkCache(keys(false, 500));
}
-
- /**
- * @throws Exception If failed.
- */
- public void testScanQuery1() throws Exception {
- checkScanQuery(keys(true, DFLT_KEYS.length, DFLT_KEYS));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testScanQuery2() throws Exception {
- checkScanQuery(keys(false, DFLT_KEYS.length, DFLT_KEYS));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testScanQuery3() throws Exception {
- checkScanQuery(keys(true, 500));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testScanQuery4() throws Exception {
- checkScanQuery(keys(false, 500));
- }
-
- /**
- *
- */
- private static class EntryIntegerIgniteReducer implements IgniteReducer<Map.Entry<Object, MyValue>, Integer> {
- @IgniteInstanceResource
- private Ignite grid;
-
- private int cnt;
-
- @Override public boolean collect(Map.Entry<Object, MyValue> e) {
- Object key = e.getKey();
-
- assertNotNull(e.getValue());
-
- try {
- Object v1 = e.getValue();
- Object v2 = grid.cache("one").get(key);
-
- assertNotNull(v2);
- assertEquals(v1, v2);
- }
- catch (CacheException e1) {
- e1.printStackTrace();
-
- assert false;
- }
-
- cnt++;
-
- return true;
- }
-
- @Override public Integer reduce() {
- return cnt;
- }
- }
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bcb3e104/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadLifecycleSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadLifecycleSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadLifecycleSelfTest.java
index 6a7a68b..f6799d8 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadLifecycleSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/replicated/preloader/GridCacheReplicatedPreloadLifecycleSelfTest.java
@@ -17,26 +17,17 @@
package org.apache.ignite.internal.processors.cache.distributed.replicated.preloader;
-import java.util.Map;
import javax.cache.Cache;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteLogger;
import org.apache.ignite.cache.CachePeekMode;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.IgniteKernal;
-import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
import org.apache.ignite.internal.processors.cache.distributed.GridCachePreloadLifecycleAbstractTest;
-import org.apache.ignite.internal.processors.cache.query.CacheQuery;
-import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.G;
-import org.apache.ignite.lang.IgniteReducer;
import org.apache.ignite.lifecycle.LifecycleBean;
import org.apache.ignite.lifecycle.LifecycleEventType;
import org.apache.ignite.resources.IgniteInstanceResource;
-import org.apache.ignite.resources.LoggerResource;
import static org.apache.ignite.cache.CacheMode.REPLICATED;
import static org.apache.ignite.cache.CacheRebalanceMode.SYNC;
@@ -167,40 +158,6 @@ public class GridCacheReplicatedPreloadLifecycleSelfTest extends GridCachePreloa
}
}
-
- /**
- * @param keys Keys.
- * @throws Exception If failed.
- */
- public void checkScanQuery(Object[] keys) throws Exception {
- preloadMode = SYNC;
-
- lifecycleBean = lifecycleBean(keys);
-
- for (int i = 0; i < gridCnt; i++) {
- startGrid(i);
-
- info("Checking '" + (i + 1) + "' nodes...");
-
- for (int j = 0; j < G.allGrids().size(); j++) {
- GridCacheAdapter<Object, MyValue> c2 = ((IgniteKernal)grid(j)).internalCache("two");
-
- CacheQuery<Map.Entry<Object, MyValue>> qry = c2.context().queries().createScanQuery(null, null, false);
-
- final int i0 = j;
- final int j0 = i;
-
- qry = qry.projection(grid(j).cluster());
-
- int totalCnt = F.sumInt(qry.execute(new EntryReducer(j0, i0)).get());
-
- info("Total entry count [grid=" + j + ", totalCnt=" + totalCnt + ']');
-
- assertEquals(keys.length * (i + 1) / 2, totalCnt);
- }
- }
- }
-
/**
* @throws Exception If failed.
*/
@@ -228,91 +185,4 @@ public class GridCacheReplicatedPreloadLifecycleSelfTest extends GridCachePreloa
public void testLifecycleBean4() throws Exception {
checkCache(keys(false, 500));
}
-
- /**
- * @throws Exception If failed.
- */
- public void testScanQuery1() throws Exception {
- checkScanQuery(keys(true, DFLT_KEYS.length, DFLT_KEYS));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testScanQuery2() throws Exception {
- checkScanQuery(keys(false, DFLT_KEYS.length, DFLT_KEYS));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testScanQuery3() throws Exception {
- checkScanQuery(keys(true, 500));
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testScanQuery4() throws Exception {
- checkScanQuery(keys(false, 500));
- }
-
- private static class EntryReducer implements IgniteReducer<Map.Entry<Object, MyValue>, Integer> {
- /** */
- private final int j0;
-
- /** */
- private final int i0;
-
- /** */
- @IgniteInstanceResource
- private Ignite grid;
-
- /** */
- @LoggerResource
- private IgniteLogger log0;
-
- /** */
- private int cnt;
-
- /**
- */
- public EntryReducer(int j0, int i0) {
- this.j0 = j0;
- this.i0 = i0;
- }
-
- /** {@inheritDoc} */
- @Override public boolean collect(Map.Entry<Object, MyValue> e) {
- if (!quiet && log0.isInfoEnabled())
- log0.info("Collecting entry: " + e);
-
- Object key = e.getKey();
-
- assertNotNull(e.getValue());
-
- try {
- Object v1 = e.getValue();
- Object v2 = ((IgniteKernal)grid).getCache("one").get(key);
-
- assertNotNull("Cache c1 misses value for key [i=" + j0 + ", j=" + i0 + ", missedKey=" +
- key + ", cache=" + ((IgniteKernal)grid).getCache("one").values() + ']', v2);
- assertEquals(v1, v2);
- }
- catch (IgniteCheckedException e1) {
- e1.printStackTrace();
-
- assert false;
- }
-
- cnt++;
-
- return true;
- }
-
- /** {@inheritDoc} */
- @Override public Integer reduce() {
- return cnt;
- }
- }
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bcb3e104/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryMetricsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryMetricsSelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryMetricsSelfTest.java
index 28eef90..d2d8c4d 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryMetricsSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/CacheAbstractQueryMetricsSelfTest.java
@@ -84,6 +84,7 @@ public abstract class CacheAbstractQueryMetricsSelfTest extends GridCommonAbstra
cacheCfg1.setCacheMode(cacheMode);
cacheCfg1.setWriteSynchronizationMode(FULL_SYNC);
cacheCfg1.setIndexedTypes(String.class, Integer.class);
+ cacheCfg1.setStatisticsEnabled(true);
CacheConfiguration<String, Integer> cacheCfg2 = defaultCacheConfiguration();
@@ -91,6 +92,7 @@ public abstract class CacheAbstractQueryMetricsSelfTest extends GridCommonAbstra
cacheCfg2.setCacheMode(cacheMode);
cacheCfg2.setWriteSynchronizationMode(FULL_SYNC);
cacheCfg2.setIndexedTypes(String.class, Integer.class);
+ cacheCfg2.setStatisticsEnabled(true);
cfg.setCacheConfiguration(cacheCfg1, cacheCfg2);
@@ -347,4 +349,4 @@ public abstract class CacheAbstractQueryMetricsSelfTest extends GridCommonAbstra
}
}, 5000);
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/bcb3e104/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
index 1507543..73654ab 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractQuerySelfTest.java
@@ -720,7 +720,13 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
public void testScanQuery() throws Exception {
IgniteCache<Integer, String> c1 = ignite().cache(null);
- c1.put(777, "value");
+ Map<Integer, String> map = new HashMap(){{
+ for (int i = 0; i < 5000; i++)
+ put(i, "str" + i);
+ }};
+
+ for (Map.Entry<Integer, String> e : map.entrySet())
+ c1.put(e.getKey(), e.getValue());
// Scan query.
QueryCursor<Cache.Entry<Integer, String>> qry = c1.query(new ScanQuery<Integer, String>());
@@ -729,16 +735,21 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
assert iter != null;
- int expCnt = 1;
+ int cnt = 0;
+
+ while (iter.hasNext()) {
+ Cache.Entry<Integer, String> e = iter.next();
+
+ String expVal = map.get(e.getKey());
+
+ assertNotNull(expVal);
- for (int i = 0; i < expCnt; i++) {
- Cache.Entry<Integer, String> e1 = iter.next();
+ assertEquals(expVal, e.getValue());
- assertEquals(777, e1.getKey().intValue());
- assertEquals("value", e1.getValue());
+ cnt++;
}
- assert !iter.hasNext();
+ assertEquals(map.size(), cnt);
}
/**
@@ -1161,13 +1172,6 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
* @throws Exception If failed.
*/
public void testScanQueryEvents() throws Exception {
- checkScanQueryEvents();
- }
-
- /**
- * @throws Exception If failed.
- */
- private void checkScanQueryEvents() throws Exception {
final Map<Integer, Integer> map = new ConcurrentHashMap8<>();
final CountDownLatch latch = new CountDownLatch(10);
final CountDownLatch execLatch = new CountDownLatch(cacheMode() == REPLICATED ? 1 : gridCount());
@@ -1787,4 +1791,4 @@ public abstract class IgniteCacheAbstractQuerySelfTest extends GridCommonAbstrac
return store;
}
}
-}
\ No newline at end of file
+}