ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject [03/11] ignite git commit: IGNITE-5267 - Moved WAL system properties to WAL configuration
Date Thu, 08 Jun 2017 16:11:21 GMT
http://git-wip-us.apache.org/repos/asf/ignite/blob/cd4d0400/modules/pds/src/test/java/org/apache/ignite/cache/database/db/wal/WalRecoveryTxLogicalRecordsTest.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/db/wal/WalRecoveryTxLogicalRecordsTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/db/wal/WalRecoveryTxLogicalRecordsTest.java
new file mode 100644
index 0000000..30a7f9e
--- /dev/null
+++ b/modules/pds/src/test/java/org/apache/ignite/cache/database/db/wal/WalRecoveryTxLogicalRecordsTest.java
@@ -0,0 +1,951 @@
+/*
+ * 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.cache.database.db.wal;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicReferenceArray;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteDataStreamer;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.CacheRebalanceMode;
+import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
+import org.apache.ignite.cache.query.QueryCursor;
+import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.cache.query.annotations.QuerySqlField;
+import org.apache.ignite.configuration.BinaryConfiguration;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.MemoryConfiguration;
+import org.apache.ignite.configuration.PersistentStoreConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.pagemem.PageIdAllocator;
+import org.apache.ignite.internal.pagemem.store.PageStore;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.cache.GridCacheContext;
+import org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManager;
+import org.apache.ignite.internal.processors.cache.IgniteRebalanceIterator;
+import org.apache.ignite.internal.processors.cache.database.CacheDataRow;
+import org.apache.ignite.internal.processors.cache.database.GridCacheDatabaseSharedManager;
+import org.apache.ignite.internal.processors.cache.database.file.FilePageStoreManager;
+import org.apache.ignite.internal.processors.cache.database.freelist.FreeListImpl;
+import org.apache.ignite.internal.processors.cache.database.freelist.PagesList;
+import org.apache.ignite.internal.processors.cache.database.tree.reuse.ReuseListImpl;
+import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtLocalPartition;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.T2;
+import org.apache.ignite.internal.util.typedef.internal.CU;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.apache.ignite.transactions.Transaction;
+import org.junit.Assert;
+
+/**
+ *
+ */
+public class WalRecoveryTxLogicalRecordsTest extends GridCommonAbstractTest {
+    /** Cache name. */
+    private static final String CACHE_NAME = "cache";
+
+    /** Cache 2 name. */
+    private static final String CACHE2_NAME = "cache2";
+
+    /** */
+    public static final int PARTS = 32;
+
+    /** */
+    public static final int WAL_HIST_SIZE = 30;
+
+    /** */
+    private int pageSize = 4 * 1024;
+
+    /** */
+    private CacheConfiguration<?, ?> extraCcfg;
+
+    /** */
+    private Long checkpointFreq;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        CacheConfiguration<Integer, IndexedValue> ccfg = new CacheConfiguration<>(CACHE_NAME);
+
+        ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
+        ccfg.setRebalanceMode(CacheRebalanceMode.SYNC);
+        ccfg.setAffinity(new RendezvousAffinityFunction(false, PARTS));
+        ccfg.setIndexedTypes(Integer.class, IndexedValue.class);
+
+        if (extraCcfg != null)
+            cfg.setCacheConfiguration(ccfg, new CacheConfiguration<>(extraCcfg));
+        else
+            cfg.setCacheConfiguration(ccfg);
+
+        MemoryConfiguration dbCfg = new MemoryConfiguration();
+
+        dbCfg.setPageSize(pageSize);
+
+        cfg.setMemoryConfiguration(dbCfg);
+
+        PersistentStoreConfiguration pCfg = new PersistentStoreConfiguration();
+
+        pCfg.setWalHistorySize(WAL_HIST_SIZE);
+
+        if (checkpointFreq != null)
+            pCfg.setCheckpointingFrequency(checkpointFreq);
+
+        cfg.setPersistentStoreConfiguration(pCfg);
+
+        cfg.setMarshaller(null);
+
+        BinaryConfiguration binCfg = new BinaryConfiguration();
+
+        binCfg.setCompactFooter(false);
+
+        cfg.setBinaryConfiguration(binCfg);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTest() throws Exception {
+        deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false));
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testWalTxSimple() throws Exception {
+        Ignite ignite = startGrid();
+
+        try {
+            GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager)((IgniteEx)ignite).context()
+                .cache().context().database();
+
+            dbMgr.enableCheckpoints(false).get();
+
+            IgniteCache<Integer, IndexedValue> cache = ignite.cache(CACHE_NAME);
+
+            int txCnt = 100;
+
+            int keysPerTx = 10;
+
+            for (int i = 0; i < txCnt; i++) {
+                try (Transaction tx = ignite.transactions().txStart()) {
+                    for (int j = 0; j < keysPerTx; j++) {
+                        int k = i * keysPerTx + j;
+
+                        cache.put(k, new IndexedValue(k));
+                    }
+
+                    tx.commit();
+                }
+            }
+
+            for (int i = 0; i < txCnt; i++) {
+                for (int j = 0; j < keysPerTx; j++) {
+                    int k = i * keysPerTx + j;
+
+                    assertEquals(k, cache.get(k).value());
+                }
+            }
+
+            stopGrid();
+
+            ignite = startGrid();
+
+            cache = ignite.cache(CACHE_NAME);
+
+            for (int i = 0; i < txCnt; i++) {
+                for (int j = 0; j < keysPerTx; j++) {
+                    int k = i * keysPerTx + j;
+
+                    assertEquals(k, cache.get(k).value());
+                }
+            }
+
+            for (int i = 0; i < txCnt; i++) {
+                for (int j = 0; j < keysPerTx; j++) {
+                    int k = i * keysPerTx + j;
+
+                    QueryCursor<List<?>> cur = cache.query(
+                        new SqlFieldsQuery("select sVal from IndexedValue where iVal=?").setArgs(k));
+
+                    List<List<?>> vals = cur.getAll();
+
+                    assertEquals(vals.size(), 1);
+                    assertEquals("string-" + k, vals.get(0).get(0));
+                }
+            }
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
+     * @throws Exception if failed.
+     */
+    public void testWalRecoveryRemoves() throws Exception {
+        Ignite ignite = startGrid();
+
+        try {
+            GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager)((IgniteEx)ignite).context()
+                .cache().context().database();
+
+            IgniteCache<Integer, IndexedValue> cache = ignite.cache(CACHE_NAME);
+
+            int txCnt = 100;
+
+            int keysPerTx = 10;
+
+            for (int i = 0; i < txCnt; i++) {
+                try (Transaction tx = ignite.transactions().txStart()) {
+                    for (int j = 0; j < keysPerTx; j++) {
+                        int k = i * keysPerTx + j;
+
+                        cache.put(k, new IndexedValue(k));
+                    }
+
+                    tx.commit();
+                }
+            }
+
+            for (int i = 0; i < txCnt; i++) {
+                for (int j = 0; j < keysPerTx; j++) {
+                    int k = i * keysPerTx + j;
+
+                    assertEquals(k, cache.get(k).value());
+                }
+            }
+
+            dbMgr.waitForCheckpoint("test");
+            dbMgr.enableCheckpoints(false).get();
+
+            for (int i = 0; i < txCnt / 2; i++) {
+                try (Transaction tx = ignite.transactions().txStart()) {
+                    for (int j = 0; j < keysPerTx; j++) {
+                        int k = i * keysPerTx + j;
+
+                        cache.remove(k);
+                    }
+
+                    tx.commit();
+                }
+            }
+
+            stopGrid();
+
+            ignite = startGrid();
+
+            cache = ignite.cache(CACHE_NAME);
+
+            for (int i = 0; i < txCnt; i++) {
+                for (int j = 0; j < keysPerTx; j++) {
+                    int k = i * keysPerTx + j;
+
+                    QueryCursor<List<?>> cur = cache.query(
+                        new SqlFieldsQuery("select sVal from IndexedValue where iVal=?").setArgs(k));
+
+                    List<List<?>> vals = cur.getAll();
+
+                    if (i < txCnt / 2) {
+                        assertNull(cache.get(k));
+                        assertTrue(F.isEmpty(vals));
+                    }
+                    else {
+                        assertEquals(k, cache.get(k).value());
+
+                        assertEquals(1, vals.size());
+                        assertEquals("string-" + k, vals.get(0).get(0));
+                    }
+                }
+            }
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
+     * @throws Exception if failed.
+     */
+    public void testRebalanceIterator() throws Exception {
+        extraCcfg = new CacheConfiguration(CACHE2_NAME);
+        extraCcfg.setAffinity(new RendezvousAffinityFunction(false, PARTS));
+
+        Ignite ignite = startGrid();
+
+        try {
+            GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager)((IgniteEx)ignite).context()
+                .cache().context().database();
+
+            dbMgr.waitForCheckpoint("test");
+
+            // This number depends on wal history size.
+            int entries = 25;
+
+            IgniteCache<Integer, Integer> cache = ignite.cache(CACHE_NAME);
+            IgniteCache<Integer, Integer> cache2 = ignite.cache(CACHE2_NAME);
+
+            for (int i = 0; i < entries; i++) {
+                // Put to partition 0.
+                cache.put(i * PARTS, i * PARTS);
+
+                // Put to partition 1.
+                cache.put(i * PARTS + 1, i * PARTS + 1);
+
+                // Put to another cache.
+                cache2.put(i, i);
+
+                dbMgr.waitForCheckpoint("test");
+            }
+
+            for (int i = 0; i < entries; i++) {
+                assertEquals((Integer)(i * PARTS), cache.get(i * PARTS));
+                assertEquals((Integer)(i * PARTS + 1), cache.get(i * PARTS + 1));
+                assertEquals((Integer)(i), cache2.get(i));
+            }
+
+            GridCacheContext<Object, Object> cctx = ((IgniteEx)ignite).context().cache().cache(CACHE_NAME).context();
+            IgniteCacheOffheapManager offh = cctx.offheap();
+            AffinityTopologyVersion topVer = cctx.affinity().affinityTopologyVersion();
+
+            for (int i = 0; i < entries; i++) {
+                try (IgniteRebalanceIterator it = offh.rebalanceIterator(0, topVer, (long)i)) {
+                    assertTrue("Not historical for iteration: " + i, it.historical());
+
+                    assertNotNull(it);
+
+                    for (int j = i; j < entries; j++) {
+                        assertTrue("i=" + i + ", j=" + j, it.hasNextX());
+
+                        CacheDataRow row = it.next();
+
+                        assertEquals(j * PARTS, (int)row.key().value(cctx.cacheObjectContext(), false));
+                        assertEquals(j * PARTS, (int)row.value().value(cctx.cacheObjectContext(), false));
+                    }
+
+                    assertFalse(it.hasNext());
+                }
+
+                try (IgniteRebalanceIterator it = offh.rebalanceIterator(1, topVer, (long)i)) {
+                    assertNotNull(it);
+
+                    assertTrue("Not historical for iteration: " + i, it.historical());
+
+                    for (int j = i; j < entries; j++) {
+                        assertTrue(it.hasNextX());
+
+                        CacheDataRow row = it.next();
+
+                        assertEquals(j * PARTS + 1, (int)row.key().value(cctx.cacheObjectContext(), false));
+                        assertEquals(j * PARTS + 1, (int)row.value().value(cctx.cacheObjectContext(), false));
+                    }
+
+                    assertFalse(it.hasNext());
+                }
+            }
+
+            stopAllGrids();
+
+            // Check that iterator is valid after restart.
+            ignite = startGrid();
+
+            cctx = ((IgniteEx)ignite).context().cache().cache(CACHE_NAME).context();
+            offh = cctx.offheap();
+            topVer = cctx.affinity().affinityTopologyVersion();
+
+            for (int i = 0; i < entries; i++) {
+                long start = System.currentTimeMillis();
+
+                try (IgniteRebalanceIterator it = offh.rebalanceIterator(0, topVer, (long)i)) {
+                    long end = System.currentTimeMillis();
+
+                    info("Time to get iterator: " + (end - start));
+
+                    assertTrue("Not historical for iteration: " + i, it.historical());
+
+                    assertNotNull(it);
+
+                    start = System.currentTimeMillis();
+
+                    for (int j = i; j < entries; j++) {
+                        assertTrue("i=" + i + ", j=" + j, it.hasNextX());
+
+                        CacheDataRow row = it.next();
+
+                        assertEquals(j * PARTS, (int)row.key().value(cctx.cacheObjectContext(), false));
+                        assertEquals(j * PARTS, (int)row.value().value(cctx.cacheObjectContext(), false));
+                    }
+
+                    end = System.currentTimeMillis();
+
+                    info("Time to iterate: " + (end - start));
+
+                    assertFalse(it.hasNext());
+                }
+
+                try (IgniteRebalanceIterator it = offh.rebalanceIterator(1, topVer, (long)i)) {
+                    assertNotNull(it);
+
+                    assertTrue("Not historical for iteration: " + i, it.historical());
+
+                    for (int j = i; j < entries; j++) {
+                        assertTrue(it.hasNextX());
+
+                        CacheDataRow row = it.next();
+
+                        assertEquals(j * PARTS + 1, (int)row.key().value(cctx.cacheObjectContext(), false));
+                        assertEquals(j * PARTS + 1, (int)row.value().value(cctx.cacheObjectContext(), false));
+                    }
+
+                    assertFalse(it.hasNext());
+                }
+            }
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
+     * @throws Exception if failed.
+     */
+    public void testCheckpointHistory() throws Exception {
+        Ignite ignite = startGrid();
+
+        try {
+            GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager)((IgniteEx)ignite).context()
+                .cache().context().database();
+
+            dbMgr.waitForCheckpoint("test");
+
+            // This number depends on wal history size.
+            int entries = WAL_HIST_SIZE * 2;
+
+            IgniteCache<Integer, Integer> cache = ignite.cache(CACHE_NAME);
+
+            for (int i = 0; i < entries; i++) {
+                // Put to partition 0.
+                cache.put(i * PARTS, i * PARTS);
+
+                // Put to partition 1.
+                cache.put(i * PARTS + 1, i * PARTS + 1);
+
+                dbMgr.waitForCheckpoint("test");
+            }
+
+            GridCacheDatabaseSharedManager.CheckpointHistory hist = dbMgr.checkpointHistory();
+
+            assertTrue(hist.checkpoints().size() <= WAL_HIST_SIZE);
+
+            File cpDir = dbMgr.checkpointDirectory();
+
+            File[] cpFiles = cpDir.listFiles();
+
+            assertTrue(cpFiles.length <= WAL_HIST_SIZE * 2);
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testWalAfterPreloading() throws Exception {
+        Ignite ignite = startGrid();
+
+        try {
+            GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager)((IgniteEx)ignite).context()
+                .cache().context().database();
+
+            dbMgr.enableCheckpoints(false).get();
+
+            int entries = 100;
+
+            try (IgniteDataStreamer<Integer, Integer> streamer = ignite.dataStreamer(CACHE_NAME)) {
+                for (int i = 0; i < entries; i++)
+                    streamer.addData(i, i);
+            }
+
+            IgniteCache<Integer, Integer> cache = ignite.cache(CACHE_NAME);
+
+            for (int i = 0; i < entries; i++)
+                assertEquals(new Integer(i), cache.get(i));
+
+            stopGrid();
+
+            ignite = startGrid();
+
+            cache = ignite.cache(CACHE_NAME);
+
+            for (int i = 0; i < entries; i++)
+                assertEquals(new Integer(i), cache.get(i));
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testRecoveryRandomPutRemove() throws Exception {
+        try {
+            pageSize = 1024;
+
+            extraCcfg = new CacheConfiguration(CACHE2_NAME);
+            extraCcfg.setAffinity(new RendezvousAffinityFunction(false, PARTS));
+
+            Ignite ignite = startGrid(0);
+
+            GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager)((IgniteEx)ignite).context()
+                .cache().context().database();
+
+            dbMgr.enableCheckpoints(false).get();
+
+            IgniteCache<Integer, IndexedValue> cache1 = ignite.cache(CACHE_NAME);
+            IgniteCache<Object, Object> cache2 = ignite.cache(CACHE2_NAME);
+
+            final int KEYS1 = 100;
+
+            for (int i = 0; i < KEYS1; i++)
+                cache1.put(i, new IndexedValue(i));
+
+            for (int i = 0; i < KEYS1; i++) {
+                if (i % 2 == 0)
+                    cache1.remove(i);
+            }
+
+            ThreadLocalRandom rnd = ThreadLocalRandom.current();
+
+            for (int i = 0; i < KEYS1; i++) {
+                cache2.put(i, new byte[rnd.nextInt(512)]);
+
+                if (rnd.nextBoolean())
+                    cache2.put(i, new byte[rnd.nextInt(512)]);
+
+                if (rnd.nextBoolean())
+                    cache2.remove(i);
+            }
+
+            ignite.close();
+
+            ignite = startGrid(0);
+
+            ignite.cache(CACHE_NAME).put(1, new IndexedValue(0));
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testRecoveryNoPageLost1() throws Exception {
+        recoveryNoPageLost(false);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testRecoveryNoPageLost2() throws Exception {
+        recoveryNoPageLost(true);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testRecoveryNoPageLost3() throws Exception {
+        try {
+            pageSize = 1024;
+            checkpointFreq = 100L;
+            extraCcfg = new CacheConfiguration(CACHE2_NAME);
+            extraCcfg.setAffinity(new RendezvousAffinityFunction(false, 32));
+
+            List<Integer> pages = null;
+
+            for (int iter = 0; iter < 5; iter++) {
+                log.info("Start node: " + iter);
+
+                Ignite ignite = startGrid(0);
+
+                if (pages != null) {
+                    List<Integer> curPags = allocatedPages(ignite, CACHE2_NAME);
+
+                    assertEquals("Iter = " + iter, pages, curPags);
+                }
+
+                final IgniteCache<Integer, Object> cache = ignite.cache(CACHE2_NAME);
+
+                final int ops = ThreadLocalRandom.current().nextInt(10) + 10;
+
+                GridTestUtils.runMultiThreaded(new Callable<Void>() {
+                    @Override public Void call() throws Exception {
+                        ThreadLocalRandom rnd = ThreadLocalRandom.current();
+
+                        for (int i = 0; i < ops; i++) {
+                            Integer key = rnd.nextInt(1000);
+
+                            cache.put(key, new byte[rnd.nextInt(512)]);
+
+                            if (rnd.nextBoolean())
+                                cache.remove(key);
+                        }
+
+                        return null;
+                    }
+                }, 10, "update");
+
+                pages = allocatedPages(ignite, CACHE2_NAME);
+
+                Ignition.stop(ignite.name(), false); //will make checkpoint
+            }
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
+     * @param checkpoint Checkpoint enable flag.
+     * @throws Exception If failed.
+     */
+    private void recoveryNoPageLost(boolean checkpoint) throws Exception {
+        try {
+            pageSize = 1024;
+            extraCcfg = new CacheConfiguration(CACHE2_NAME);
+            extraCcfg.setAffinity(new RendezvousAffinityFunction(false, 32));
+
+            List<Integer> pages = null;
+
+            AtomicInteger cnt = new AtomicInteger();
+
+            for (int iter = 0; iter < 5; iter++) {
+                log.info("Start node: " + iter);
+
+                Ignite ignite = startGrid(0);
+
+                GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager)((IgniteEx)ignite).context()
+                    .cache().context().database();
+
+                if (!checkpoint)
+                    dbMgr.enableCheckpoints(false).get();
+
+                if (pages != null) {
+                    List<Integer> curPags = allocatedPages(ignite, CACHE2_NAME);
+
+                    assertEquals(pages, curPags);
+                }
+
+                IgniteCache<Integer, Object> cache = ignite.cache(CACHE2_NAME);
+
+                for (int i = 0; i < 128; i++)
+                    cache.put(cnt.incrementAndGet(), new byte[256 + iter * 100]);
+
+                pages = allocatedPages(ignite, CACHE2_NAME);
+
+                ignite.close();
+            }
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
+     * @param ignite Node.
+     * @param cacheName Cache name.
+     * @return Allocated pages per-store.
+     * @throws Exception If failed.
+     */
+    private List<Integer> allocatedPages(Ignite ignite, String cacheName) throws Exception {
+        FilePageStoreManager storeMgr =
+            (FilePageStoreManager)((IgniteEx)ignite).context().cache().context().pageStore();
+
+        int parts = ignite.affinity(cacheName).partitions();
+
+        List<Integer> res = new ArrayList<>(parts);
+
+        for (int p = 0; p < parts; p++) {
+            PageStore store = storeMgr.getStore(CU.cacheId(cacheName), p);
+
+            store.sync();
+
+            res.add(store.pages());
+        }
+
+        PageStore store = storeMgr.getStore(CU.cacheId(cacheName), PageIdAllocator.INDEX_PARTITION);
+
+        store.sync();
+
+        res.add(store.pages());
+
+        return res;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testFreeListRecovery() throws Exception {
+        try {
+            pageSize = 1024;
+            extraCcfg = new CacheConfiguration(CACHE2_NAME);
+
+            Ignite ignite = startGrid(0);
+
+            IgniteCache<Integer, IndexedValue> cache1 = ignite.cache(CACHE_NAME);
+            IgniteCache<Object, Object> cache2 = ignite.cache(CACHE2_NAME);
+
+            final int KEYS1 = 2048;
+
+            for (int i = 0; i < KEYS1; i++)
+                cache1.put(i, new IndexedValue(i));
+
+            for (int i = 0; i < KEYS1; i++) {
+                if (i % 2 == 0)
+                    cache1.remove(i);
+            }
+
+            ThreadLocalRandom rnd = ThreadLocalRandom.current();
+
+            for (int i = 0; i < KEYS1; i++) {
+                cache2.put(i, new byte[rnd.nextInt(512)]);
+
+                if (rnd.nextBoolean())
+                    cache2.put(i, new byte[rnd.nextInt(512)]);
+
+                if (rnd.nextBoolean())
+                    cache2.remove(i);
+            }
+
+            Map<Integer, T2<Map<Integer, long[]>, int[]>> cache1_1 = getFreeListData(ignite, CACHE_NAME);
+            Map<Integer, T2<Map<Integer, long[]>, int[]>> cache2_1 = getFreeListData(ignite, CACHE2_NAME);
+            T2<long[], Integer> rl1_1 = getReuseListData(ignite, CACHE_NAME);
+            T2<long[], Integer> rl2_1 = getReuseListData(ignite, CACHE2_NAME);
+
+            ignite.close();
+
+            ignite = startGrid(0);
+
+            cache1 = ignite.cache(CACHE_NAME);
+            cache2 = ignite.cache(CACHE2_NAME);
+
+            for (int i = 0; i < KEYS1; i++) {
+                cache1.get(i);
+                cache2.get(i);
+            }
+
+            Map<Integer, T2<Map<Integer, long[]>, int[]>> cache1_2 = getFreeListData(ignite, CACHE_NAME);
+            Map<Integer, T2<Map<Integer, long[]>, int[]>> cache2_2 = getFreeListData(ignite, CACHE2_NAME);
+            T2<long[], Integer> rl1_2 = getReuseListData(ignite, CACHE_NAME);
+            T2<long[], Integer> rl2_2 = getReuseListData(ignite, CACHE2_NAME);
+
+            checkEquals(cache1_1, cache1_2);
+            checkEquals(cache2_1, cache2_2);
+            checkEquals(rl1_1, rl1_2);
+            checkEquals(rl2_1, rl2_2);
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
+     * @param ignite Node.
+     * @param cacheName Cache name.
+     * @return Cache reuse list data.
+     */
+    private T2<long[], Integer> getReuseListData(Ignite ignite, String cacheName) {
+        GridCacheContext ctx = ((IgniteEx)ignite).context().cache().cache(cacheName).context();
+
+        ReuseListImpl reuseList = GridTestUtils.getFieldValue(ctx.offheap(), "reuseList");
+        PagesList.Stripe[] bucket = GridTestUtils.getFieldValue(reuseList, "bucket");
+
+        long[] ids = null;
+
+        if (bucket != null) {
+            ids = new long[bucket.length];
+
+            for (int i = 0; i < bucket.length; i++)
+                ids[i] = bucket[i].tailId;
+        }
+
+//        AtomicIntegerArray cnts = GridTestUtils.getFieldValue(reuseList, PagesList.class, "cnts");
+//        assertEquals(1, cnts.length());
+
+        return new T2<>(ids, 0);
+    }
+
+    /**
+     * @param rl1 Data 1 (before stop).
+     * @param rl2 Data 2 (after restore).
+     */
+    private void checkEquals(T2<long[], Integer> rl1, T2<long[], Integer> rl2) {
+        Assert.assertArrayEquals(rl1.get1(), rl2.get1());
+        assertEquals(rl1.get2(), rl2.get2());
+    }
+
+    /**
+     * @param partsLists1 Data 1 (before stop).
+     * @param partsLists2 Data 2 (after restore).
+     */
+    private void checkEquals(Map<Integer, T2<Map<Integer, long[]>, int[]>> partsLists1,
+        Map<Integer, T2<Map<Integer, long[]>, int[]>> partsLists2) {
+        assertEquals(partsLists1.size(), partsLists2.size());
+
+        for (Integer part : partsLists1.keySet()) {
+            T2<Map<Integer, long[]>, int[]> t1 = partsLists1.get(part);
+            T2<Map<Integer, long[]>, int[]> t2 = partsLists2.get(part);
+
+            Map<Integer, long[]> m1 = t1.get1();
+            Map<Integer, long[]> m2 = t2.get1();
+
+            assertEquals(m1.size(), m2.size());
+
+            for (Integer bucket : m1.keySet()) {
+                long tails1[] = m1.get(bucket);
+                long tails2[] = m2.get(bucket);
+
+                Assert.assertArrayEquals(tails1, tails2);
+            }
+
+            Assert.assertArrayEquals("Wrong counts [part=" + part + ']', t1.get2(), t2.get2());
+        }
+    }
+
+    /**
+     * @param ignite Node.
+     * @param cacheName Cache name.
+     * @return Cache free lists data.
+     */
+    private Map<Integer, T2<Map<Integer, long[]>, int[]>> getFreeListData(Ignite ignite, String cacheName) {
+        GridCacheContext ctx = ((IgniteEx)ignite).context().cache().cache(cacheName).context();
+
+        List<GridDhtLocalPartition> parts = ctx.topology().localPartitions();
+
+        assertTrue(!parts.isEmpty());
+        assertEquals(ctx.affinity().partitions(), parts.size());
+
+        Map<Integer, T2<Map<Integer, long[]>, int[]>> res = new HashMap<>();
+
+        boolean foundNonEmpty = false;
+        boolean foundTails = false;
+
+        for (GridDhtLocalPartition part : parts) {
+            FreeListImpl freeList = GridTestUtils.getFieldValue(part.dataStore(), "freeList");
+
+            if (freeList == null)
+                // Lazy store.
+                continue;
+
+            AtomicReferenceArray<PagesList.Stripe[]> buckets = GridTestUtils.getFieldValue(freeList,
+                FreeListImpl.class, "buckets");
+            //AtomicIntegerArray cnts = GridTestUtils.getFieldValue(freeList, PagesList.class, "cnts");
+
+            assertNotNull(buckets);
+            //assertNotNull(cnts);
+            assertTrue(buckets.length() > 0);
+            //assertEquals(cnts.length(), buckets.length());
+
+            Map<Integer, long[]> tailsPerBucket = new HashMap<>();
+
+            for (int i = 0; i < buckets.length(); i++) {
+                PagesList.Stripe[] tails = buckets.get(i);
+
+                long ids[] = null;
+
+                if (tails != null) {
+                    ids = new long[tails.length];
+
+                    for (int j = 0; j < tails.length; j++)
+                        ids[j] = tails[j].tailId;
+                }
+
+                tailsPerBucket.put(i, ids);
+
+                    if (tails != null) {
+                        assertTrue(tails.length > 0);
+
+                        foundTails = true;
+                    }
+                }
+
+//            int[] cntsPerBucket = new int[cnts.length()];
+//
+//            for (int i = 0; i < cnts.length(); i++) {
+//                cntsPerBucket[i] = cnts.get(i);
+//
+//                if (cntsPerBucket[i] > 0)
+//                    foundNonEmpty = true;
+//            }
+
+            res.put(part.id(), new T2<>(tailsPerBucket, (int[])null));
+        }
+
+        //assertTrue(foundNonEmpty);
+        assertTrue(foundTails);
+
+        return res;
+    }
+
+    /**
+     *
+     */
+    private static class IndexedValue {
+        /** */
+        @QuerySqlField(index = true)
+        private int iVal;
+
+        /** */
+        @QuerySqlField
+        private String sVal;
+
+        /**
+         * @param iVal Indexed value.
+         */
+        private IndexedValue(int iVal) {
+            this.iVal = iVal;
+            sVal = "string-" + iVal;
+        }
+
+        /**
+         * @return Value.
+         */
+        private int value() {
+            return iVal;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/cd4d0400/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/BPlusTreePageMemoryImplTest.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/BPlusTreePageMemoryImplTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/BPlusTreePageMemoryImplTest.java
new file mode 100644
index 0000000..a35903c
--- /dev/null
+++ b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/BPlusTreePageMemoryImplTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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.cache.database.pagemem;
+
+import java.nio.ByteBuffer;
+import org.apache.ignite.configuration.MemoryPolicyConfiguration;
+import org.apache.ignite.internal.mem.DirectMemoryProvider;
+import org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider;
+import org.apache.ignite.internal.pagemem.FullPageId;
+import org.apache.ignite.internal.pagemem.PageMemory;
+import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
+import org.apache.ignite.internal.processors.cache.database.CheckpointLockStateChecker;
+import org.apache.ignite.internal.processors.cache.database.IgniteCacheDatabaseSharedManager;
+import org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl;
+import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryEx;
+import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryImpl;
+import org.apache.ignite.internal.processors.database.BPlusTreeSelfTest;
+import org.apache.ignite.internal.util.typedef.CIX3;
+import org.apache.ignite.testframework.junits.GridTestKernalContext;
+
+/**
+ *
+ */
+public class BPlusTreePageMemoryImplTest extends BPlusTreeSelfTest {
+    /** {@inheritDoc} */
+    @Override protected PageMemory createPageMemory() throws Exception {
+        long[] sizes = new long[CPUS + 1];
+
+        for (int i = 0; i < sizes.length; i++)
+            sizes[i] = 1024 * MB / CPUS;
+
+        sizes[CPUS] = 10 * MB;
+
+        DirectMemoryProvider provider = new UnsafeMemoryProvider(log);
+
+        GridCacheSharedContext<Object, Object> sharedCtx = new GridCacheSharedContext<>(
+            new GridTestKernalContext(log),
+            null,
+            null,
+            null,
+            new NoOpPageStoreManager(),
+            new NoOpWALManager(),
+            new IgniteCacheDatabaseSharedManager(),
+            null,
+            null,
+            null,
+            null,
+            null,
+            null,
+            null,
+            null
+        );
+
+        PageMemory mem = new PageMemoryImpl(
+            provider, sizes,
+            sharedCtx,
+            PAGE_SIZE,
+            new CIX3<FullPageId, ByteBuffer, Integer>() {
+                @Override public void applyx(FullPageId fullPageId, ByteBuffer byteBuf, Integer tag) {
+                    assert false : "No evictions should happen during the test";
+                }
+            },
+            new CIX3<Long, FullPageId, PageMemoryEx>(){
+                @Override public void applyx(Long aLong, FullPageId fullPageId, PageMemoryEx ex) {
+                }
+            },
+            new CheckpointLockStateChecker() {
+                @Override public boolean checkpointLockIsHeldByThread() {
+                    return true;
+                }
+            },
+            new MemoryMetricsImpl(new MemoryPolicyConfiguration()));
+
+        mem.start();
+
+        return mem;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected long acquiredPages() {
+        return ((PageMemoryImpl)pageMem).acquiredPages();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/cd4d0400/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/BPlusTreeReuseListPageMemoryImplSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/BPlusTreeReuseListPageMemoryImplSelfTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/BPlusTreeReuseListPageMemoryImplSelfTest.java
deleted file mode 100644
index b533ed1..0000000
--- a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/BPlusTreeReuseListPageMemoryImplSelfTest.java
+++ /dev/null
@@ -1,114 +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.cache.database.pagemem;
-
-import java.nio.ByteBuffer;
-import org.apache.ignite.configuration.MemoryPolicyConfiguration;
-import org.apache.ignite.internal.mem.DirectMemoryProvider;
-import org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider;
-import org.apache.ignite.internal.pagemem.FullPageId;
-import org.apache.ignite.internal.pagemem.PageMemory;
-import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
-import org.apache.ignite.internal.processors.cache.database.CheckpointLockStateChecker;
-import org.apache.ignite.internal.processors.cache.database.IgniteCacheDatabaseSharedManager;
-import org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl;
-import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryEx;
-import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryImpl;
-import org.apache.ignite.internal.processors.cache.database.wal.FileWriteAheadLogManager;
-import org.apache.ignite.internal.processors.database.BPlusTreeReuseSelfTest;
-import org.apache.ignite.internal.util.lang.GridInClosure3X;
-import org.apache.ignite.internal.util.typedef.CIX3;
-import org.apache.ignite.testframework.junits.GridTestKernalContext;
-
-/**
- *
- */
-public class BPlusTreeReuseListPageMemoryImplSelfTest extends BPlusTreeReuseSelfTest {
-    /** {@inheritDoc} */
-    @Override protected void beforeTest() throws Exception {
-        System.setProperty(FileWriteAheadLogManager.IGNITE_PDS_WAL_MODE, "LOG_ONLY");
-
-        super.beforeTest();
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTest() throws Exception {
-        super.afterTest();
-
-        System.clearProperty(FileWriteAheadLogManager.IGNITE_PDS_WAL_MODE);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected PageMemory createPageMemory() throws Exception {
-        long[] sizes = new long[CPUS + 1];
-
-        for (int i = 0; i < sizes.length; i++)
-            sizes[i] = 1024 * MB / CPUS;
-
-        sizes[CPUS] = 10 * MB;
-
-        DirectMemoryProvider provider = new UnsafeMemoryProvider(log);
-
-        GridCacheSharedContext<Object, Object> sharedCtx = new GridCacheSharedContext<>(
-            new GridTestKernalContext(log),
-            null,
-            null,
-            null,
-            new NoOpPageStoreManager(),
-            new NoOpWALManager(),
-            new IgniteCacheDatabaseSharedManager(),
-            null,
-            null,
-            null,
-            null,
-            null,
-            null,
-            null,
-            null
-        );
-
-        PageMemory mem = new PageMemoryImpl(
-            provider, sizes,
-            sharedCtx,
-            PAGE_SIZE,
-            new CIX3<FullPageId, ByteBuffer, Integer>() {
-                @Override public void applyx(FullPageId fullPageId, ByteBuffer byteBuf, Integer tag) {
-                    assert false : "No evictions should happen during the test";
-                }
-            },
-            new GridInClosure3X<Long, FullPageId, PageMemoryEx>() {
-                @Override public void applyx(Long page, FullPageId fullPageId, PageMemoryEx pageMem) {
-                }
-            }, new CheckpointLockStateChecker() {
-                @Override public boolean checkpointLockIsHeldByThread() {
-                    return true;
-                }
-            },
-            new MemoryMetricsImpl(new MemoryPolicyConfiguration())
-        );
-
-        mem.start();
-
-        return mem;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected long acquiredPages() {
-        return ((PageMemoryImpl)pageMem).acquiredPages();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/cd4d0400/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/BPlusTreeReuseListPageMemoryImplTest.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/BPlusTreeReuseListPageMemoryImplTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/BPlusTreeReuseListPageMemoryImplTest.java
new file mode 100644
index 0000000..5c4502c
--- /dev/null
+++ b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/BPlusTreeReuseListPageMemoryImplTest.java
@@ -0,0 +1,99 @@
+/*
+ * 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.cache.database.pagemem;
+
+import java.nio.ByteBuffer;
+import org.apache.ignite.configuration.MemoryPolicyConfiguration;
+import org.apache.ignite.internal.mem.DirectMemoryProvider;
+import org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider;
+import org.apache.ignite.internal.pagemem.FullPageId;
+import org.apache.ignite.internal.pagemem.PageMemory;
+import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
+import org.apache.ignite.internal.processors.cache.database.CheckpointLockStateChecker;
+import org.apache.ignite.internal.processors.cache.database.IgniteCacheDatabaseSharedManager;
+import org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl;
+import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryEx;
+import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryImpl;
+import org.apache.ignite.internal.processors.database.BPlusTreeReuseSelfTest;
+import org.apache.ignite.internal.util.lang.GridInClosure3X;
+import org.apache.ignite.internal.util.typedef.CIX3;
+import org.apache.ignite.testframework.junits.GridTestKernalContext;
+
+/**
+ *
+ */
+public class BPlusTreeReuseListPageMemoryImplTest extends BPlusTreeReuseSelfTest {
+    /** {@inheritDoc} */
+    @Override protected PageMemory createPageMemory() throws Exception {
+        long[] sizes = new long[CPUS + 1];
+
+        for (int i = 0; i < sizes.length; i++)
+            sizes[i] = 1024 * MB / CPUS;
+
+        sizes[CPUS] = 10 * MB;
+
+        DirectMemoryProvider provider = new UnsafeMemoryProvider(log);
+
+        GridCacheSharedContext<Object, Object> sharedCtx = new GridCacheSharedContext<>(
+            new GridTestKernalContext(log),
+            null,
+            null,
+            null,
+            new NoOpPageStoreManager(),
+            new NoOpWALManager(),
+            new IgniteCacheDatabaseSharedManager(),
+            null,
+            null,
+            null,
+            null,
+            null,
+            null,
+            null,
+            null
+        );
+
+        PageMemory mem = new PageMemoryImpl(
+            provider, sizes,
+            sharedCtx,
+            PAGE_SIZE,
+            new CIX3<FullPageId, ByteBuffer, Integer>() {
+                @Override public void applyx(FullPageId fullPageId, ByteBuffer byteBuf, Integer tag) {
+                    assert false : "No evictions should happen during the test";
+                }
+            },
+            new GridInClosure3X<Long, FullPageId, PageMemoryEx>() {
+                @Override public void applyx(Long page, FullPageId fullPageId, PageMemoryEx pageMem) {
+                }
+            }, new CheckpointLockStateChecker() {
+                @Override public boolean checkpointLockIsHeldByThread() {
+                    return true;
+                }
+            },
+            new MemoryMetricsImpl(new MemoryPolicyConfiguration())
+        );
+
+        mem.start();
+
+        return mem;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected long acquiredPages() {
+        return ((PageMemoryImpl)pageMem).acquiredPages();
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/cd4d0400/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/BPlusTreeSelfTestPageMemoryImplSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/BPlusTreeSelfTestPageMemoryImplSelfTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/BPlusTreeSelfTestPageMemoryImplSelfTest.java
deleted file mode 100644
index 1eab1f8..0000000
--- a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/BPlusTreeSelfTestPageMemoryImplSelfTest.java
+++ /dev/null
@@ -1,113 +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.cache.database.pagemem;
-
-import java.nio.ByteBuffer;
-import org.apache.ignite.configuration.MemoryPolicyConfiguration;
-import org.apache.ignite.internal.mem.DirectMemoryProvider;
-import org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider;
-import org.apache.ignite.internal.pagemem.FullPageId;
-import org.apache.ignite.internal.pagemem.PageMemory;
-import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
-import org.apache.ignite.internal.processors.cache.database.CheckpointLockStateChecker;
-import org.apache.ignite.internal.processors.cache.database.IgniteCacheDatabaseSharedManager;
-import org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl;
-import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryEx;
-import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryImpl;
-import org.apache.ignite.internal.processors.cache.database.wal.FileWriteAheadLogManager;
-import org.apache.ignite.internal.processors.database.BPlusTreeSelfTest;
-import org.apache.ignite.internal.util.typedef.CIX3;
-import org.apache.ignite.testframework.junits.GridTestKernalContext;
-
-/**
- *
- */
-public class BPlusTreeSelfTestPageMemoryImplSelfTest extends BPlusTreeSelfTest {
-    /** {@inheritDoc} */
-    @Override protected void beforeTest() throws Exception {
-        System.setProperty(FileWriteAheadLogManager.IGNITE_PDS_WAL_MODE, "LOG_ONLY");
-
-        super.beforeTest();
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTest() throws Exception {
-        super.afterTest();
-
-        System.clearProperty(FileWriteAheadLogManager.IGNITE_PDS_WAL_MODE);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected PageMemory createPageMemory() throws Exception {
-        long[] sizes = new long[CPUS + 1];
-
-        for (int i = 0; i < sizes.length; i++)
-            sizes[i] = 1024 * MB / CPUS;
-
-        sizes[CPUS] = 10 * MB;
-
-        DirectMemoryProvider provider = new UnsafeMemoryProvider(log);
-
-        GridCacheSharedContext<Object, Object> sharedCtx = new GridCacheSharedContext<>(
-            new GridTestKernalContext(log),
-            null,
-            null,
-            null,
-            new NoOpPageStoreManager(),
-            new NoOpWALManager(),
-            new IgniteCacheDatabaseSharedManager(),
-            null,
-            null,
-            null,
-            null,
-            null,
-            null,
-            null,
-            null
-        );
-
-        PageMemory mem = new PageMemoryImpl(
-            provider, sizes,
-            sharedCtx,
-            PAGE_SIZE,
-            new CIX3<FullPageId, ByteBuffer, Integer>() {
-                @Override public void applyx(FullPageId fullPageId, ByteBuffer byteBuf, Integer tag) {
-                    assert false : "No evictions should happen during the test";
-                }
-            },
-            new CIX3<Long, FullPageId, PageMemoryEx>(){
-                @Override public void applyx(Long aLong, FullPageId fullPageId, PageMemoryEx ex) {
-                }
-            },
-            new CheckpointLockStateChecker() {
-                @Override public boolean checkpointLockIsHeldByThread() {
-                    return true;
-                }
-            },
-            new MemoryMetricsImpl(new MemoryPolicyConfiguration()));
-
-        mem.start();
-
-        return mem;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected long acquiredPages() {
-        return ((PageMemoryImpl)pageMem).acquiredPages();
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/cd4d0400/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/MetadataStoragePageMemoryImplSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/MetadataStoragePageMemoryImplSelfTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/MetadataStoragePageMemoryImplSelfTest.java
deleted file mode 100644
index c9c6c18..0000000
--- a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/MetadataStoragePageMemoryImplSelfTest.java
+++ /dev/null
@@ -1,104 +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.cache.database.pagemem;
-
-import java.io.File;
-import java.nio.ByteBuffer;
-import org.apache.ignite.configuration.MemoryPolicyConfiguration;
-import org.apache.ignite.internal.mem.DirectMemoryProvider;
-import org.apache.ignite.internal.mem.file.MappedFileMemoryProvider;
-import org.apache.ignite.internal.pagemem.FullPageId;
-import org.apache.ignite.internal.pagemem.PageMemory;
-import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
-import org.apache.ignite.internal.processors.cache.database.CheckpointLockStateChecker;
-import org.apache.ignite.internal.processors.cache.database.IgniteCacheDatabaseSharedManager;
-import org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl;
-import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryEx;
-import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryImpl;
-import org.apache.ignite.internal.processors.database.MetadataStorageSelfTest;
-import org.apache.ignite.internal.util.lang.GridInClosure3X;
-import org.apache.ignite.internal.util.typedef.CIX3;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.testframework.junits.GridTestKernalContext;
-
-/**
- *
- */
-public class MetadataStoragePageMemoryImplSelfTest extends MetadataStorageSelfTest{
-    /** Make sure page is small enough to trigger multiple pages in a linked list. */
-    public static final int PAGE_SIZE = 1024;
-
-    /** */
-    private static File allocationPath;
-
-    /** {@inheritDoc} */
-    @Override protected void beforeTestsStarted() throws Exception {
-        allocationPath = U.resolveWorkDirectory(U.defaultWorkDirectory(), "pagemem", false);
-    }
-
-    /**
-     * @param clean Clean flag. If {@code true}, will clean previous memory state and allocate
-     *      new empty page memory.
-     * @return Page memory instance.
-     */
-    @Override protected PageMemory memory(boolean clean) throws Exception {
-        long[] sizes = new long[10];
-
-        for (int i = 0; i < sizes.length; i++)
-            sizes[i] = 1024 * 1024;
-
-        DirectMemoryProvider provider = new MappedFileMemoryProvider(log(), allocationPath);
-
-        GridCacheSharedContext<Object, Object> sharedCtx = new GridCacheSharedContext<>(
-            new GridTestKernalContext(log),
-            null,
-            null,
-            null,
-            new NoOpPageStoreManager(),
-            new NoOpWALManager(),
-            new IgniteCacheDatabaseSharedManager(),
-            null,
-            null,
-            null,
-            null,
-            null,
-            null,
-            null,
-            null
-        );
-
-        return new PageMemoryImpl(
-            provider, sizes,
-            sharedCtx,
-            PAGE_SIZE,
-            new CIX3<FullPageId, ByteBuffer, Integer>() {
-                @Override public void applyx(FullPageId fullPageId, ByteBuffer byteBuf, Integer tag) {
-                    assert false : "No evictions should happen during the test";
-                }
-            },
-            new GridInClosure3X<Long, FullPageId, PageMemoryEx>() {
-                @Override public void applyx(Long page, FullPageId fullId, PageMemoryEx pageMem) {
-                }
-            }, new CheckpointLockStateChecker() {
-                @Override public boolean checkpointLockIsHeldByThread() {
-                    return true;
-                }
-            },
-            new MemoryMetricsImpl(new MemoryPolicyConfiguration()));
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/cd4d0400/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/MetadataStoragePageMemoryImplTest.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/MetadataStoragePageMemoryImplTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/MetadataStoragePageMemoryImplTest.java
new file mode 100644
index 0000000..a6e241c
--- /dev/null
+++ b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/MetadataStoragePageMemoryImplTest.java
@@ -0,0 +1,104 @@
+/*
+ * 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.cache.database.pagemem;
+
+import java.io.File;
+import java.nio.ByteBuffer;
+import org.apache.ignite.configuration.MemoryPolicyConfiguration;
+import org.apache.ignite.internal.mem.DirectMemoryProvider;
+import org.apache.ignite.internal.mem.file.MappedFileMemoryProvider;
+import org.apache.ignite.internal.pagemem.FullPageId;
+import org.apache.ignite.internal.pagemem.PageMemory;
+import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
+import org.apache.ignite.internal.processors.cache.database.CheckpointLockStateChecker;
+import org.apache.ignite.internal.processors.cache.database.IgniteCacheDatabaseSharedManager;
+import org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl;
+import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryEx;
+import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryImpl;
+import org.apache.ignite.internal.processors.database.MetadataStorageSelfTest;
+import org.apache.ignite.internal.util.lang.GridInClosure3X;
+import org.apache.ignite.internal.util.typedef.CIX3;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.testframework.junits.GridTestKernalContext;
+
+/**
+ *
+ */
+public class MetadataStoragePageMemoryImplTest extends MetadataStorageSelfTest{
+    /** Make sure page is small enough to trigger multiple pages in a linked list. */
+    public static final int PAGE_SIZE = 1024;
+
+    /** */
+    private static File allocationPath;
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        allocationPath = U.resolveWorkDirectory(U.defaultWorkDirectory(), "pagemem", false);
+    }
+
+    /**
+     * @param clean Clean flag. If {@code true}, will clean previous memory state and allocate
+     *      new empty page memory.
+     * @return Page memory instance.
+     */
+    @Override protected PageMemory memory(boolean clean) throws Exception {
+        long[] sizes = new long[10];
+
+        for (int i = 0; i < sizes.length; i++)
+            sizes[i] = 1024 * 1024;
+
+        DirectMemoryProvider provider = new MappedFileMemoryProvider(log(), allocationPath);
+
+        GridCacheSharedContext<Object, Object> sharedCtx = new GridCacheSharedContext<>(
+            new GridTestKernalContext(log),
+            null,
+            null,
+            null,
+            new NoOpPageStoreManager(),
+            new NoOpWALManager(),
+            new IgniteCacheDatabaseSharedManager(),
+            null,
+            null,
+            null,
+            null,
+            null,
+            null,
+            null,
+            null
+        );
+
+        return new PageMemoryImpl(
+            provider, sizes,
+            sharedCtx,
+            PAGE_SIZE,
+            new CIX3<FullPageId, ByteBuffer, Integer>() {
+                @Override public void applyx(FullPageId fullPageId, ByteBuffer byteBuf, Integer tag) {
+                    assert false : "No evictions should happen during the test";
+                }
+            },
+            new GridInClosure3X<Long, FullPageId, PageMemoryEx>() {
+                @Override public void applyx(Long page, FullPageId fullId, PageMemoryEx pageMem) {
+                }
+            }, new CheckpointLockStateChecker() {
+                @Override public boolean checkpointLockIsHeldByThread() {
+                    return true;
+                }
+            },
+            new MemoryMetricsImpl(new MemoryPolicyConfiguration()));
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/cd4d0400/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/PageMemoryImplNoLoadSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/PageMemoryImplNoLoadSelfTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/PageMemoryImplNoLoadSelfTest.java
deleted file mode 100644
index 8ff5345..0000000
--- a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/PageMemoryImplNoLoadSelfTest.java
+++ /dev/null
@@ -1,100 +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.cache.database.pagemem;
-
-import java.io.File;
-import java.nio.ByteBuffer;
-import org.apache.ignite.configuration.MemoryPolicyConfiguration;
-import org.apache.ignite.internal.mem.DirectMemoryProvider;
-import org.apache.ignite.internal.mem.file.MappedFileMemoryProvider;
-import org.apache.ignite.internal.pagemem.FullPageId;
-import org.apache.ignite.internal.pagemem.PageMemory;
-import org.apache.ignite.internal.pagemem.impl.PageMemoryNoLoadSelfTest;
-import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
-import org.apache.ignite.internal.processors.cache.database.CheckpointLockStateChecker;
-import org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl;
-import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryEx;
-import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryImpl;
-import org.apache.ignite.internal.util.lang.GridInClosure3X;
-import org.apache.ignite.internal.processors.cache.database.IgniteCacheDatabaseSharedManager;
-import org.apache.ignite.internal.util.typedef.CIX3;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.testframework.junits.GridTestKernalContext;
-
-/**
- *
- */
-public class PageMemoryImplNoLoadSelfTest extends PageMemoryNoLoadSelfTest {
-    /**
-     * @return Page memory implementation.
-     */
-    @Override protected PageMemory memory() throws Exception {
-        File memDir = U.resolveWorkDirectory(U.defaultWorkDirectory(), "pagemem", false);
-
-        long[] sizes = new long[10];
-
-        for (int i = 0; i < sizes.length; i++)
-            sizes[i] = 5 * 1024 * 1024;
-
-        DirectMemoryProvider provider = new MappedFileMemoryProvider(log(), memDir);
-
-        GridCacheSharedContext<Object, Object> sharedCtx = new GridCacheSharedContext<>(
-            new GridTestKernalContext(log),
-            null,
-            null,
-            null,
-            new NoOpPageStoreManager(),
-            new NoOpWALManager(),
-            new IgniteCacheDatabaseSharedManager(),
-            null,
-            null,
-            null,
-            null,
-            null,
-            null,
-            null,
-            null
-        );
-
-        return new PageMemoryImpl(
-            provider,
-            sizes,
-            sharedCtx,
-            PAGE_SIZE,
-            new CIX3<FullPageId, ByteBuffer, Integer>() {
-                @Override public void applyx(FullPageId fullPageId, ByteBuffer byteBuffer, Integer tag) {
-                    assert false : "No evictions should happen during the test";
-                }
-            },
-            new GridInClosure3X<Long, FullPageId, PageMemoryEx>() {
-                @Override public void applyx(Long page, FullPageId fullId, PageMemoryEx pageMem) {
-                }
-            },
-            new CheckpointLockStateChecker() {
-                @Override public boolean checkpointLockIsHeldByThread() {
-                    return true;
-                }
-            },
-            new MemoryMetricsImpl(new MemoryPolicyConfiguration()));
-    }
-
-    /** {@inheritDoc} */
-    @Override public void testPageHandleDeallocation() throws Exception {
-        // No-op.
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/cd4d0400/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/PageMemoryImplNoLoadTest.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/PageMemoryImplNoLoadTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/PageMemoryImplNoLoadTest.java
new file mode 100644
index 0000000..38baea8
--- /dev/null
+++ b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/PageMemoryImplNoLoadTest.java
@@ -0,0 +1,100 @@
+/*
+ * 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.cache.database.pagemem;
+
+import java.io.File;
+import java.nio.ByteBuffer;
+import org.apache.ignite.configuration.MemoryPolicyConfiguration;
+import org.apache.ignite.internal.mem.DirectMemoryProvider;
+import org.apache.ignite.internal.mem.file.MappedFileMemoryProvider;
+import org.apache.ignite.internal.pagemem.FullPageId;
+import org.apache.ignite.internal.pagemem.PageMemory;
+import org.apache.ignite.internal.pagemem.impl.PageMemoryNoLoadSelfTest;
+import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
+import org.apache.ignite.internal.processors.cache.database.CheckpointLockStateChecker;
+import org.apache.ignite.internal.processors.cache.database.MemoryMetricsImpl;
+import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryEx;
+import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryImpl;
+import org.apache.ignite.internal.util.lang.GridInClosure3X;
+import org.apache.ignite.internal.processors.cache.database.IgniteCacheDatabaseSharedManager;
+import org.apache.ignite.internal.util.typedef.CIX3;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.testframework.junits.GridTestKernalContext;
+
+/**
+ *
+ */
+public class PageMemoryImplNoLoadTest extends PageMemoryNoLoadSelfTest {
+    /**
+     * @return Page memory implementation.
+     */
+    @Override protected PageMemory memory() throws Exception {
+        File memDir = U.resolveWorkDirectory(U.defaultWorkDirectory(), "pagemem", false);
+
+        long[] sizes = new long[10];
+
+        for (int i = 0; i < sizes.length; i++)
+            sizes[i] = 5 * 1024 * 1024;
+
+        DirectMemoryProvider provider = new MappedFileMemoryProvider(log(), memDir);
+
+        GridCacheSharedContext<Object, Object> sharedCtx = new GridCacheSharedContext<>(
+            new GridTestKernalContext(log),
+            null,
+            null,
+            null,
+            new NoOpPageStoreManager(),
+            new NoOpWALManager(),
+            new IgniteCacheDatabaseSharedManager(),
+            null,
+            null,
+            null,
+            null,
+            null,
+            null,
+            null,
+            null
+        );
+
+        return new PageMemoryImpl(
+            provider,
+            sizes,
+            sharedCtx,
+            PAGE_SIZE,
+            new CIX3<FullPageId, ByteBuffer, Integer>() {
+                @Override public void applyx(FullPageId fullPageId, ByteBuffer byteBuffer, Integer tag) {
+                    assert false : "No evictions should happen during the test";
+                }
+            },
+            new GridInClosure3X<Long, FullPageId, PageMemoryEx>() {
+                @Override public void applyx(Long page, FullPageId fullId, PageMemoryEx pageMem) {
+                }
+            },
+            new CheckpointLockStateChecker() {
+                @Override public boolean checkpointLockIsHeldByThread() {
+                    return true;
+                }
+            },
+            new MemoryMetricsImpl(new MemoryPolicyConfiguration()));
+    }
+
+    /** {@inheritDoc} */
+    @Override public void testPageHandleDeallocation() throws Exception {
+        // No-op.
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/cd4d0400/modules/pds/src/test/java/org/apache/ignite/cache/database/standbycluster/GridChangeGlobalStateAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/standbycluster/GridChangeGlobalStateAbstractTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/standbycluster/GridChangeGlobalStateAbstractTest.java
deleted file mode 100644
index 62239ed..0000000
--- a/modules/pds/src/test/java/org/apache/ignite/cache/database/standbycluster/GridChangeGlobalStateAbstractTest.java
+++ /dev/null
@@ -1,366 +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.cache.database.standbycluster;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ThreadLocalRandom;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.configuration.MemoryConfiguration;
-import org.apache.ignite.configuration.MemoryPolicyConfiguration;
-import org.apache.ignite.configuration.PersistentStoreConfiguration;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-/**
- *
- */
-public abstract class GridChangeGlobalStateAbstractTest extends GridCommonAbstractTest {
-    /** Primary suffix. */
-    private static final String primarySuffix = "-primary";
-
-    /** BackUp suffix. */
-    private static final String backUpSuffix = "-backUp";
-
-    /** BackUp suffix. */
-    private static final String clientSuffix = "-client";
-
-    /** Primary ip finder. */
-    protected final TcpDiscoveryIpFinder primaryIpFinder = new TcpDiscoveryVmIpFinder(true);
-
-    /** Back up ip finder. */
-    protected final TcpDiscoveryIpFinder backUpIpFinder = new TcpDiscoveryVmIpFinder(true);
-
-    /** Consistent id count. */
-    private int consistentIdCnt;
-
-    /** Nodes. */
-    protected Map<String, Ignite> nodes = new ConcurrentHashMap<>();
-
-    /** {@inheritDoc} */
-    @Override protected void beforeTest() throws Exception {
-        super.beforeTest();
-
-        nodes.clear();
-
-        deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), testName(), true));
-
-        startPrimaryNodes(primaryNodes());
-
-        startPrimaryClientNodes(primaryClientNodes());
-
-        startBackUpNodes(backUpNodes());
-
-        startBackUpClientNodes(backUpClientNodes());
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTest() throws Exception {
-        super.afterTest();
-
-        stopAll(clientSuffix);
-
-        stopAll(primarySuffix);
-
-        stopAll(backUpSuffix);
-
-        nodes.clear();
-
-        deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), testName(), true));
-    }
-
-    /**
-     *
-     */
-    protected int primaryNodes() {
-        return 3;
-    }
-
-    /**
-     *
-     */
-    protected int primaryClientNodes() {
-        return 3;
-    }
-
-    /**
-     *
-     */
-    protected int backUpNodes() {
-        return 3;
-    }
-
-    /**
-     *
-     */
-    protected int backUpClientNodes() {
-        return 3;
-    }
-
-    /**
-     * @param idx idx.
-     */
-    protected Ignite primary(int idx) {
-        return nodes.get("node" + idx + primarySuffix);
-    }
-
-    /**
-     * @param idx idx.
-     */
-    protected Ignite primaryClient(int idx) {
-        return nodes.get("node" + idx + primarySuffix + clientSuffix);
-    }
-
-    /**
-     * @param idx idx.
-     */
-    protected Ignite backUp(int idx) {
-        return nodes.get("node" + idx + backUpSuffix);
-    }
-
-    /**
-     * @param idx idx.
-     */
-    protected Ignite backUpClient(int idx) {
-        return nodes.get("node" + idx + backUpSuffix + clientSuffix);
-    }
-
-    /**
-     * @param cnt Count.
-     */
-    protected void startPrimaryNodes(int cnt) throws Exception {
-        for (int i = 0; i < cnt; i++)
-            startPrimary(i);
-    }
-
-    /**
-     * @param idx Index.
-     */
-    protected void startPrimary(int idx) throws Exception {
-        String node = "node" + idx;
-
-        String name = node + primarySuffix;
-
-        IgniteConfiguration cfg = getConfiguration(name);
-        cfg.setConsistentId(node);
-        cfg.setActiveOnStart(true);
-        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(primaryIpFinder);
-
-        Ignite ig = startGrid(name, cfg);
-
-        nodes.put(name, ig);
-    }
-
-    /**
-     * @param cnt Count.
-     */
-    protected void startBackUpNodes(int cnt) throws Exception {
-        for (int i = 0; i < cnt; i++)
-            startBackUp(i);
-    }
-
-    /**
-     * @param idx Index.
-     */
-    protected void startBackUp(int idx) throws Exception {
-        String node = "node" + idx;
-
-        String name = node + backUpSuffix;
-
-        IgniteConfiguration cfg = getConfiguration(name);
-        cfg.setConsistentId(node);
-        cfg.setActiveOnStart(false);
-        ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(backUpIpFinder);
-
-        Ignite ig = startGrid(name, cfg);
-
-        nodes.put(name, ig);
-    }
-
-    /**
-     * @param cnt Count.
-     */
-    protected void startPrimaryClientNodes(int cnt) throws Exception {
-        for (int i = 0; i < cnt; i++) {
-            String node = "node" + i;
-
-            String name = node + primarySuffix + clientSuffix;
-
-            IgniteConfiguration cfg = getConfiguration(name);
-            cfg.setConsistentId(node);
-            cfg.setClientMode(true);
-            ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(primaryIpFinder);
-
-            Ignite ig = startGrid(name, cfg);
-
-            nodes.put(name, ig);
-        }
-    }
-
-    /**
-     * @param cnt Count.
-     */
-    protected void startBackUpClientNodes(int cnt) throws Exception {
-        for (int i = 0; i < cnt; i++) {
-            String node = "node" + i;
-
-            String name = node + backUpSuffix + clientSuffix;
-
-            IgniteConfiguration cfg = getConfiguration(name);
-            cfg.setConsistentId(node);
-            cfg.setActiveOnStart(false);
-            cfg.setClientMode(true);
-            ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(backUpIpFinder);
-
-            Ignite ig = startGrid(name, cfg);
-
-            nodes.put(name, ig);
-        }
-    }
-
-    /**
-     *
-     */
-    protected Iterable<Ignite> allBackUpNodes(){
-        List<Ignite> r = new ArrayList<>();
-
-        for (String name : this.nodes.keySet())
-            if (name.contains(backUpSuffix))
-                r.add(nodes.get(name));
-
-        return r;
-    }
-
-    /**
-     *
-     */
-    protected Ignite randomBackUp(boolean includeClient) {
-        int nodes = 0;
-
-        List<Ignite> igs = new ArrayList<>();
-
-        for (String name : this.nodes.keySet())
-            if (name.contains(backUpSuffix)){
-                if (includeClient)
-                   igs.add(this.nodes.get(name));
-                else {
-                    if (name.contains(clientSuffix))
-                        continue;
-
-                    igs.add(this.nodes.get(name));
-                }
-            }
-
-        int idx = ThreadLocalRandom.current().nextInt(0, igs.size());
-
-        return igs.get(idx);
-    }
-
-
-    /**
-     * @param i Idx.
-     */
-    protected void stopPrimary(int i) {
-        String name = "node" + i + primarySuffix;
-
-        nodes.get(name).close();
-
-        nodes.remove(name);
-    }
-
-    /**
-     *
-     */
-    protected void stopAllPrimary() {
-        stopAll(primarySuffix);
-    }
-
-    /**
-     *
-     */
-    protected void stopAllBackUp() {
-        stopAll(backUpSuffix);
-    }
-
-    /**
-     *
-     */
-    protected void stopAllClient() {
-        stopAll(clientSuffix);
-    }
-
-    /**
-     * @param suffix Suffix.
-     */
-    private void stopAll(String suffix) {
-        for (String name : nodes.keySet())
-            if (name.contains(suffix)) {
-                Ignite ig = nodes.get(name);
-
-                stopGrid(ig.name());
-
-                nodes.remove(name);
-            }
-    }
-
-    /**
-     * @param gridName Grid name.
-     */
-    @Override protected IgniteConfiguration getConfiguration(final String gridName) throws Exception {
-        final IgniteConfiguration cfg = super.getConfiguration(gridName);
-
-        PersistentStoreConfiguration pCfg = new PersistentStoreConfiguration();
-
-        pCfg.setPersistentStorePath(testName() + "/db");
-        pCfg.setWalArchivePath(testName() + "/db/wal/archive");
-        pCfg.setWalStorePath(testName() + "/db/wal");
-
-        cfg.setPersistentStoreConfiguration(pCfg);
-
-        final MemoryConfiguration memCfg = new MemoryConfiguration();
-
-        memCfg.setPageSize(1024);
-        memCfg.setConcurrencyLevel(64);
-
-        MemoryPolicyConfiguration memPlcCfg = new MemoryPolicyConfiguration();
-        memPlcCfg.setInitialSize(5 * 1024 * 1024);
-        memPlcCfg.setMaxSize(5 * 1024 * 1024);
-        memPlcCfg.setName("dfltMemPlc");
-
-        memCfg.setMemoryPolicies(memPlcCfg);
-        memCfg.setDefaultMemoryPolicyName("dfltMemPlc");
-
-        cfg.setMemoryConfiguration(memCfg);
-
-        return cfg;
-    }
-
-    /**
-     *
-     */
-    protected String testName() {
-        return getClass().getSimpleName();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/cd4d0400/modules/pds/src/test/java/org/apache/ignite/cache/database/standbycluster/GridChangeGlobalStateCacheTest.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/standbycluster/GridChangeGlobalStateCacheTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/standbycluster/GridChangeGlobalStateCacheTest.java
deleted file mode 100644
index 06ceeec..0000000
--- a/modules/pds/src/test/java/org/apache/ignite/cache/database/standbycluster/GridChangeGlobalStateCacheTest.java
+++ /dev/null
@@ -1,168 +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.cache.database.standbycluster;
-
-import javax.cache.configuration.Configuration;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.internal.IgniteEx;
-import org.apache.ignite.internal.processors.cache.GridCacheProcessor;
-import org.apache.ignite.internal.util.typedef.F;
-
-/**
- *
- */
-public class GridChangeGlobalStateCacheTest extends GridChangeGlobalStateAbstractTest {
-    /**
-     *
-     */
-    public void testCheckValueAfterActivation(){
-        String cacheName = "my-cache";
-
-        Ignite ig1P = primary(0);
-
-        Ignite ig1B = backUp(0);
-        Ignite ig2B = backUp(1);
-        Ignite ig3B = backUp(2);
-
-        IgniteCache<String, String> cacheP = ig1P.getOrCreateCache(cacheName);
-
-        cacheP.put("key","value");
-
-        stopAllPrimary();
-
-        ig1B.active(true);
-
-        IgniteCache<String, String> cache1B = ig1B.cache(cacheName);
-        IgniteCache<String, String> cache2B = ig2B.cache(cacheName);
-        IgniteCache<String, String> cache3B = ig3B.cache(cacheName);
-
-        assertTrue(cache1B != null);
-        assertTrue(cache2B != null);
-        assertTrue(cache3B != null);
-
-        assertEquals(cache1B.get("key"), "value");
-        assertEquals(cache2B.get("key"), "value");
-        assertEquals(cache3B.get("key"), "value");
-    }
-
-    /**
-     *
-     */
-    public void testMoreKeyValueAfterActivate() throws Exception {
-        String cacheName = "my-cache";
-
-        Ignite ig1P = primary(0);
-        Ignite ig2P = primary(1);
-        Ignite ig3P = primary(2);
-
-        Ignite ig1B = backUp(0);
-        Ignite ig2B = backUp(1);
-        Ignite ig3B = backUp(2);
-
-        CacheConfiguration<String, String> cacheCfg = new CacheConfiguration<>(cacheName);
-
-        IgniteCache<String, String> cache1P = ig1P.getOrCreateCache(cacheCfg);
-
-        for (int i = 0; i < 4_000; i++)
-            cache1P.put("key" + i, "value" + i);
-
-        IgniteCache<String, String> cache2P = ig2P.cache(cacheName);
-
-        for (int i = 4_000; i < 8_000; i++)
-            cache2P.put("key" + i, "value" + i);
-
-        IgniteCache<String, String> cache3P = ig3P.cache(cacheName);
-
-        for (int i = 8_000; i < 12_000; i++)
-            cache3P.put("key" + i, "value" + i);
-
-        stopAllPrimary();
-
-        ig1B.active(true);
-
-        IgniteCache<String, String> cache1B = ig1B.cache(cacheName);
-        IgniteCache<String, String> cache2B = ig2B.cache(cacheName);
-        IgniteCache<String, String> cache3B = ig3B.cache(cacheName);
-
-        assertTrue(cache1B != null);
-        assertTrue(cache2B != null);
-        assertTrue(cache3B != null);
-
-        for (int i = 0; i < 4_000; i++)
-            assertEquals("value" + i, cache1B.get("key" + i));
-
-        for (int i = 4_000; i < 8_000; i++)
-            assertEquals("value" + i, cache2B.get("key" + i));
-
-        for (int i = 8_000; i < 12_000; i++)
-            assertEquals("value" + i, cache3B.get("key" + i));
-    }
-
-    /**
-     * @throws Exception if fail.
-     */
-    public void testDeActivateAndActivateCacheValue() throws Exception {
-        String chName = "myCache";
-
-        Ignite ig1 = primary(0);
-        Ignite ig2 = primary(1);
-        Ignite ig3 = primary(2);
-
-        IgniteCache<String, String> cacheExp = ig1.getOrCreateCache(chName);
-
-        Configuration<String, String> cfgExp = cacheExp.getConfiguration(CacheConfiguration.class);
-
-        cacheExp.put("key", "value");
-
-        assertTrue(ig1.active());
-        assertTrue(ig2.active());
-        assertTrue(ig3.active());
-
-        ig2.active(false);
-
-        IgniteEx ex1 = (IgniteEx)ig1;
-        IgniteEx ex2 = (IgniteEx)ig2;
-        IgniteEx ex3 = (IgniteEx)ig3;
-
-        GridCacheProcessor cache1 = ex1.context().cache();
-        GridCacheProcessor cache2 = ex2.context().cache();
-        GridCacheProcessor cache3 = ex3.context().cache();
-
-        assertTrue(F.isEmpty(cache1.jcaches()));
-        assertTrue(F.isEmpty(cache2.jcaches()));
-        assertTrue(F.isEmpty(cache3.jcaches()));
-
-        assertTrue(!ig1.active());
-        assertTrue(!ig2.active());
-        assertTrue(!ig3.active());
-
-        ig3.active(true);
-
-        assertTrue(ig1.active());
-        assertTrue(ig2.active());
-        assertTrue(ig3.active());
-
-        IgniteCache<String, String> cacheAct = ig2.cache(chName);
-
-        Configuration<String, String> cfgAct = cacheAct.getConfiguration(CacheConfiguration.class);
-
-        assertEquals("value", cacheAct.get("key"));
-    }
-}


Mime
View raw message