Repository: ignite
Updated Branches:
  refs/heads/master 712733030 -> f14894651


IGNITE-7686 Reduce the number of pages to write in direct IO tests - Fixes 
#3532.

Signed-off-by: Alexey Goncharuk <alexey.goncha...@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f1489465
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f1489465
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f1489465

Branch: refs/heads/master
Commit: f148946517fa476a2ba0b45a15075a864c3a15f6
Parents: 7127330
Author: dpavlov <dpav...@gridgain.com>
Authored: Thu Feb 22 20:46:50 2018 +0300
Committer: Alexey Goncharuk <alexey.goncha...@gmail.com>
Committed: Thu Feb 22 20:46:50 2018 +0300

----------------------------------------------------------------------
 .../db/file/IgnitePdsEvictionTest.java          | 321 ------------------
 .../db/file/IgnitePdsPageReplacementTest.java   | 329 +++++++++++++++++++
 .../ignite/testsuites/IgnitePdsTestSuite.java   |  18 +-
 .../testsuites/IgnitePdsNativeIoTestSuite.java  |   3 +
 .../IgnitePdsReplacementNativeIoTest.java       |  28 ++
 5 files changed, 373 insertions(+), 326 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/f1489465/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsEvictionTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsEvictionTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsEvictionTest.java
