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 2018/10/30 06:09:00 UTC
[09/28] ignite git commit: IGNITE-8873 Fixed tests - Fixes #5091.
IGNITE-8873 Fixed tests - Fixes #5091.
Signed-off-by: Alexey Goncharuk <al...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ad99fbae
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ad99fbae
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ad99fbae
Branch: refs/heads/ignite-627
Commit: ad99fbae735307e56ea6c78dcbd88fa1454ecee2
Parents: 11e142d
Author: Aleksei Scherbakov <al...@gmail.com>
Authored: Sat Oct 27 11:45:32 2018 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Sat Oct 27 11:45:32 2018 +0300
----------------------------------------------------------------------
.../db/IgnitePdsPartitionPreloadTest.java | 49 +++++++++++++-------
1 file changed, 33 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ad99fbae/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsPartitionPreloadTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsPartitionPreloadTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsPartitionPreloadTest.java
index b9d28ae..0452ad4 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsPartitionPreloadTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/IgnitePdsPartitionPreloadTest.java
@@ -388,27 +388,31 @@ public class IgnitePdsPartitionPreloadTest extends GridCommonAbstractTest {
}
/**
- * @param testNodeFactory Test node factory.
+ * @param execNodeFactory Test node factory.
* @param preloadMode Preload mode.
*/
- private void preloadPartition(Supplier<Ignite> testNodeFactory, PreloadMode preloadMode) throws Exception {
+ private void preloadPartition(Supplier<Ignite> execNodeFactory, PreloadMode preloadMode) throws Exception {
Ignite crd = startGridsMultiThreaded(GRIDS_CNT);
- int cnt = 0;
+ Ignite testNode = grid(1);
+
+ Object consistentId = testNode.cluster().localNode().consistentId();
- Ignite primary = grid(1);
+ assertEquals(PRIMARY_NODE, testNode.cluster().localNode().consistentId());
- assertEquals(PRIMARY_NODE, primary.cluster().localNode().consistentId());
+ boolean locCacheMode = testNode.cache(DEFAULT_CACHE_NAME).getConfiguration(CacheConfiguration.class).getCacheMode() == LOCAL;
- Integer key = primaryKey(primary.cache(DEFAULT_CACHE_NAME));
+ Integer key = primaryKey(testNode.cache(DEFAULT_CACHE_NAME));
int preloadPart = crd.affinity(DEFAULT_CACHE_NAME).partition(key);
- try (IgniteDataStreamer<Integer, Integer> streamer = primary.dataStreamer(DEFAULT_CACHE_NAME)) {
+ int cnt = 0;
+
+ try (IgniteDataStreamer<Integer, Integer> streamer = testNode.dataStreamer(DEFAULT_CACHE_NAME)) {
int k = 0;
while (cnt < ENTRY_CNT) {
- if (primary.affinity(DEFAULT_CACHE_NAME).partition(k) == preloadPart) {
+ if (testNode.affinity(DEFAULT_CACHE_NAME).partition(k) == preloadPart) {
streamer.addData(k, k);
cnt++;
@@ -424,36 +428,49 @@ public class IgnitePdsPartitionPreloadTest extends GridCommonAbstractTest {
startGridsMultiThreaded(GRIDS_CNT);
- primary = G.allGrids().stream().
+ testNode = G.allGrids().stream().
filter(ignite -> PRIMARY_NODE.equals(ignite.cluster().localNode().consistentId())).findFirst().get();
- assertEquals(primary, primaryNode(key, DEFAULT_CACHE_NAME));
+ if (!locCacheMode)
+ assertEquals(testNode, primaryNode(key, DEFAULT_CACHE_NAME));
- Ignite testNode = testNodeFactory.get();
+ Ignite execNode = execNodeFactory.get();
switch (preloadMode) {
case SYNC:
- testNode.cache(DEFAULT_CACHE_NAME).preloadPartition(preloadPart);
+ execNode.cache(DEFAULT_CACHE_NAME).preloadPartition(preloadPart);
+
+ if (locCacheMode) {
+ testNode = G.allGrids().stream().filter(ignite ->
+ ignite.cluster().localNode().consistentId().equals(consistentId)).findFirst().get();
+ }
break;
case ASYNC:
- testNode.cache(DEFAULT_CACHE_NAME).preloadPartitionAsync(preloadPart).get();
+ execNode.cache(DEFAULT_CACHE_NAME).preloadPartitionAsync(preloadPart).get();
+
+ if (locCacheMode) {
+ testNode = G.allGrids().stream().filter(ignite ->
+ ignite.cluster().localNode().consistentId().equals(consistentId)).findFirst().get();
+ }
break;
case LOCAL:
- assertTrue(testNode.cache(DEFAULT_CACHE_NAME).localPreloadPartition(preloadPart));
+ assertTrue(execNode.cache(DEFAULT_CACHE_NAME).localPreloadPartition(preloadPart));
+
+ testNode = execNode; // For local preloading testNode == execNode
break;
}
- long c0 = primary.dataRegionMetrics(DEFAULT_REGION).getPagesRead();
+ long c0 = testNode.dataRegionMetrics(DEFAULT_REGION).getPagesRead();
// After partition preloading no pages should be read from store.
List<Cache.Entry<Object, Object>> list = U.arrayList(testNode.cache(DEFAULT_CACHE_NAME).localEntries(), 1000);
assertEquals(ENTRY_CNT, list.size());
- assertEquals("Read pages count must be same", c0, primary.dataRegionMetrics(DEFAULT_REGION).getPagesRead());
+ assertEquals("Read pages count must be same", c0, testNode.dataRegionMetrics(DEFAULT_REGION).getPagesRead());
}
/** */