ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject [05/47] ignite git commit: IGNITE-5267 - Moved ignite-ps module to ignite-core
Date Sun, 11 Jun 2017 20:03:31 GMT
http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/test/java/org/apache/ignite/cache/database/db/wal/IgniteWalRecoveryTest.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/db/wal/IgniteWalRecoveryTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/db/wal/IgniteWalRecoveryTest.java
deleted file mode 100644
index 4eb3d34..0000000
--- a/modules/pds/src/test/java/org/apache/ignite/cache/database/db/wal/IgniteWalRecoveryTest.java
+++ /dev/null
@@ -1,1288 +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.db.wal;
-
-import java.io.File;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ThreadLocalRandom;
-import java.util.concurrent.TimeUnit;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteCompute;
-import org.apache.ignite.IgniteException;
-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.SqlFieldsQuery;
-import org.apache.ignite.cache.query.annotations.QuerySqlField;
-import org.apache.ignite.cluster.ClusterNode;
-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.MemoryPolicyConfiguration;
-import org.apache.ignite.configuration.PersistentStoreConfiguration;
-import org.apache.ignite.configuration.WALMode;
-import org.apache.ignite.internal.IgniteEx;
-import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.IgniteInterruptedCheckedException;
-import org.apache.ignite.internal.pagemem.FullPageId;
-import org.apache.ignite.internal.pagemem.PageUtils;
-import org.apache.ignite.internal.pagemem.wal.WALIterator;
-import org.apache.ignite.internal.pagemem.wal.WALPointer;
-import org.apache.ignite.internal.pagemem.wal.record.MemoryRecoveryRecord;
-import org.apache.ignite.internal.pagemem.wal.record.PageSnapshot;
-import org.apache.ignite.internal.pagemem.wal.record.WALRecord;
-import org.apache.ignite.internal.pagemem.wal.record.delta.PageDeltaRecord;
-import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
-import org.apache.ignite.internal.processors.cache.database.GridCacheDatabaseSharedManager;
-import org.apache.ignite.internal.processors.cache.database.pagemem.PageMemoryEx;
-import org.apache.ignite.internal.processors.cache.database.tree.io.TrackingPageIO;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.PA;
-import org.apache.ignite.internal.util.typedef.PAX;
-import org.apache.ignite.internal.util.typedef.X;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteBiTuple;
-import org.apache.ignite.lang.IgniteCallable;
-import org.apache.ignite.lang.IgnitePredicate;
-import org.apache.ignite.lang.IgniteRunnable;
-import org.apache.ignite.resources.IgniteInstanceResource;
-import org.apache.ignite.testframework.GridTestUtils;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-import org.apache.ignite.testframework.junits.multijvm.IgniteProcessProxy;
-import org.junit.Assert;
-import sun.nio.ch.DirectBuffer;
-
-/**
- *
- */
-public class IgniteWalRecoveryTest extends GridCommonAbstractTest {
-    /** */
-    private static final String HAS_CACHE = "HAS_CACHE";
-
-    /** */
-    private static final int LARGE_ARR_SIZE = 1025;
-
-    /** */
-    private boolean fork;
-
-    /** */
-    private String cacheName;
-
-    /** */
-    private int walSegmentSize;
-
-    /** Logger only. */
-    private boolean logOnly;
-
-    /** {@inheritDoc} */
-    @Override protected boolean isMultiJvm() {
-        return fork;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(gridName);
-
-        CacheConfiguration<Integer, IndexedObject> ccfg = new CacheConfiguration<>(cacheName);
-
-        ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
-        ccfg.setRebalanceMode(CacheRebalanceMode.SYNC);
-        ccfg.setAffinity(new RendezvousAffinityFunction(false, 32));
-        ccfg.setNodeFilter(new RemoteNodeFilter());
-        ccfg.setIndexedTypes(Integer.class, IndexedObject.class);
-
-        cfg.setCacheConfiguration(ccfg);
-
-        MemoryConfiguration dbCfg = new MemoryConfiguration();
-
-        dbCfg.setPageSize(4 * 1024);
-
-        MemoryPolicyConfiguration memPlcCfg = new MemoryPolicyConfiguration();
-
-        memPlcCfg.setName("dfltMemPlc");
-        memPlcCfg.setInitialSize(1024 * 1024 * 1024);
-        memPlcCfg.setMaxSize(1024 * 1024 * 1024);
-
-        dbCfg.setMemoryPolicies(memPlcCfg);
-        dbCfg.setDefaultMemoryPolicyName("dfltMemPlc");
-
-        cfg.setMemoryConfiguration(dbCfg);
-
-        PersistentStoreConfiguration pCfg = new PersistentStoreConfiguration();
-
-        if (logOnly)
-            pCfg.setWalMode(WALMode.LOG_ONLY);
-
-        if (walSegmentSize != 0)
-            pCfg.setWalSegmentSize(walSegmentSize);
-
-        cfg.setPersistentStoreConfiguration(pCfg);
-
-        cfg.setMarshaller(null);
-
-        BinaryConfiguration binCfg = new BinaryConfiguration();
-
-        binCfg.setCompactFooter(false);
-
-        cfg.setBinaryConfiguration(binCfg);
-
-        if (!getTestIgniteInstanceName(0).equals(gridName))
-            cfg.setUserAttributes(F.asMap(HAS_CACHE, true));
-
-        return cfg;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void beforeTest() throws Exception {
-        stopAllGrids();
-
-        deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false));
-
-        cacheName = "partitioned";
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTest() throws Exception {
-        stopAllGrids();
-
-        logOnly = false;
-
-        deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false));
-    }
-
-    /**
-     * @throws Exception if failed.
-     */
-    public void testWalBig() throws Exception {
-        try {
-            IgniteEx ignite = startGrid(1);
-
-            IgniteCache<Object, Object> cache = ignite.cache("partitioned");
-
-            Random rnd = new Random();
-
-            Map<Integer, IndexedObject> map = new HashMap<>();
-
-            for (int i = 0; i < 10_000; i++) {
-                if (i % 1000 == 0)
-                    X.println(" >> " + i);
-
-                int k = rnd.nextInt(300_000);
-                IndexedObject v = new IndexedObject(rnd.nextInt(10_000));
-
-                cache.put(k, v);
-                map.put(k, v);
-            }
-
-            // Check.
-            for (Integer k : map.keySet())
-                assertEquals(map.get(k), cache.get(k));
-
-            stopGrid(1);
-
-            ignite = startGrid(1);
-
-            cache = ignite.cache("partitioned");
-
-            // Check.
-            for (Integer k : map.keySet())
-                assertEquals(map.get(k), cache.get(k));
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-
-    /**
-     * @throws Exception If fail.
-     */
-    public void testSwitchClassLoader() throws Exception {
-        try {
-            final IgniteEx igniteEx = startGrid(1);
-
-            // CustomDiscoveryMessage will trigger service tasks
-            startGrid(2);
-
-            IgniteCache<Integer, EnumVal> cache = igniteEx.cache("partitioned");
-
-            // Creates LoadCacheJobV2
-//            cache.loadCache(null);
-
-            final ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
-            final ClassLoader newCl = getExternalClassLoader();
-
-            Thread.currentThread().setContextClassLoader(newCl);
-
-            for (int i = 0; i < 10; i++)
-                cache.put(i, i % 2 == 0 ? EnumVal.VAL1 : EnumVal.VAL2);
-
-            for (int i = 0; i < 10; i++)
-                assert cache.containsKey(i);
-
-            // Invokes ClearTask with new class loader
-            cache.clear();
-
-            Thread.currentThread().setContextClassLoader(oldCl);
-
-            for (int i = 0; i < 10; i++)
-                cache.put(i, i % 2 == 0 ? EnumVal.VAL1 : EnumVal.VAL2);
-
-            for (int i = 0; i < 10; i++)
-                assert cache.containsKey(i);
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-
-    /**
-     * @throws Exception if failed.
-     */
-    public void testWalSimple() throws Exception {
-        try {
-            IgniteEx ignite = startGrid(1);
-
-            IgniteCache<Object, Object> cache = ignite.cache("partitioned");
-
-            info(" --> step1");
-
-            for (int i = 0; i < 10_000; i += 2) {
-//                X.println(" -> put: " + i);
-
-                cache.put(i, new IndexedObject(i));
-            }
-
-            info(" --> step2");
-
-            for (int i = 0; i < 10_000; i += 3)
-                cache.put(i, new IndexedObject(i * 2));
-
-            info(" --> step3");
-
-            for (int i = 0; i < 10_000; i += 7)
-                cache.put(i, new IndexedObject(i * 3));
-
-            info(" --> check1");
-
-            // Check.
-            for (int i = 0; i < 10_000; i++) {
-                IndexedObject o;
-
-                if (i % 7 == 0)
-                    o = new IndexedObject(i * 3);
-                else if (i % 3 == 0)
-                    o = new IndexedObject(i * 2);
-                else if (i % 2 == 0)
-                    o = new IndexedObject(i);
-                else
-                    o = null;
-
-                assertEquals(o, cache.get(i));
-            }
-
-            stopGrid(1);
-
-            ignite = startGrid(1);
-
-            cache = ignite.cache("partitioned");
-
-            info(" --> check2");
-
-            // Check.
-            for (int i = 0; i < 10_000; i++) {
-                IndexedObject o;
-
-                if (i % 7 == 0)
-                    o = new IndexedObject(i * 3);
-                else if (i % 3 == 0)
-                    o = new IndexedObject(i * 2);
-                else if (i % 2 == 0)
-                    o = new IndexedObject(i);
-                else
-                    o = null;
-
-                assertEquals(o, cache.get(i));
-            }
-
-            info(" --> ok");
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-
-    /**
-     * @throws Exception If fail.
-     */
-    public void testWalLargeValue() throws Exception {
-        try {
-            IgniteEx ignite = startGrid(1);
-
-            IgniteCache<Object, Object> cache = ignite.cache("partitioned");
-
-            for (int i = 0; i < 10_000; i++) {
-                final byte[] data = new byte[i];
-
-                Arrays.fill(data, (byte)i);
-
-                cache.put(i, data);
-
-                if (i % 1000 == 0)
-                    X.println(" ---> put: " + i);
-
-//                Assert.assertArrayEquals(data, (byte[])cache.get(i));
-            }
-
-//            info(" --> check1");
-//
-//            for (int i = 0; i < 25_000; i++) {
-//                final byte[] data = new byte[i];
-//
-//                Arrays.fill(data, (byte)i);
-//
-//                final byte[] loaded = (byte[]) cache.get(i);
-//
-//                Assert.assertArrayEquals(data, loaded);
-//            }
-
-            stopGrid(1);
-
-            ignite = startGrid(1);
-
-            cache = ignite.cache("partitioned");
-
-            info(" --> check2");
-
-            for (int i = 0; i < 10_000; i++) {
-                final byte[] data = new byte[i];
-
-                Arrays.fill(data, (byte)i);
-
-                final byte[] loaded = (byte[]) cache.get(i);
-
-                Assert.assertArrayEquals(data, loaded);
-
-                if (i % 1000 == 0)
-                    X.println(" ---> get: " + i);
-            }
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-
-    /**
-     * @throws Exception if failed.
-     */
-    public void testWalRolloverMultithreadedDefault() throws Exception {
-        logOnly = false;
-
-        checkWalRolloverMultithreaded();
-    }
-
-    /**
-     * @throws Exception if failed.
-     */
-    public void testWalRolloverMultithreadedLogOnly() throws Exception {
-        logOnly = true;
-
-        checkWalRolloverMultithreaded();
-    }
-
-    /**
-     * @throws Exception if failed.
-     */
-    public void testHugeCheckpointRecord() throws Exception {
-        try {
-            final IgniteEx ignite = startGrid(1);
-
-            for (int i = 0; i < 50; i++) {
-                CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>("cache-" + i);
-
-                // We can get 'too many open files' with default number of partitions.
-                ccfg.setAffinity(new RendezvousAffinityFunction(false, 128));
-
-                IgniteCache<Object, Object> cache = ignite.getOrCreateCache(ccfg);
-
-                cache.put(i, i);
-            }
-
-            final long endTime = System.currentTimeMillis() + 30_000;
-
-            IgniteInternalFuture<Long> fut = GridTestUtils.runMultiThreadedAsync(new Callable<Void>() {
-                @Override public Void call() throws Exception {
-                    Random rnd = ThreadLocalRandom.current();
-
-                    while (U.currentTimeMillis() < endTime) {
-                        IgniteCache<Object, Object> cache = ignite.cache("cache-" + rnd.nextInt(50));
-
-                        cache.put(rnd.nextInt(50_000), rnd.nextInt());
-                    }
-
-                    return null;
-                }
-            }, 16, "put-thread");
-
-            while (System.currentTimeMillis() < endTime) {
-                ignite.context().cache().context().database().wakeupForCheckpoint("test").get();
-
-                U.sleep(500);
-            }
-
-            fut.get();
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-
-    /**
-     * @throws Exception if failed.
-     */
-    private void checkWalRolloverMultithreaded() throws Exception {
-        walSegmentSize = 2 * 1024 * 1024;
-
-        final long endTime = System.currentTimeMillis() + 2 * 60 * 1000;
-
-        try {
-            IgniteEx ignite = startGrid(1);
-
-            final IgniteCache<Object, Object> cache = ignite.cache("partitioned");
-
-            GridTestUtils.runMultiThreaded(new Callable<Void>() {
-                @Override public Void call() throws Exception {
-                    Random rnd = ThreadLocalRandom.current();
-
-                    while (U.currentTimeMillis() < endTime)
-                        cache.put(rnd.nextInt(50_000), rnd.nextInt());
-
-                    return null;
-                }
-            }, 16, "put-thread");
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-
-    /**
-     * @throws Exception If fail.
-     */
-    public void testWalRenameDirSimple() throws Exception {
-        try {
-            IgniteEx ignite = startGrid(1);
-
-            IgniteCache<Object, Object> cache = ignite.cache("partitioned");
-
-            for (int i = 0; i < 100; i++)
-                cache.put(i, new IndexedObject(i));
-
-            stopGrid(1);
-
-            final File cacheDir = cacheDir("partitioned", ignite.context().discovery().consistentId().toString());
-
-            final boolean renamed = cacheDir.renameTo(new File(cacheDir.getParent(), "cache-partitioned0"));
-
-            assert renamed;
-
-            cacheName = "partitioned0";
-
-            ignite = startGrid(1);
-
-            cache = ignite.cache(cacheName);
-
-            for (int i = 0; i < 100; i++)
-                assertEquals(new IndexedObject(i), cache.get(i));
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-
-    /**
-     * @param cacheName Cache name.
-     * @param consId Consistent ID.
-     * @return Cache dir.
-     * @throws IgniteCheckedException If fail.
-     */
-    private File cacheDir(final String cacheName, String consId) throws IgniteCheckedException {
-        consId = consId.replaceAll("[\\.:]", "_");
-
-        final File dbDir = U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false);
-
-        assert dbDir.exists();
-
-        final File consIdDir = new File(dbDir.getAbsolutePath(), consId);
-
-        assert consIdDir.exists();
-
-        final File cacheDir = new File(consIdDir.getAbsolutePath(), "cache-" + cacheName);
-
-        assert cacheDir.exists();
-
-        return cacheDir;
-    }
-
-    /**
-     * @throws Exception if failed.
-     */
-    public void testRecoveryNoCheckpoint() throws Exception {
-        try {
-            IgniteEx ctrlGrid = startGrid(0);
-
-            fork = true;
-
-            IgniteEx cacheGrid = startGrid(1);
-
-            ctrlGrid.compute(ctrlGrid.cluster().forRemotes()).run(new LoadRunnable(false));
-
-            info("Killing remote process...");
-
-            ((IgniteProcessProxy)cacheGrid).kill();
-
-            final IgniteEx g0 = ctrlGrid;
-
-            GridTestUtils.waitForCondition(new PA() {
-                /** {@inheritDoc} */
-                @Override public boolean apply() {
-                    return g0.cluster().nodes().size() == 1;
-                }
-            }, getTestTimeout());
-
-            fork = false;
-
-            // Now start the grid and verify that updates were restored from WAL.
-            cacheGrid = startGrid(1);
-
-            IgniteCache<Object, Object> cache = cacheGrid.cache("partitioned");
-
-            for (int i = 0; i < 10_000; i++)
-                assertEquals(new IndexedObject(i), cache.get(i));
-
-            List<List<?>> res = cache.query(new SqlFieldsQuery("select count(iVal) from IndexedObject")).getAll();
-
-            assertEquals(1, res.size());
-            assertEquals(10_000L, res.get(0).get(0));
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-
-    /**
-     * @throws Exception if failed.
-     */
-    public void testRecoveryLargeNoCheckpoint() throws Exception {
-        try {
-            IgniteEx ctrlGrid = startGrid(0);
-
-            fork = true;
-
-            IgniteEx cacheGrid = startGrid(1);
-
-            ctrlGrid.compute(ctrlGrid.cluster().forRemotes()).run(new LargeLoadRunnable(false));
-
-            info("Killing remote process...");
-
-            ((IgniteProcessProxy)cacheGrid).kill();
-
-            final IgniteEx g0 = ctrlGrid;
-
-            GridTestUtils.waitForCondition(new PA() {
-                /** {@inheritDoc} */
-                @Override public boolean apply() {
-                    return g0.cluster().nodes().size() == 1;
-                }
-            }, getTestTimeout());
-
-            fork = false;
-
-            // Now start the grid and verify that updates were restored from WAL.
-            cacheGrid = startGrid(1);
-
-            IgniteCache<Object, Object> cache = cacheGrid.cache("partitioned");
-
-            for (int i = 0; i < 1000; i++) {
-                final long[] data = new long[LARGE_ARR_SIZE];
-
-                Arrays.fill(data, i);
-
-                final long[] loaded = (long[]) cache.get(i);
-
-                Assert.assertArrayEquals(data, loaded);
-            }
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override protected long getTestTimeout() {
-        return TimeUnit.MINUTES.toMillis(20);
-    }
-
-    /**
-     * @throws Exception if failed.
-     */
-    public void testRandomCrash() throws Exception {
-        try {
-            IgniteEx ctrlGrid = startGrid(0);
-
-            fork = true;
-
-            IgniteEx cacheGrid = startGrid(1);
-
-            IgniteCompute rmt = ctrlGrid.compute(ctrlGrid.cluster().forRemotes());
-
-            rmt.run(new LoadRunnable(false));
-
-            info(">>> Finished cache population.");
-
-            rmt.run(new AsyncLoadRunnable());
-
-            Thread.sleep(20_000);
-
-            info(">>> Killing remote process...");
-
-            ((IgniteProcessProxy)cacheGrid).kill();
-
-            startGrid(1);
-
-            Boolean res = rmt.call(new VerifyCallable());
-
-            assertTrue(res);
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-
-    /**
-     * @throws Exception if failed.
-     */
-    public void testLargeRandomCrash() throws Exception {
-        try {
-            IgniteEx ctrlGrid = startGrid(0);
-
-            fork = true;
-
-            IgniteEx cacheGrid = startGrid(1);
-
-            IgniteCompute rmt = ctrlGrid.compute(ctrlGrid.cluster().forRemotes());
-
-            rmt.run(new LargeLoadRunnable(false));
-
-            info(">>> Finished cache population.");
-
-            rmt.run(new AsyncLargeLoadRunnable());
-
-            Thread.sleep(20_000);
-
-            info(">>> Killing remote process...");
-
-            ((IgniteProcessProxy)cacheGrid).kill();
-
-            startGrid(1);
-
-            Boolean res = rmt.call(new VerifyLargeCallable());
-
-            assertTrue(res);
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-
-    /**
-     *
-     */
-    private static class RemoteNodeFilter implements IgnitePredicate<ClusterNode> {
-        /** {@inheritDoc} */
-        @Override public boolean apply(ClusterNode clusterNode) {
-            return clusterNode.attribute(HAS_CACHE) != null;
-        }
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testDestroyCache() throws Exception {
-        try {
-            IgniteEx ignite = startGrid(1);
-
-            IgniteCache<Object, Object> cache = ignite.getOrCreateCache("test");
-
-            cache.put(1, new IndexedObject(1));
-
-            ignite.destroyCache("test");
-
-            cache = ignite.getOrCreateCache("test");
-
-            // No entry available after cache destroy.
-            assertNull(cache.get(1));
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-
-    /**
-     * @throws Exception If fail.
-     */
-    public void testEvictPartition() throws Exception {
-        try {
-            Ignite ignite1 = startGrid("node1");
-
-            IgniteCache<Object, Object> cache1 = ignite1.cache(cacheName);
-
-            for (int i = 0; i < 100; i++)
-                cache1.put(i, new IndexedObject(i));
-
-            Ignite ignite2 = startGrid("node2");
-
-            IgniteCache<Object, Object> cache2 = ignite2.cache(cacheName);
-
-            for (int i = 0; i < 100; i++) {
-                assertEquals(new IndexedObject(i), cache1.get(i));
-                assertEquals(new IndexedObject(i), cache2.get(i));
-            }
-
-            ignite1.close();
-            ignite2.close();
-
-            ignite1 = startGrid("node1");
-            ignite2 = startGrid("node2");
-
-            cache1 = ignite1.cache(cacheName);
-            cache2 = ignite2.cache(cacheName);
-
-            for (int i = 0; i < 100; i++) {
-                assertEquals(new IndexedObject(i), cache1.get(i));
-                assertEquals(new IndexedObject(i), cache2.get(i));
-            }
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-
-    /**
-     * @throws Exception if failed.
-     */
-    public void testApplyDeltaRecords() throws Exception {
-        try {
-            IgniteEx ignite0 = (IgniteEx)startGrid("node0");
-
-            IgniteCache<Object, Object> cache0 = ignite0.cache(cacheName);
-
-            for (int i = 0; i < 1000; i++)
-                cache0.put(i, new IndexedObject(i));
-
-            GridCacheSharedContext<Object, Object> sharedCtx = ignite0.context().cache().context();
-
-            GridCacheDatabaseSharedManager db = (GridCacheDatabaseSharedManager)sharedCtx.database();
-
-            db.waitForCheckpoint("test");
-            db.enableCheckpoints(false).get();
-
-            // Log something to know where to start.
-            WALPointer ptr = sharedCtx.wal().log(new MemoryRecoveryRecord(U.currentTimeMillis()));
-
-            info("Replay marker: " + ptr);
-
-            for (int i = 1000; i < 5000; i++)
-                cache0.put(i, new IndexedObject(i));
-
-            info("Done puts...");
-
-            for (int i = 2_000; i < 3_000; i++)
-                cache0.remove(i);
-
-            info("Done removes...");
-
-            for (int i = 5000; i < 6000; i++)
-                cache0.put(i, new IndexedObject(i));
-
-            info("Done puts...");
-
-            Map<FullPageId, byte[]> rolledPages = new HashMap<>();
-
-            int pageSize = sharedCtx.database().pageSize();
-
-            ByteBuffer buf1 = ByteBuffer.allocateDirect(pageSize);
-
-            // Now check that deltas can be correctly applied.
-            try (WALIterator it = sharedCtx.wal().replay(ptr)) {
-                while (it.hasNext()) {
-                    IgniteBiTuple<WALPointer, WALRecord> tup = it.next();
-
-                    WALRecord rec = tup.get2();
-
-                    if (rec instanceof PageSnapshot) {
-                        PageSnapshot page = (PageSnapshot)rec;
-
-                        rolledPages.put(page.fullPageId(), page.pageData());
-                    }
-                    else if (rec instanceof PageDeltaRecord) {
-                        PageDeltaRecord delta = (PageDeltaRecord)rec;
-
-                        FullPageId fullId = new FullPageId(delta.pageId(), delta.cacheId());
-
-                        byte[] pageData = rolledPages.get(fullId);
-
-                        if (pageData == null) {
-                            pageData = new byte[pageSize];
-
-                            rolledPages.put(fullId, pageData);
-                        }
-
-                        assertNotNull("Missing page snapshot [page=" + fullId + ", delta=" + delta + ']', pageData);
-
-                        buf1.order(ByteOrder.nativeOrder());
-
-                        buf1.position(0);
-                        buf1.put(pageData);
-                        buf1.position(0);
-
-                        delta.applyDelta(sharedCtx
-                                .database()
-                                .memoryPolicy(null)
-                                .pageMemory(),
-
-                                ((DirectBuffer)buf1).address());
-
-                        buf1.position(0);
-
-                        buf1.get(pageData);
-                    }
-                }
-            }
-
-            info("Done apply...");
-
-            PageMemoryEx pageMem = (PageMemoryEx)db.memoryPolicy(null).pageMemory();
-
-            for (Map.Entry<FullPageId, byte[]> entry : rolledPages.entrySet()) {
-                FullPageId fullId = entry.getKey();
-
-                ignite0.context().cache().context().database().checkpointReadLock();
-
-                try {
-                    long page = pageMem.acquirePage(fullId.cacheId(), fullId.pageId(), true);
-
-                    try {
-                        long buf = pageMem.writeLock(fullId.cacheId(), fullId.pageId(), page, true);
-
-                        try {
-                            byte[] data = entry.getValue();
-
-                            for (int i = 0; i < data.length; i++) {
-                                if (fullId.pageId() == TrackingPageIO.VERSIONS.latest().trackingPageFor(fullId.pageId(), db.pageSize()))
-                                    continue; // Skip tracking pages.
-
-                                assertEquals("page=" + fullId + ", pos=" + i, PageUtils.getByte(buf, i), data[i]);
-                            }
-                        }
-                        finally {
-                            pageMem.writeUnlock(fullId.cacheId(), fullId.pageId(), page, null, false, true);
-                        }
-                    }
-                    finally {
-                        pageMem.releasePage(fullId.cacheId(), fullId.pageId(), page);
-                    }
-                }
-                finally {
-                    ignite0.context().cache().context().database().checkpointReadUnlock();
-                }
-            }
-
-            ignite0.close();
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-
-    /**
-     *
-     */
-    private static class LoadRunnable implements IgniteRunnable {
-        /** */
-        @IgniteInstanceResource
-        private Ignite ignite;
-
-        /** */
-        private boolean disableCheckpoints;
-
-        /**
-         * @param disableCheckpoints Disable checkpoints flag.
-         */
-        private LoadRunnable(boolean disableCheckpoints) {
-            this.disableCheckpoints = disableCheckpoints;
-        }
-
-        /** {@inheritDoc} */
-        @Override public void run() {
-            ignite.log().info("Started load.");
-
-            if (disableCheckpoints) {
-                GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager)((IgniteEx)ignite).context()
-                    .cache().context().database();
-
-                try {
-                    dbMgr.enableCheckpoints(false).get();
-                }
-                catch (IgniteCheckedException e) {
-                    throw new IgniteException(e);
-                }
-            }
-
-            try {
-                boolean successfulWaiting = GridTestUtils.waitForCondition(new PAX() {
-                    @Override public boolean applyx() {
-                        return ignite.cache("partitioned") != null;
-                    }
-                }, 10_000);
-
-                assertTrue(successfulWaiting);
-            }
-            catch (IgniteInterruptedCheckedException e) {
-                throw new RuntimeException(e);
-            }
-
-            IgniteCache<Object, Object> cache = ignite.cache("partitioned");
-
-            for (int i = 0; i < 10_000; i++)
-                cache.put(i, new IndexedObject(i));
-
-            ignite.log().info("Finished load.");
-        }
-    }
-
-    /**
-     *
-     */
-    private static class AsyncLoadRunnable implements IgniteRunnable {
-        /** */
-        @IgniteInstanceResource
-        private Ignite ignite;
-
-        /** {@inheritDoc} */
-        @Override public void run() {
-            try {
-                boolean successfulWaiting = GridTestUtils.waitForCondition(new PAX() {
-                    @Override public boolean applyx() {
-                        return ignite.cache("partitioned") != null;
-                    }
-                }, 10_000);
-
-                assertTrue(successfulWaiting);
-            }
-            catch (IgniteInterruptedCheckedException e) {
-                throw new RuntimeException(e);
-            }
-
-            ignite.log().info(">>>>>>> Started load.");
-
-            for (int i = 0; i < 4; i++) {
-                ignite.scheduler().callLocal(new Callable<Object>() {
-                    @Override public Object call() throws Exception {
-                        IgniteCache<Object, Object> cache = ignite.cache("partitioned");
-
-                        ThreadLocalRandom rnd = ThreadLocalRandom.current();
-
-                        int cnt = 0;
-
-                        while (!Thread.currentThread().isInterrupted()) {
-                            cache.put(rnd.nextInt(10_000), new IndexedObject(rnd.nextInt()));
-
-                            cnt++;
-
-                            if (cnt > 0 && cnt % 1_000 == 0)
-                                ignite.log().info(">>>> Updated: " + cnt);
-                        }
-
-                        return null;
-                    }
-                });
-            }
-        }
-    }
-
-    /**
-     *
-     */
-    private static class VerifyCallable implements IgniteCallable<Boolean> {
-        /** */
-        @IgniteInstanceResource
-        private Ignite ignite;
-
-        /** {@inheritDoc} */
-        @Override public Boolean call() throws Exception {
-            try {
-                boolean successfulWaiting = GridTestUtils.waitForCondition(new PAX() {
-                    @Override public boolean applyx() {
-                        return ignite.cache("partitioned") != null;
-                    }
-                }, 10_000);
-
-                assertTrue(successfulWaiting);
-            }
-            catch (IgniteInterruptedCheckedException e) {
-                throw new RuntimeException(e);
-            }
-
-            IgniteCache<Object, Object> cache = ignite.cache("partitioned");
-
-            for (int i = 0; i < 10_000; i++) {
-                Object val = cache.get(i);
-
-                if (val == null) {
-                    ignite.log().warning("Failed to find a value for key: " + i);
-
-                    return false;
-                }
-            }
-
-            return true;
-        }
-    }
-
-    /**
-     *
-     */
-    private static class LargeLoadRunnable implements IgniteRunnable {
-        /** */
-        @IgniteInstanceResource
-        private Ignite ignite;
-
-        /** */
-        private boolean disableCheckpoints;
-
-        /**
-         * @param disableCheckpoints Disable checkpoints flag.
-         */
-        private LargeLoadRunnable(boolean disableCheckpoints) {
-            this.disableCheckpoints = disableCheckpoints;
-        }
-
-        /** {@inheritDoc} */
-        @Override public void run() {
-            try {
-                boolean successfulWaiting = GridTestUtils.waitForCondition(new PAX() {
-                    @Override public boolean applyx() {
-                        return ignite.cache("partitioned") != null;
-                    }
-                }, 10_000);
-
-                assertTrue(successfulWaiting);
-            }
-            catch (IgniteInterruptedCheckedException e) {
-                throw new RuntimeException(e);
-            }
-
-            ignite.log().info("Started load.");
-
-            if (disableCheckpoints) {
-                GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager)((IgniteEx)ignite).context()
-                    .cache().context().database();
-
-                dbMgr.enableCheckpoints(false);
-            }
-
-            IgniteCache<Object, Object> cache = ignite.cache("partitioned");
-
-            for (int i = 0; i < 1000; i++) {
-                final long[] data = new long[LARGE_ARR_SIZE];
-
-                Arrays.fill(data, i);
-
-                cache.put(i, data);
-            }
-
-            ignite.log().info("Finished load.");
-        }
-    }
-
-    /**
-     *
-     */
-    private static class AsyncLargeLoadRunnable implements IgniteRunnable {
-        /** */
-        @IgniteInstanceResource
-        private Ignite ignite;
-
-        /** {@inheritDoc} */
-        @Override public void run() {
-            try {
-                boolean successfulWaiting = GridTestUtils.waitForCondition(new PAX() {
-                    @Override public boolean applyx() {
-                        return ignite.cache("partitioned") != null;
-                    }
-                }, 10_000);
-
-                assertTrue(successfulWaiting);
-            }
-            catch (IgniteInterruptedCheckedException e) {
-                throw new RuntimeException(e);
-            }
-
-            ignite.log().info(">>>>>>> Started load.");
-
-            for (int i = 0; i < 1; i++) {
-                ignite.scheduler().callLocal(new Callable<Object>() {
-                    @Override public Object call() throws Exception {
-                        IgniteCache<Object, Object> cache = ignite.cache("partitioned");
-
-                        ThreadLocalRandom rnd = ThreadLocalRandom.current();
-
-                        int cnt = 0;
-
-                        while (!Thread.currentThread().isInterrupted()) {
-                            final long[] data = new long[LARGE_ARR_SIZE];
-
-                            final int key = rnd.nextInt(1000);
-
-                            Arrays.fill(data, key);
-
-//                            System.out.println("> " + key);
-
-                            cache.put(key, data);
-
-                            cnt++;
-
-                            if (cnt > 0 && cnt % 1_000 == 0)
-                                ignite.log().info(">>>> Updated: " + cnt);
-                        }
-
-                        return null;
-                    }
-                });
-            }
-        }
-    }
-
-    /**
-     *
-     */
-    private static class VerifyLargeCallable implements IgniteCallable<Boolean> {
-        /** */
-        @IgniteInstanceResource
-        private Ignite ignite;
-
-        /** {@inheritDoc} */
-        @Override public Boolean call() throws Exception {
-            try {
-                boolean successfulWaiting = GridTestUtils.waitForCondition(new PAX() {
-                    @Override public boolean applyx() {
-                        return ignite.cache("partitioned") != null;
-                    }
-                }, 10_000);
-
-                assertTrue(successfulWaiting);
-            }
-            catch (IgniteInterruptedCheckedException e) {
-                throw new RuntimeException(e);
-            }
-
-            IgniteCache<Object, Object> cache = ignite.cache("partitioned");
-
-            for (int i = 0; i < 1000; i++) {
-                final long[] data = new long[LARGE_ARR_SIZE];
-
-                Arrays.fill(data, i);
-
-                final Object val = cache.get(i);
-
-                if (val == null) {
-                    ignite.log().warning("Failed to find a value for key: " + i);
-
-                    return false;
-                }
-            }
-
-            return true;
-        }
-    }
-
-
-    /**
-     *
-     */
-    private static class IndexedObject {
-        /** */
-        @QuerySqlField(index = true)
-        private int iVal;
-
-        /**
-         * @param iVal Integer value.
-         */
-        private IndexedObject(int iVal) {
-            this.iVal = iVal;
-        }
-
-        /** {@inheritDoc} */
-        @Override public boolean equals(Object o) {
-            if (this == o)
-                return true;
-
-            if (!(o instanceof IndexedObject))
-                return false;
-
-            IndexedObject that = (IndexedObject)o;
-
-            return iVal == that.iVal;
-        }
-
-        /** {@inheritDoc} */
-        @Override public int hashCode() {
-            return iVal;
-        }
-
-        /** {@inheritDoc} */
-        @Override public String toString() {
-            return S.toString(IndexedObject.class, this);
-        }
-    }
-
-    /**
-     *
-     */
-    private enum EnumVal {
-        /** */
-        VAL1,
-
-        /** */
-        VAL2,
-
-        /** */
-        VAL3
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/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
deleted file mode 100644
index 30a7f9e..0000000
--- a/modules/pds/src/test/java/org/apache/ignite/cache/database/db/wal/WalRecoveryTxLogicalRecordsTest.java
+++ /dev/null
@@ -1,951 +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.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/6bf5ce46/modules/pds/src/test/java/org/apache/ignite/cache/database/db/wal/crc/IgniteDataIntegrityTests.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/db/wal/crc/IgniteDataIntegrityTests.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/db/wal/crc/IgniteDataIntegrityTests.java
deleted file mode 100644
index c40a4ed..0000000
--- a/modules/pds/src/test/java/org/apache/ignite/cache/database/db/wal/crc/IgniteDataIntegrityTests.java
+++ /dev/null
@@ -1,137 +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.db.wal.crc;
-
-import junit.framework.TestCase;
-import java.io.EOFException;
-import java.io.File;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.nio.ByteBuffer;
-import java.util.concurrent.ThreadLocalRandom;
-import org.apache.ignite.internal.processors.cache.database.wal.FileInput;
-import org.apache.ignite.internal.processors.cache.database.wal.crc.IgniteDataIntegrityViolationException;
-import org.apache.ignite.internal.processors.cache.database.wal.crc.PureJavaCrc32;
-
-/**
- *
- */
-public class IgniteDataIntegrityTests extends TestCase {
-    /** File input. */
-    private FileInput fileInput;
-
-    /** Random access file. */
-    private RandomAccessFile randomAccessFile;
-
-    /** {@inheritDoc} */
-    @Override protected void setUp() throws Exception {
-        super.setUp();
-
-        File file = File.createTempFile("integrity", "dat");
-        file.deleteOnExit();
-
-        randomAccessFile = new RandomAccessFile(file, "rw");
-
-        fileInput = new FileInput(randomAccessFile.getChannel(), ByteBuffer.allocate(1024));
-
-        PureJavaCrc32 pureJavaCrc32 = new PureJavaCrc32();
-
-        ByteBuffer buf = ByteBuffer.allocate(1024);
-        ThreadLocalRandom curr = ThreadLocalRandom.current();
-
-        for (int i = 0; i < 1024; i+=16) {
-            buf.putInt(curr.nextInt());
-            buf.putInt(curr.nextInt());
-            buf.putInt(curr.nextInt());
-            buf.position(i);
-            buf.putInt(PureJavaCrc32.calcCrc32(buf, 12));
-        }
-
-        randomAccessFile.write(buf.array());
-        randomAccessFile.getFD().sync();
-    }
-
-    /**
-     *
-     */
-    public void testSuccessfulPath() throws Exception {
-        checkIntegrity();
-    }
-
-    /**
-     *
-     */
-    public void testIntegrityViolationChecking() throws Exception {
-        toggleOneRandomBit(0, 1024 - 16);
-
-        try {
-            checkIntegrity();
-
-            fail();
-        } catch (IgniteDataIntegrityViolationException ex) {
-            //success
-        }
-    }
-
-    /**
-     *
-     */
-    public void testSkipingLastCorruptedEntry() throws Exception {
-        toggleOneRandomBit(1024 - 16, 1024);
-
-        try {
-            checkIntegrity();
-
-            fail();
-        } catch (EOFException ex) {
-            //success
-        }
-    }
-
-    /**
-     * @param rangeFrom Range from.
-     * @param rangeTo Range to.
-     */
-    private void toggleOneRandomBit(int rangeFrom, int rangeTo) throws IOException {
-        int pos = ThreadLocalRandom.current().nextInt(rangeFrom, rangeTo);
-        randomAccessFile.seek(pos);
-
-        byte b = randomAccessFile.readByte();
-
-        b ^=  (1 << 3);
-
-        randomAccessFile.seek(pos);
-        randomAccessFile.writeByte(b);
-        randomAccessFile.getFD().sync();
-    }
-
-    /**
-     *
-     */
-    private void checkIntegrity() throws Exception {
-        randomAccessFile.seek(0);
-
-        for (int i = 0; i < 1024 / 16; i++) {
-            try(FileInput.Crc32CheckingFileInput in = fileInput.startRead(false)) {
-                in.readInt();
-                in.readInt();
-                in.readInt();
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/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
deleted file mode 100644
index a35903c..0000000
--- a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/BPlusTreePageMemoryImplTest.java
+++ /dev/null
@@ -1,98 +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.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/6bf5ce46/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
deleted file mode 100644
index 5c4502c..0000000
--- a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/BPlusTreeReuseListPageMemoryImplTest.java
+++ /dev/null
@@ -1,99 +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.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();
-    }
-}


Mime
View raw message