deleted file mode 100644
index 9dd0146..0000000
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsEvictionTest.java
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache.persistence.db.file;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.concurrent.Callable;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.DataPageEvictionMode;
-import org.apache.ignite.configuration.DataStorageConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.configuration.DataRegionConfiguration;
-import org.apache.ignite.configuration.WALMode;
-import org.apache.ignite.internal.IgniteEx;
-import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.pagemem.FullPageId;
-import org.apache.ignite.internal.pagemem.PageMemory;
-import org.apache.ignite.internal.pagemem.PageUtils;
-import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
-import 
org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager;
-import org.apache.ignite.internal.processors.cache.persistence.DummyPageIO;
-import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO;
-import org.apache.ignite.internal.util.typedef.internal.CU;
-import org.apache.ignite.testframework.GridTestUtils;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-/**
- * Test for page evictions.
- */
-public class IgnitePdsEvictionTest extends GridCommonAbstractTest {
-    /** */
-    private static final int NUMBER_OF_SEGMENTS = 64;
-
-    /** */
-    private static final int PAGE_SIZE = 4 * 1024;
-
-    /** */
-    private static final long CHUNK_SIZE = 1024 * 1024;
-
-    /** */
-    private static final long MEMORY_LIMIT = 10 * CHUNK_SIZE;
-
-    /** */
-    private static final int PAGES_NUM = 128_000;
-
-    /** Cache name. */
-    private final String cacheName = "cache";
-
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String gridName) 
throws Exception {
-        final IgniteConfiguration cfg = super.getConfiguration(gridName);
-
-        cfg.setDataStorageConfiguration(createDbConfig());
-
-        cfg.setCacheConfiguration(new CacheConfiguration<>(cacheName));
-
-        return cfg;
-    }
-
-    /**
-     * @return DB config.
-     */
-    private DataStorageConfiguration createDbConfig() {
-        final DataStorageConfiguration memCfg = new DataStorageConfiguration();
-
-        DataRegionConfiguration memPlcCfg = new DataRegionConfiguration();
-        memPlcCfg.setInitialSize(MEMORY_LIMIT);
-        memPlcCfg.setMaxSize(MEMORY_LIMIT);
-        memPlcCfg.setPageEvictionMode(DataPageEvictionMode.RANDOM_LRU);
-        memPlcCfg.setName("dfltDataRegion");
-        memPlcCfg.setPersistenceEnabled(true);
-
-        memCfg.setPageSize(PAGE_SIZE);
-        memCfg.setConcurrencyLevel(NUMBER_OF_SEGMENTS);
-        memCfg.setDefaultDataRegionConfiguration(memPlcCfg);
-        memCfg.setWalMode(WALMode.LOG_ONLY);
-
-        return memCfg;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void beforeTestsStarted() throws Exception {
-        super.beforeTestsStarted();
-
-        cleanPersistenceDir();
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTestsStopped() throws Exception {
-        super.afterTestsStopped();
-
-        stopAllGrids();
-
-        cleanPersistenceDir();
-    }
-
-    /**
-     * @throws Exception If fail.
-     */
-    public void testPageEviction() throws Exception {
-        final IgniteEx ig = startGrid(0);
-
-        ig.active(true);
-
-        final PageMemory memory = getMemory(ig);
-
-        writeData(ig, memory, CU.cacheId(cacheName));
-    }
-
-    /**
-     * @param memory Page memory.
-     * @param cacheId Cache id.
-     * @throws IgniteCheckedException If failed.
-     */
-    private void writeData(final IgniteEx ignite, final PageMemory memory, 
final int cacheId) throws Exception {
-        final int size = PAGES_NUM;
-
-        final List<FullPageId> pageIds = new ArrayList<>(size);
-
-        IgniteCacheDatabaseSharedManager db = 
ignite.context().cache().context().database();
-
-        PageIO pageIO = new DummyPageIO();
-
-        // Allocate.
-        for (int i = 0; i < size; i++) {
-            db.checkpointReadLock();
-            try {
-                final FullPageId fullId = new 
FullPageId(memory.allocatePage(cacheId, i % 256, PageMemory.FLAG_DATA),
-                    cacheId);
-
-                initPage(memory, pageIO, fullId);
-
-                pageIds.add(fullId);
-            }
-            finally {
-                db.checkpointReadUnlock();
-            }
-        }
-
-        System.out.println("Allocated pages: " + pageIds.size());
-
-        // Write data. (Causes evictions.)
-        final int part = PAGES_NUM / NUMBER_OF_SEGMENTS;
-
-        final Collection<IgniteInternalFuture> futs = new ArrayList<>();
-
-        for (int i = 0; i < PAGES_NUM; i += part)
-            futs.add(runWriteInThread(ignite, i, i + part, memory, pageIds));
-
-        for (final IgniteInternalFuture fut : futs)
-            fut.get();
-
-        System.out.println("Wrote pages: " + pageIds.size());
-
-        // Read data. (Causes evictions.)
-        futs.clear();
-
-        for (int i = 0; i < PAGES_NUM; i += part)
-            futs.add(runReadInThread(ignite, i, i + part, memory, pageIds));
-
-        for (final IgniteInternalFuture fut : futs)
-            fut.get();
-
-        System.out.println("Read pages: " + pageIds.size());
-    }
-
-    /**
-     * Initializes page.
-     * @param mem page memory implementation.
-     * @param pageIO page io implementation.
-     * @param fullId full page id.
-     * @throws IgniteCheckedException if error occurs.
-     */
-    private void initPage(PageMemory mem, PageIO pageIO, FullPageId fullId) 
throws IgniteCheckedException {
-        long page = mem.acquirePage(fullId.groupId(), fullId.pageId());
-
-        try {
-            final long pageAddr = mem.writeLock(fullId.groupId(), 
fullId.pageId(), page);
-
-            try {
-                pageIO.initNewPage(pageAddr, fullId.pageId(), mem.pageSize());
-            }
-            finally {
-                mem.writeUnlock(fullId.groupId(), fullId.pageId(), page, null, 
true);
-            }
-        }
-        finally {
-            mem.releasePage(fullId.groupId(), fullId.pageId(), page);
-        }
-    }
-
-    /**
-     * @param start Start index.
-     * @param end End index.
-     * @param memory PageMemory.
-     * @param pageIds Allocated pages.
-     * @return Future.
-     * @throws Exception If fail.
-     */
-    private IgniteInternalFuture runWriteInThread(
-        final IgniteEx ignite,
-        final int start,
-        final int end,
-        final PageMemory memory,
-        final List<FullPageId> pageIds
-    ) throws Exception {
-
-        return GridTestUtils.runAsync(new Callable<Object>() {
-            @Override public Object call() throws Exception {
-                IgniteCacheDatabaseSharedManager db = 
ignite.context().cache().context().database();
-
-                for (int i = start; i < end; i++) {
-                    db.checkpointReadLock();
-
-                    try {
-                        FullPageId fullId = pageIds.get(i);
-
-                        long page = memory.acquirePage(fullId.groupId(), 
fullId.pageId());
-
-                        try {
-                            final long pageAddr = 
memory.writeLock(fullId.groupId(), fullId.pageId(), page);
-
-                            try {
-                                PageIO.setPageId(pageAddr, fullId.pageId());
-
-                                PageUtils.putLong(pageAddr, 
PageIO.COMMON_HEADER_END, i * 2);
-                            }
-                            finally {
-                                memory.writeUnlock(fullId.groupId(), 
fullId.pageId(), page, null, true);
-                            }
-                        }
-                        finally {
-                            memory.releasePage(fullId.groupId(), 
fullId.pageId(), page);
-                        }
-                    }
-                    finally {
-                        db.checkpointReadUnlock();
-                    }
-                }
-
-                return null;
-            }
-        });
-    }
-
-    /**
-     * @param start Start index.
-     * @param end End index.
-     * @param memory PageMemory.
-     * @param pageIds Allocated pages.
-     * @return Future.
-     * @throws Exception If fail.
-     */
-    private IgniteInternalFuture runReadInThread(final IgniteEx ignite, final 
int start, final int end,
-        final PageMemory memory,
-        final List<FullPageId> pageIds) throws Exception {
-        return GridTestUtils.runAsync(new Callable<Object>() {
-            @Override public Object call() throws Exception {
-                IgniteCacheDatabaseSharedManager db = 
ignite.context().cache().context().database();
-
-                for (int i = start; i < end; i++) {
-                    db.checkpointReadLock();
-
-                    try {
-                        final FullPageId fullId = pageIds.get(i);
-
-                        long page = memory.acquirePage(fullId.groupId(), 
fullId.pageId());
-                        try {
-                            final long pageAddr = 
memory.readLock(fullId.groupId(), fullId.pageId(), page);
-
-                            try {
-                                assertEquals(i * 2, 
PageUtils.getLong(pageAddr, PageIO.COMMON_HEADER_END));
-                            }
-                            finally {
-                                memory.readUnlock(fullId.groupId(), 
fullId.pageId(), page);
-                            }
-                        }
-                        finally {
-                            memory.releasePage(fullId.groupId(), 
fullId.pageId(), page);
-                        }
-                    }
-                    finally {
-                        db.checkpointReadUnlock();
-                    }
-                }
-
-                return null;
-            }
-        });
-    }
-
-    /**
-     * @param ig Ignite instance.
-     * @return Memory and store.
-     * @throws Exception If failed to initialize the store.
-     */
-    private PageMemory getMemory(IgniteEx ig) throws Exception {
-        final GridCacheSharedContext<Object, Object> sharedCtx = 
ig.context().cache().context();
-
-        final IgniteCacheDatabaseSharedManager db = sharedCtx.database();
-
-        return db.dataRegion(null).pageMemory();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f1489465/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsPageReplacementTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsPageReplacementTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsPageReplacementTest.java
new file mode 100644
index 0000000..b807aa7
--- /dev/null
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/file/IgnitePdsPageReplacementTest.java
@@ -0,0 +1,329 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.persistence.db.file;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.concurrent.Callable;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.DataPageEvictionMode;
+import org.apache.ignite.configuration.DataStorageConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.DataRegionConfiguration;
+import org.apache.ignite.configuration.WALMode;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.pagemem.FullPageId;
+import org.apache.ignite.internal.pagemem.PageMemory;
+import org.apache.ignite.internal.pagemem.PageUtils;
+import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
+import 
org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager;
+import org.apache.ignite.internal.processors.cache.persistence.DummyPageIO;
+import org.apache.ignite.internal.processors.cache.persistence.tree.io.PageIO;
+import org.apache.ignite.internal.util.typedef.internal.CU;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Test for page replacement (rotation with disk) process with enabled 
persistence.
+ * A lot of reader threads tries to acquire page and checkpointer threads 
write data.
+ */
+public class IgnitePdsPageReplacementTest extends GridCommonAbstractTest {
+    /** */
+    private static final int NUMBER_OF_SEGMENTS = 64;
+
+    /** */
+    private static final int PAGE_SIZE = 4 * 1024;
+
+    /** */
+    private static final long CHUNK_SIZE = 1024 * 1024;
+
+    /** */
+    private static final long MEMORY_LIMIT = 10 * CHUNK_SIZE;
+
+    /** */
+    private static final int PAGES_NUM = 128_000;
+
+    /** Cache name. */
+    private final String cacheName = "cache";
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) 
throws Exception {
+        final IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        cfg.setDataStorageConfiguration(createDbConfig());
+
+        cfg.setCacheConfiguration(new CacheConfiguration<>(cacheName));
+
+        return cfg;
+    }
+
+    /**
+     * @return DB config.
+     */
+    private DataStorageConfiguration createDbConfig() {
+        final DataStorageConfiguration memCfg = new DataStorageConfiguration();
+
+        DataRegionConfiguration memPlcCfg = new DataRegionConfiguration();
+        memPlcCfg.setInitialSize(MEMORY_LIMIT);
+        memPlcCfg.setMaxSize(MEMORY_LIMIT);
+        memPlcCfg.setPageEvictionMode(DataPageEvictionMode.RANDOM_LRU);
+        memPlcCfg.setName("dfltDataRegion");
+        memPlcCfg.setPersistenceEnabled(true);
+
+        memCfg.setPageSize(PAGE_SIZE);
+        memCfg.setConcurrencyLevel(NUMBER_OF_SEGMENTS);
+        memCfg.setDefaultDataRegionConfiguration(memPlcCfg);
+        memCfg.setWalMode(WALMode.LOG_ONLY);
+
+        return memCfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        super.beforeTestsStarted();
+
+        cleanPersistenceDir();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        super.afterTestsStopped();
+
+        stopAllGrids();
+
+        cleanPersistenceDir();
+    }
+
+    /**
+     * @throws Exception If fail.
+     */
+    public void testPageReplacement() throws Exception {
+        final IgniteEx ig = startGrid(0);
+
+        ig.active(true);
+
+        final PageMemory memory = getMemory(ig);
+
+        writeData(ig, memory, CU.cacheId(cacheName));
+    }
+
+    /**
+     * @param memory Page memory.
+     * @param cacheId Cache id.
+     * @throws IgniteCheckedException If failed.
+     */
+    private void writeData(final IgniteEx ignite, final PageMemory memory, 
final int cacheId) throws Exception {
+        final int pagesNum = getPagesNum();
+
+        final List<FullPageId> pageIds = new ArrayList<>(pagesNum);
+
+        IgniteCacheDatabaseSharedManager db = 
ignite.context().cache().context().database();
+
+        PageIO pageIO = new DummyPageIO();
+
+        // Allocate.
+        for (int i = 0; i < pagesNum; i++) {
+            db.checkpointReadLock();
+            try {
+                final FullPageId fullId = new 
FullPageId(memory.allocatePage(cacheId, i % 256, PageMemory.FLAG_DATA),
+                    cacheId);
+
+                initPage(memory, pageIO, fullId);
+
+                pageIds.add(fullId);
+            }
+            finally {
+                db.checkpointReadUnlock();
+            }
+        }
+
+        System.out.println("Allocated pages: " + pageIds.size());
+
+        // Write data. (Causes evictions.)
+        final int part = pagesNum / NUMBER_OF_SEGMENTS;
+
+        final Collection<IgniteInternalFuture> futs = new ArrayList<>();
+
+        for (int i = 0; i < pagesNum; i += part)
+            futs.add(runWriteInThread(ignite, i, i + part, memory, pageIds));
+
+        for (final IgniteInternalFuture fut : futs)
+            fut.get();
+
+        System.out.println("Wrote pages: " + pageIds.size());
+
+        // Read data. (Causes evictions.)
+        futs.clear();
+
+        for (int i = 0; i < pagesNum; i += part)
+            futs.add(runReadInThread(ignite, i, i + part, memory, pageIds));
+
+        for (final IgniteInternalFuture fut : futs)
+            fut.get();
+
+        System.out.println("Read pages: " + pageIds.size());
+    }
+
+    /**
+     * @return num of pages to operate in test.
+     */
+    protected int getPagesNum() {
+        return PAGES_NUM;
+    }
+
+    /**
+     * Initializes page.
+     * @param mem page memory implementation.
+     * @param pageIO page io implementation.
+     * @param fullId full page id.
+     * @throws IgniteCheckedException if error occurs.
+     */
+    private void initPage(PageMemory mem, PageIO pageIO, FullPageId fullId) 
throws IgniteCheckedException {
+        long page = mem.acquirePage(fullId.groupId(), fullId.pageId());
+
+        try {
+            final long pageAddr = mem.writeLock(fullId.groupId(), 
fullId.pageId(), page);
+
+            try {
+                pageIO.initNewPage(pageAddr, fullId.pageId(), mem.pageSize());
+            }
+            finally {
+                mem.writeUnlock(fullId.groupId(), fullId.pageId(), page, null, 
true);
+            }
+        }
+        finally {
+            mem.releasePage(fullId.groupId(), fullId.pageId(), page);
+        }
+    }
+
+    /**
+     * @param start Start index.
+     * @param end End index.
+     * @param memory PageMemory.
+     * @param pageIds Allocated pages.
+     * @return Future.
+     * @throws Exception If fail.
+     */
+    private IgniteInternalFuture runWriteInThread(
+        final IgniteEx ignite,
+        final int start,
+        final int end,
+        final PageMemory memory,
+        final List<FullPageId> pageIds
+    ) throws Exception {
+
+        return GridTestUtils.runAsync(new Callable<Object>() {
+            @Override public Object call() throws Exception {
+                IgniteCacheDatabaseSharedManager db = 
ignite.context().cache().context().database();
+
+                for (int i = start; i < end; i++) {
+                    db.checkpointReadLock();
+
+                    try {
+                        FullPageId fullId = pageIds.get(i);
+
+                        long page = memory.acquirePage(fullId.groupId(), 
fullId.pageId());
+
+                        try {
+                            final long pageAddr = 
memory.writeLock(fullId.groupId(), fullId.pageId(), page);
+
+                            try {
+                                PageIO.setPageId(pageAddr, fullId.pageId());
+
+                                PageUtils.putLong(pageAddr, 
PageIO.COMMON_HEADER_END, i * 2);
+                            }
+                            finally {
+                                memory.writeUnlock(fullId.groupId(), 
fullId.pageId(), page, null, true);
+                            }
+                        }
+                        finally {
+                            memory.releasePage(fullId.groupId(), 
fullId.pageId(), page);
+                        }
+                    }
+                    finally {
+                        db.checkpointReadUnlock();
+                    }
+                }
+
+                return null;
+            }
+        });
+    }
+
+    /**
+     * @param start Start index.
+     * @param end End index.
+     * @param memory PageMemory.
+     * @param pageIds Allocated pages.
+     * @return Future.
+     * @throws Exception If fail.
+     */
+    private IgniteInternalFuture runReadInThread(final IgniteEx ignite, final 
int start, final int end,
+        final PageMemory memory,
+        final List<FullPageId> pageIds) throws Exception {
+        return GridTestUtils.runAsync(new Callable<Object>() {
+            @Override public Object call() throws Exception {
+                IgniteCacheDatabaseSharedManager db = 
ignite.context().cache().context().database();
+
+                for (int i = start; i < end; i++) {
+                    db.checkpointReadLock();
+
+                    try {
+                        final FullPageId fullId = pageIds.get(i);
+
+                        long page = memory.acquirePage(fullId.groupId(), 
fullId.pageId());
+                        try {
+                            final long pageAddr = 
memory.readLock(fullId.groupId(), fullId.pageId(), page);
+
+                            try {
+                                assertEquals(i * 2, 
PageUtils.getLong(pageAddr, PageIO.COMMON_HEADER_END));
+                            }
+                            finally {
+                                memory.readUnlock(fullId.groupId(), 
fullId.pageId(), page);
+                            }
+                        }
+                        finally {
+                            memory.releasePage(fullId.groupId(), 
fullId.pageId(), page);
+                        }
+                    }
+                    finally {
+                        db.checkpointReadUnlock();
+                    }
+                }
+
+                return null;
+            }
+        });
+    }
+
+    /**
+     * @param ig Ignite instance.
+     * @return Memory and store.
+     * @throws Exception If failed to initialize the store.
+     */
+    private PageMemory getMemory(IgniteEx ig) throws Exception {
+        final GridCacheSharedContext<Object, Object> sharedCtx = 
ig.context().cache().context();
+
+        final IgniteCacheDatabaseSharedManager db = sharedCtx.database();
+
+        return db.dataRegion(null).pageMemory();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/f1489465/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite.java
 
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite.java
index a8397d7..a36f35b 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite.java
@@ -25,7 +25,7 @@ import 
org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsCache
 import 
org.apache.ignite.internal.processors.cache.persistence.db.IgnitePdsDataRegionMetricsTest;
 import 
org.apache.ignite.internal.processors.cache.persistence.db.file.DefaultPageSizeBackwardsCompatibilityTest;
 import 
org.apache.ignite.internal.processors.cache.persistence.db.file.IgnitePdsCheckpointSimulationWithRealCpDisabledTest;
-import 
org.apache.ignite.internal.processors.cache.persistence.db.file.IgnitePdsEvictionTest;
+import 
org.apache.ignite.internal.processors.cache.persistence.db.file.IgnitePdsPageReplacementTest;
 import 
org.apache.ignite.internal.processors.cache.persistence.pagemem.BPlusTreePageMemoryImplTest;
 import 
org.apache.ignite.internal.processors.cache.persistence.pagemem.BPlusTreeReuseListPageMemoryImplTest;
 import 
org.apache.ignite.internal.processors.cache.persistence.pagemem.FillFactorMetricTest;
@@ -40,7 +40,6 @@ import 
org.apache.ignite.internal.processors.database.IgniteDbPutGetWithCacheSto
 import 
org.apache.ignite.internal.processors.database.IgniteDbSingleNodePutGetTest;
 import 
org.apache.ignite.internal.processors.database.IgniteDbSingleNodeTinyPutGetTest;
 
-
 /**
  *
  */
@@ -53,11 +52,11 @@ public class IgnitePdsTestSuite extends TestSuite {
         TestSuite suite = new TestSuite("Ignite Persistent Store Test Suite");
 
         addRealPageStoreTests(suite);
+        addRealPageStoreTestsLongRunning(suite);
 
         // Basic PageMemory tests.
         suite.addTestSuite(PageMemoryImplNoLoadTest.class);
         suite.addTestSuite(IndexStoragePageMemoryImplTest.class);
-        suite.addTestSuite(IgnitePdsEvictionTest.class);
         suite.addTestSuite(PageMemoryImplTest.class);
 
         // BTree tests with store page memory.
@@ -76,13 +75,22 @@ public class IgnitePdsTestSuite extends TestSuite {
     }
 
     /**
+     * Fills {@code suite} with PDS test subset, which operates with real page 
store, but requires long time to
+     * execute.
+     *
+     * @param suite suite to add tests into.
+     */
+    public static void addRealPageStoreTestsLongRunning(TestSuite suite) {
+        // Basic PageMemory tests.
+        suite.addTestSuite(IgnitePdsPageReplacementTest.class);
+    }
+
+    /**
      * Fills {@code suite} with PDS test subset, which operates with real page 
store and does actual disk operations.
      *
      * @param suite suite to add tests into.
      */
     public static void addRealPageStoreTests(TestSuite suite) {
-        // Basic PageMemory tests.
-        suite.addTestSuite(IgnitePdsEvictionTest.class);
 
         // Checkpointing smoke-test.
         
suite.addTestSuite(IgnitePdsCheckpointSimulationWithRealCpDisabledTest.class);

http://git-wip-us.apache.org/repos/asf/ignite/blob/f1489465/modules/direct-io/src/test/java/org/apache/ignite/testsuites/IgnitePdsNativeIoTestSuite.java
----------------------------------------------------------------------
diff --git 
a/modules/direct-io/src/test/java/org/apache/ignite/testsuites/IgnitePdsNativeIoTestSuite.java
 
b/modules/direct-io/src/test/java/org/apache/ignite/testsuites/IgnitePdsNativeIoTestSuite.java
index 48454ea..787a755 100644
--- 
a/modules/direct-io/src/test/java/org/apache/ignite/testsuites/IgnitePdsNativeIoTestSuite.java
+++ 
b/modules/direct-io/src/test/java/org/apache/ignite/testsuites/IgnitePdsNativeIoTestSuite.java
@@ -31,6 +31,9 @@ public class IgnitePdsNativeIoTestSuite extends TestSuite {
 
         IgnitePdsTestSuite.addRealPageStoreTests(suite);
 
+        //long running test by design with light parameters
+        suite.addTestSuite(IgnitePdsReplacementNativeIoTest.class);
+
         suite.addTestSuite(IgniteNativeIoWithNoPersistenceTest.class);
 
         return suite;

http://git-wip-us.apache.org/repos/asf/ignite/blob/f1489465/modules/direct-io/src/test/java/org/apache/ignite/testsuites/IgnitePdsReplacementNativeIoTest.java
----------------------------------------------------------------------
diff --git 
a/modules/direct-io/src/test/java/org/apache/ignite/testsuites/IgnitePdsReplacementNativeIoTest.java
 
b/modules/direct-io/src/test/java/org/apache/ignite/testsuites/IgnitePdsReplacementNativeIoTest.java
new file mode 100644
index 0000000..79aecfc
--- /dev/null
+++ 
b/modules/direct-io/src/test/java/org/apache/ignite/testsuites/IgnitePdsReplacementNativeIoTest.java
@@ -0,0 +1,28 @@
+package org.apache.ignite.testsuites;
+
+import org.apache.ignite.IgniteSystemProperties;
+import 
org.apache.ignite.internal.processors.cache.persistence.db.file.IgnitePdsPageReplacementTest;
+
+/**
+ * Page replacement light variant of test for native direct IO (wastes real 
IOPs on agents)
+ */
+public class IgnitePdsReplacementNativeIoTest extends 
IgnitePdsPageReplacementTest {
+
+    /** {@inheritDoc} */
+    @Override protected long getTestTimeout() {
+        return 15 * 60 * 1000;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected int getPagesNum() {
+        // 1k - passed, 20k - passed, 64k - failed
+        return 20 * 1024;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void testPageReplacement() throws Exception {
+        
System.setProperty(IgniteSystemProperties.IGNITE_USE_ASYNC_FILE_IO_FACTORY, 
"false");
+
+        super.testPageReplacement();
+    }
+}

Reply via email to