You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2017/06/11 20:03:32 UTC
[06/47] ignite git commit: IGNITE-5267 - Moved ignite-ps module to
ignite-core
http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/test/java/org/apache/ignite/cache/database/db/file/IgnitePdsNoActualWalHistoryTest.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/db/file/IgnitePdsNoActualWalHistoryTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/db/file/IgnitePdsNoActualWalHistoryTest.java
deleted file mode 100644
index 5a9da83..0000000
--- a/modules/pds/src/test/java/org/apache/ignite/cache/database/db/file/IgnitePdsNoActualWalHistoryTest.java
+++ /dev/null
@@ -1,215 +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.file;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Random;
-import org.apache.ignite.IgniteCache;
-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.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.configuration.WALMode;
-import org.apache.ignite.internal.IgniteEx;
-import org.apache.ignite.internal.processors.cache.database.GridCacheDatabaseSharedManager;
-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.testframework.junits.common.GridCommonAbstractTest;
-
-/**
- *
- */
-public class IgnitePdsNoActualWalHistoryTest extends GridCommonAbstractTest {
- /** Cache name. */
- private static final String CACHE_NAME = "cache";
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(gridName);
-
- CacheConfiguration<Integer, IndexedObject> ccfg = new CacheConfiguration<>(CACHE_NAME);
-
- ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
- ccfg.setRebalanceMode(CacheRebalanceMode.SYNC);
- ccfg.setAffinity(new RendezvousAffinityFunction(false, 32));
-
- cfg.setCacheConfiguration(ccfg);
-
- MemoryConfiguration dbCfg = new MemoryConfiguration();
-
- dbCfg.setPageSize(4 * 1024);
-
- cfg.setMemoryConfiguration(dbCfg);
-
- cfg.setPersistentStoreConfiguration(
- new PersistentStoreConfiguration()
- .setWalSegmentSize(4 * 1024 * 1024)
- .setWalHistorySize(2)
- .setWalSegments(10)
- .setWalMode(WALMode.LOG_ONLY)
- );
-
- cfg.setMarshaller(null);
-
- BinaryConfiguration binCfg = new BinaryConfiguration();
-
- binCfg.setCompactFooter(false);
-
- cfg.setBinaryConfiguration(binCfg);
-
- return cfg;
- }
-
- /** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- stopAllGrids();
-
- deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false));
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- stopAllGrids();
-
- 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(CACHE_NAME);
-
- Random rnd = new Random();
-
- Map<Integer, IndexedObject> map = new HashMap<>();
-
- for (int i = 0; i < 40_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);
- }
-
- GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager)ignite.context().cache().context()
- .database();
-
- // Create many checkpoints to clean up the history.
- dbMgr.wakeupForCheckpoint("test").get();
- dbMgr.wakeupForCheckpoint("test").get();
- dbMgr.wakeupForCheckpoint("test").get();
- dbMgr.wakeupForCheckpoint("test").get();
- dbMgr.wakeupForCheckpoint("test").get();
- dbMgr.wakeupForCheckpoint("test").get();
- dbMgr.wakeupForCheckpoint("test").get();
-
- dbMgr.enableCheckpoints(false).get();
-
- for (int i = 0; i < 50; i++) {
- int k = rnd.nextInt(300_000);
- IndexedObject v = new IndexedObject(rnd.nextInt(10_000));
-
- cache.put(k, v);
- map.put(k, v);
- }
-
- stopGrid(1);
-
- ignite = startGrid(1);
-
- cache = ignite.cache(CACHE_NAME);
-
- // Check.
- for (Integer k : map.keySet())
- assertEquals(map.get(k), cache.get(k));
- }
- finally {
- stopAllGrids();
- }
- }
-
- /**
- *
- */
- private static class IndexedObject {
- /** */
- @QuerySqlField(index = true)
- private int iVal;
-
- /** */
- private byte[] payload = new byte[1024];
-
- /**
- * @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/file/ignitePdsCheckpointSimulationTest.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/db/file/ignitePdsCheckpointSimulationTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/db/file/ignitePdsCheckpointSimulationTest.java
deleted file mode 100644
index b30162d..0000000
--- a/modules/pds/src/test/java/org/apache/ignite/cache/database/db/file/ignitePdsCheckpointSimulationTest.java
+++ /dev/null
@@ -1,1000 +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.file;
-
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.ThreadLocalRandom;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-import java.nio.ByteOrder;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.cache.CacheRebalanceMode;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.MemoryConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-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.pagemem.FullPageId;
-import org.apache.ignite.internal.pagemem.PageIdAllocator;
-import org.apache.ignite.internal.pagemem.PageMemory;
-import org.apache.ignite.internal.pagemem.PageUtils;
-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.pagemem.PageMemoryImpl;
-import org.apache.ignite.internal.processors.cache.database.tree.io.DataPageIO;
-import org.apache.ignite.internal.processors.cache.database.tree.io.PageIO;
-import org.apache.ignite.internal.processors.cache.database.tree.io.TrackingPageIO;
-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.internal.pagemem.store.IgnitePageStoreManager;
-import org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager;
-import org.apache.ignite.internal.pagemem.wal.WALIterator;
-import org.apache.ignite.internal.pagemem.wal.WALPointer;
-import org.apache.ignite.internal.pagemem.wal.record.CheckpointRecord;
-import org.apache.ignite.internal.pagemem.wal.record.DataEntry;
-import org.apache.ignite.internal.pagemem.wal.record.DataRecord;
-import org.apache.ignite.internal.pagemem.wal.record.PageSnapshot;
-import org.apache.ignite.internal.pagemem.wal.record.WALRecord;
-import org.apache.ignite.internal.processors.cache.CacheObject;
-import org.apache.ignite.internal.processors.cache.CacheObjectContext;
-import org.apache.ignite.internal.processors.cache.GridCacheContext;
-import org.apache.ignite.internal.processors.cache.GridCacheOperation;
-import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
-import org.apache.ignite.internal.processors.cache.KeyCacheObject;
-import org.apache.ignite.internal.util.typedef.F;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteBiTuple;
-import org.apache.ignite.testframework.GridTestUtils;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-/**
- *
- */
-public class ignitePdsCheckpointSimulationTest extends GridCommonAbstractTest {
- /** */
- private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
-
- /** */
- private static final int TOTAL_PAGES = 1000;
-
- /** */
- private static final boolean VERBOSE = false;
-
- /** Cache name. */
- private final String cacheName = "cache";
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(gridName);
-
- CacheConfiguration ccfg = new CacheConfiguration(cacheName);
-
- ccfg.setRebalanceMode(CacheRebalanceMode.NONE);
-
- cfg.setCacheConfiguration(ccfg);
-
- MemoryConfiguration dbCfg = new MemoryConfiguration();
-
- cfg.setMemoryConfiguration(dbCfg);
-
- cfg.setPersistentStoreConfiguration(
- new PersistentStoreConfiguration()
- .setCheckpointingFrequency(500)
- .setWalMode(WALMode.LOG_ONLY)
- .setAlwaysWriteFullPages(true)
- );
-
- TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
-
- discoSpi.setIpFinder(IP_FINDER);
-
- cfg.setDiscoverySpi(discoSpi);
-
- return cfg;
- }
-
- /** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- stopAllGrids();
-
- deleteWorkFiles();
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- stopAllGrids();
-
- deleteWorkFiles();
- }
-
- /**
- * @throws Exception if failed.
- */
- public void testCheckpointSimulationMultiThreaded() throws Exception {
- IgniteEx ig = startGrid(0);
-
- GridCacheSharedContext<Object, Object> shared = ig.context().cache().context();
-
- GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager)shared.database();
-
- IgnitePageStoreManager pageStore = shared.pageStore();
-
- U.sleep(1_000);
-
- // Disable integrated checkpoint thread.
- dbMgr.enableCheckpoints(false).get();
-
- // Must put something in partition 0 in order to initialize meta page.
- // Otherwise we will violate page store integrity rules.
- ig.cache(cacheName).put(0, 0);
-
- PageMemory mem = shared.database().memoryPolicy(null).pageMemory();
-
- IgniteBiTuple<Map<FullPageId, Integer>, WALPointer> res;
-
- try {
- res = runCheckpointing(ig, (PageMemoryImpl)mem, pageStore, shared.wal(),
- shared.cache().cache(cacheName).context().cacheId());
- }
- catch (Throwable th) {
- log().error("Error while running checkpointing", th);
-
- throw th;
- }
- finally {
- dbMgr.enableCheckpoints(true).get();
-
- stopAllGrids(false);
- }
-
- ig = startGrid(0);
-
- shared = ig.context().cache().context();
-
- dbMgr = (GridCacheDatabaseSharedManager)shared.database();
-
- dbMgr.enableCheckpoints(false).get();
-
- mem = shared.database().memoryPolicy(null).pageMemory();
-
- verifyReads(res.get1(), mem, res.get2(), shared.wal());
- }
-
- /**
- * @throws Exception if failed.
- */
- public void testGetForInitialWrite() throws Exception {
- IgniteEx ig = startGrid(0);
-
- GridCacheSharedContext<Object, Object> shared = ig.context().cache().context();
-
- int cacheId = shared.cache().cache(cacheName).context().cacheId();
-
- GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager)shared.database();
-
- // Disable integrated checkpoint thread.
- dbMgr.enableCheckpoints(false);
-
- PageMemory mem = shared.database().memoryPolicy(null).pageMemory();
-
- IgniteWriteAheadLogManager wal = shared.wal();
-
- WALPointer start = wal.log(new CheckpointRecord(null, false));
-
- final FullPageId[] initWrites = new FullPageId[10];
-
- ig.context().cache().context().database().checkpointReadLock();
-
- try {
- for (int i = 0; i < initWrites.length; i++)
- initWrites[i] = new FullPageId(mem.allocatePage(cacheId, 0, PageIdAllocator.FLAG_DATA), cacheId);
-
- // Check getForInitialWrite methods.
- for (FullPageId fullId : initWrites) {
- long page = mem.acquirePage(fullId.cacheId(), fullId.pageId());
- try {
- long pageAddr = mem.writeLock(fullId.cacheId(), fullId.pageId(), page);
-
- try {
- DataPageIO.VERSIONS.latest().initNewPage(pageAddr, fullId.pageId(), mem.pageSize());
-
- for (int i = PageIO.COMMON_HEADER_END; i < mem.pageSize(); i++)
- PageUtils.putByte(pageAddr, i, (byte)0xAB);
- }
- finally {
- mem.writeUnlock(fullId.cacheId(), fullId.pageId(), page, null, true);
- }
- }
- finally {
- mem.releasePage(fullId.cacheId(), fullId.pageId(), page);
- }
- }
-
- wal.fsync(null);
- }
- finally {
- ig.context().cache().context().database().checkpointReadUnlock();
- stopAllGrids(false);
- }
-
- ig = startGrid(0);
-
- shared = ig.context().cache().context();
-
- dbMgr = (GridCacheDatabaseSharedManager)shared.database();
-
- dbMgr.enableCheckpoints(false);
-
- wal = shared.wal();
-
- try (WALIterator it = wal.replay(start)) {
- it.nextX();
-
- for (FullPageId initialWrite : initWrites) {
- IgniteBiTuple<WALPointer, WALRecord> tup = it.nextX();
-
- assertTrue(String.valueOf(tup.get2()), tup.get2() instanceof PageSnapshot);
-
- PageSnapshot snap = (PageSnapshot)tup.get2();
-
- FullPageId actual = snap.fullPageId();
-
- //there are extra tracking pages, skip them
- if (TrackingPageIO.VERSIONS.latest().trackingPageFor(actual.pageId(), mem.pageSize()) == actual.pageId()) {
- tup = it.nextX();
-
- assertTrue(tup.get2() instanceof PageSnapshot);
-
- actual = ((PageSnapshot)tup.get2()).fullPageId();
- }
-
- assertEquals(initialWrite, actual);
- }
- }
- }
-
- /**
- * @throws Exception if failed.
- */
- public void testDataWalEntries() throws Exception {
- IgniteEx ig = startGrid(0);
-
- GridCacheSharedContext<Object, Object> sharedCtx = ig.context().cache().context();
- GridCacheContext<Object, Object> cctx = sharedCtx.cache().cache(cacheName).context();
-
- GridCacheDatabaseSharedManager db = (GridCacheDatabaseSharedManager)sharedCtx.database();
- IgniteWriteAheadLogManager wal = sharedCtx.wal();
-
- assertTrue(wal.isAlwaysWriteFullPages());
-
- db.enableCheckpoints(false);
-
- final int cnt = 10;
-
- List<DataEntry> entries = new ArrayList<>(cnt);
-
- for (int i = 0; i < cnt; i++) {
- GridCacheOperation op = i % 2 == 0 ? GridCacheOperation.UPDATE : GridCacheOperation.DELETE;
-
- KeyCacheObject key = cctx.toCacheKeyObject(i);
-
- CacheObject val = null;
-
- if (op != GridCacheOperation.DELETE)
- val = cctx.toCacheObject("value-" + i);
-
- entries.add(new DataEntry(cctx.cacheId(), key, val, op, null, cctx.versions().next(), 0L,
- cctx.affinity().partition(i), i));
- }
-
- UUID cpId = UUID.randomUUID();
-
- WALPointer start = wal.log(new CheckpointRecord(cpId, null, false));
-
- wal.fsync(start);
-
- for (DataEntry entry : entries)
- wal.log(new DataRecord(entry));
-
- WALPointer end = wal.log(new CheckpointRecord(cpId, start, true));
-
- wal.fsync(end);
-
- // Data will not be written to the page store.
- stopAllGrids();
-
- ig = startGrid(0);
-
- sharedCtx = ig.context().cache().context();
- cctx = sharedCtx.cache().cache(cacheName).context();
-
- db = (GridCacheDatabaseSharedManager)sharedCtx.database();
- wal = sharedCtx.wal();
-
- db.enableCheckpoints(false);
-
- try (WALIterator it = wal.replay(start)) {
- IgniteBiTuple<WALPointer, WALRecord> tup = it.nextX();
-
- assert tup.get2() instanceof CheckpointRecord;
-
- assertEquals(start, tup.get1());
-
- CheckpointRecord cpRec = (CheckpointRecord)tup.get2();
-
- assertEquals(cpId, cpRec.checkpointId());
- assertNull(cpRec.checkpointMark());
- assertFalse(cpRec.end());
-
- int idx = 0;
- CacheObjectContext coctx = cctx.cacheObjectContext();
-
- while (idx < entries.size()) {
- tup = it.nextX();
-
- assert tup.get2() instanceof DataRecord;
-
- DataRecord dataRec = (DataRecord)tup.get2();
-
- DataEntry entry = entries.get(idx);
-
- assertEquals(1, dataRec.writeEntries().size());
-
- DataEntry readEntry = dataRec.writeEntries().get(0);
-
- assertEquals(entry.cacheId(), readEntry.cacheId());
- assertEquals(entry.key().<Integer>value(coctx, true), readEntry.key().<Integer>value(coctx, true));
- assertEquals(entry.op(), readEntry.op());
-
- if (entry.op() == GridCacheOperation.UPDATE)
- assertEquals(entry.value().value(coctx, true), readEntry.value().value(coctx, true));
- else
- assertNull(entry.value());
-
- assertEquals(entry.writeVersion(), readEntry.writeVersion());
- assertEquals(entry.nearXidVersion(), readEntry.nearXidVersion());
- assertEquals(entry.partitionCounter(), readEntry.partitionCounter());
-
- idx++;
- }
-
- tup = it.nextX();
-
- assert tup.get2() instanceof CheckpointRecord;
-
- assertEquals(end, tup.get1());
-
- cpRec = (CheckpointRecord)tup.get2();
-
- assertEquals(cpId, cpRec.checkpointId());
- assertEquals(start, cpRec.checkpointMark());
- assertTrue(cpRec.end());
- }
- }
-
- /**
- * @throws Exception if failed.
- */
- public void testPageWalEntries() throws Exception {
- IgniteEx ig = startGrid(0);
-
- GridCacheSharedContext<Object, Object> sharedCtx = ig.context().cache().context();
- int cacheId = sharedCtx.cache().cache(cacheName).context().cacheId();
-
- GridCacheDatabaseSharedManager db = (GridCacheDatabaseSharedManager)sharedCtx.database();
- PageMemory pageMem = sharedCtx.database().memoryPolicy(null).pageMemory();
- IgniteWriteAheadLogManager wal = sharedCtx.wal();
-
- db.enableCheckpoints(false).get();
-
- int pageCnt = 100;
-
- List<FullPageId> pageIds = new ArrayList<>();
-
- for (int i = 0; i < pageCnt; i++) {
- db.checkpointReadLock();
- try {
- pageIds.add(new FullPageId(pageMem.allocatePage(cacheId, PageIdAllocator.INDEX_PARTITION,
- PageIdAllocator.FLAG_IDX), cacheId));
- }
- finally {
- db.checkpointReadUnlock();
- }
- }
-
- UUID cpId = UUID.randomUUID();
-
- WALPointer start = wal.log(new CheckpointRecord(cpId, null, false));
-
- wal.fsync(start);
-
- ig.context().cache().context().database().checkpointReadLock();
-
- try {
- for (FullPageId pageId : pageIds)
- writePageData(pageId, pageMem);
- }
- finally {
- ig.context().cache().context().database().checkpointReadUnlock();
- }
-
- WALPointer end = wal.log(new CheckpointRecord(cpId, start, true));
-
- wal.fsync(end);
-
- // Data will not be written to the page store.
- stopAllGrids();
-
- ig = startGrid(0);
-
- sharedCtx = ig.context().cache().context();
-
- db = (GridCacheDatabaseSharedManager)sharedCtx.database();
- wal = sharedCtx.wal();
-
- db.enableCheckpoints(false);
-
- try (WALIterator it = wal.replay(start)) {
- IgniteBiTuple<WALPointer, WALRecord> tup = it.nextX();
-
- assert tup.get2() instanceof CheckpointRecord : tup.get2();
-
- assertEquals(start, tup.get1());
-
- CheckpointRecord cpRec = (CheckpointRecord)tup.get2();
-
- assertEquals(cpId, cpRec.checkpointId());
- assertNull(cpRec.checkpointMark());
- assertFalse(cpRec.end());
-
- int idx = 0;
-
- while (idx < pageIds.size()) {
- tup = it.nextX();
-
- assert tup.get2() instanceof PageSnapshot : tup.get2().getClass();
-
- PageSnapshot snap = (PageSnapshot)tup.get2();
-
- //there are extra tracking pages, skip them
- if (TrackingPageIO.VERSIONS.latest().trackingPageFor(snap.fullPageId().pageId(), pageMem.pageSize()) == snap.fullPageId().pageId()) {
- tup = it.nextX();
-
- assertTrue(tup.get2() instanceof PageSnapshot);
-
- snap = (PageSnapshot)tup.get2();
- }
-
- assertEquals(pageIds.get(idx), snap.fullPageId());
-
- idx++;
- }
-
- tup = it.nextX();
-
- assert tup.get2() instanceof CheckpointRecord;
-
- assertEquals(end, tup.get1());
-
- cpRec = (CheckpointRecord)tup.get2();
-
- assertEquals(cpId, cpRec.checkpointId());
- assertEquals(start, cpRec.checkpointMark());
- assertTrue(cpRec.end());
- }
- }
-
- /**
- * @throws Exception if failed.
- */
- public void testDirtyFlag() throws Exception {
- IgniteEx ig = startGrid(0);
-
- GridCacheSharedContext<Object, Object> shared = ig.context().cache().context();
-
- int cacheId = shared.cache().cache(cacheName).context().cacheId();
-
- GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager)shared.database();
-
- // Disable integrated checkpoint thread.
- dbMgr.enableCheckpoints(false);
-
- PageMemoryEx mem = (PageMemoryEx) dbMgr.memoryPolicy(null).pageMemory();
-
- ig.context().cache().context().database().checkpointReadLock();
-
- FullPageId[] pageIds = new FullPageId[100];
-
- try {
- for (int i = 0; i < pageIds.length; i++)
- pageIds[i] = new FullPageId(mem.allocatePage(cacheId, 0, PageIdAllocator.FLAG_DATA), cacheId);
-
- for (FullPageId fullId : pageIds) {
- long page = mem.acquirePage(fullId.cacheId(), fullId.pageId());
-
- try {
- assertTrue(mem.isDirty(fullId.cacheId(), fullId.pageId(), page)); //page is dirty right after allocation
-
- long pageAddr = mem.writeLock(fullId.cacheId(), fullId.pageId(), page);
-
- PageIO.setPageId(pageAddr, fullId.pageId());
-
- try {
- assertTrue(mem.isDirty(fullId.cacheId(), fullId.pageId(), page));
- }
- finally {
- mem.writeUnlock(fullId.cacheId(), fullId.pageId(),page, null,true);
- }
-
- assertTrue(mem.isDirty(fullId.cacheId(), fullId.pageId(), page));
- }
- finally {
- mem.releasePage(fullId.cacheId(), fullId.pageId(), page);
- }
- }
- }
- finally {
- ig.context().cache().context().database().checkpointReadUnlock();
- }
-
- Collection<FullPageId> cpPages = mem.beginCheckpoint();
-
- ig.context().cache().context().database().checkpointReadLock();
-
- try {
- for (FullPageId fullId : pageIds) {
- assertTrue(cpPages.contains(fullId));
-
- ByteBuffer buf = ByteBuffer.allocate(mem.pageSize());
-
- long page = mem.acquirePage(fullId.cacheId(), fullId.pageId());
-
- try {
- assertTrue(mem.isDirty(fullId.cacheId(), fullId.pageId(), page));
-
- long pageAddr = mem.writeLock(fullId.cacheId(), fullId.pageId(), page);
-
- try {
- assertFalse(mem.isDirty(fullId.cacheId(), fullId.pageId(), page));
-
- for (int i = PageIO.COMMON_HEADER_END; i < mem.pageSize(); i++)
- PageUtils.putByte(pageAddr, i, (byte)1);
- }
- finally {
- mem.writeUnlock(fullId.cacheId(), fullId.pageId(), page, null, true);
- }
-
- assertTrue(mem.isDirty(fullId.cacheId(), fullId.pageId(), page));
-
- buf.rewind();
-
- mem.getForCheckpoint(fullId, buf, null);
-
- buf.position(PageIO.COMMON_HEADER_END);
-
- while (buf.hasRemaining())
- assertEquals((byte)0, buf.get());
- }
- finally {
- mem.releasePage(fullId.cacheId(), fullId.pageId(), page);
- }
- }
- }
- finally {
- ig.context().cache().context().database().checkpointReadUnlock();
- }
-
- mem.finishCheckpoint();
-
- for (FullPageId fullId : pageIds) {
- long page = mem.acquirePage(fullId.cacheId(), fullId.pageId());
- try {
- assertTrue(mem.isDirty(fullId.cacheId(), fullId.pageId(), page));
- }
- finally {
- mem.releasePage(fullId.cacheId(), fullId.pageId(), page);
- }
- }
- }
-
- /**
- * @throws Exception if failed.
- */
- private void writePageData(FullPageId fullId, PageMemory mem) throws Exception {
- long page = mem.acquirePage(fullId.cacheId(), fullId.pageId());
- try {
- long pageAddr = mem.writeLock(fullId.cacheId(), fullId.pageId(), page);
-
- try {
- DataPageIO.VERSIONS.latest().initNewPage(pageAddr, fullId.pageId(), mem.pageSize());
-
- ThreadLocalRandom rnd = ThreadLocalRandom.current();
-
- for (int i = PageIO.COMMON_HEADER_END; i < mem.pageSize(); i++)
- PageUtils.putByte(pageAddr, i, (byte)rnd.nextInt(255));
- }
- finally {
- mem.writeUnlock(fullId.cacheId(), fullId.pageId(), page, null, true);
- }
- }
- finally {
- mem.releasePage(fullId.cacheId(), fullId.pageId(), page);
- }
- }
-
- /**
- * @param res Result map to verify.
- * @param mem Memory.
- */
- private void verifyReads(
- Map<FullPageId, Integer> res,
- PageMemory mem,
- WALPointer start,
- IgniteWriteAheadLogManager wal
- ) throws Exception {
- Map<FullPageId, byte[]> replay = new HashMap<>();
-
- try (WALIterator it = wal.replay(start)) {
- IgniteBiTuple<WALPointer, WALRecord> tup = it.nextX();
-
- assertTrue("Invalid record: " + tup, tup.get2() instanceof CheckpointRecord);
-
- CheckpointRecord cpRec = (CheckpointRecord)tup.get2();
-
- while (it.hasNextX()) {
- tup = it.nextX();
-
- WALRecord rec = tup.get2();
-
- if (rec instanceof CheckpointRecord) {
- CheckpointRecord end = (CheckpointRecord)rec;
-
- // Found the finish mark.
- if (end.checkpointId().equals(cpRec.checkpointId()) && end.end())
- break;
- }
- else if (rec instanceof PageSnapshot) {
- PageSnapshot page = (PageSnapshot)rec;
-
- replay.put(page.fullPageId(), page.pageData());
- }
- }
- }
-
- // Check read-through from the file store.
- for (Map.Entry<FullPageId, Integer> entry : res.entrySet()) {
- FullPageId fullId = entry.getKey();
- int state = entry.getValue();
-
- if (state == -1) {
- info("Page was never written: " + fullId);
-
- continue;
- }
-
- byte[] walData = replay.get(fullId);
-
- assertNotNull("Missing WAL record for a written page: " + fullId, walData);
-
- long page = mem.acquirePage(fullId.cacheId(), fullId.pageId());
- try {
- long pageAddr = mem.readLock(fullId.cacheId(), fullId.pageId(), page);
-
- try {
- for (int i = PageIO.COMMON_HEADER_END; i < mem.pageSize(); i++) {
- assertEquals("Invalid state [pageId=" + fullId + ", pos=" + i + ']',
- state & 0xFF, PageUtils.getByte(pageAddr, i) & 0xFF);
-
- assertEquals("Invalid WAL state [pageId=" + fullId + ", pos=" + i + ']',
- state & 0xFF, walData[i] & 0xFF);
- }
- }
- finally {
- mem.readUnlock(fullId.cacheId(), fullId.pageId(), page);
- }
- }
- finally {
- mem.releasePage(fullId.cacheId(), fullId.pageId(), page);
- }
- }
- }
-
- /**
- * @param mem Memory to use.
- * @param storeMgr Store manager.
- * @param cacheId Cache ID.
- * @return Result map of random operations.
- * @throws Exception If failure occurred.
- */
- private IgniteBiTuple<Map<FullPageId, Integer>, WALPointer> runCheckpointing(
- final IgniteEx ig,
- final PageMemoryImpl mem,
- final IgnitePageStoreManager storeMgr,
- final IgniteWriteAheadLogManager wal,
- final int cacheId
- ) throws Exception {
- final ConcurrentMap<FullPageId, Integer> resMap = new ConcurrentHashMap<>();
-
- final FullPageId pages[] = new FullPageId[TOTAL_PAGES];
-
- Set<FullPageId> allocated = new HashSet<>();
-
- for (int i = 0; i < TOTAL_PAGES; i++) {
- FullPageId fullId = new FullPageId(mem.allocatePage(cacheId, 0, PageIdAllocator.FLAG_DATA), cacheId);
-
- resMap.put(fullId, -1);
-
- pages[i] = fullId;
-
- allocated.add(fullId);
- }
-
- final AtomicBoolean run = new AtomicBoolean(true);
-
- // Simulate transaction lock.
- final ReadWriteLock updLock = new ReentrantReadWriteLock();
-
- // Mark the start position.
- CheckpointRecord cpRec = new CheckpointRecord(null, false);
-
- WALPointer start = wal.log(cpRec);
-
- wal.fsync(start);
-
- IgniteInternalFuture<Long> updFut = GridTestUtils.runMultiThreadedAsync(new Callable<Object>() {
- @Override public Object call() throws Exception {
- while (true) {
- FullPageId fullId = pages[ThreadLocalRandom.current().nextInt(TOTAL_PAGES)];
-
- updLock.readLock().lock();
-
- try {
- if (!run.get())
- return null;
-
- ig.context().cache().context().database().checkpointReadLock();
-
- try {
- long page = mem.acquirePage(fullId.cacheId(), fullId.pageId());
-
- try {
- long pageAddr = mem.writeLock(fullId.cacheId(), fullId.pageId(), page);
-
- PageIO.setPageId(pageAddr, fullId.pageId());
-
- try {
- int state = resMap.get(fullId);
-
- if (state != -1) {
- if (VERBOSE)
- info("Verify page [fullId=" + fullId + ", state=" + state +
- ", buf=" + pageAddr +
- ", bhc=" + U.hexLong(System.identityHashCode(pageAddr)) +
- ", page=" + U.hexLong(System.identityHashCode(page)) + ']');
-
- for (int i = PageIO.COMMON_HEADER_END; i < mem.pageSize(); i++)
- assertEquals("Verify page failed [fullId=" + fullId +
- ", i=" + i +
- ", state=" + state +
- ", buf=" + pageAddr +
- ", bhc=" + U.hexLong(System.identityHashCode(pageAddr)) +
- ", page=" + U.hexLong(System.identityHashCode(page)) + ']',
- state & 0xFF, PageUtils.getByte(pageAddr, i) & 0xFF);
- }
-
- state = (state + 1) & 0xFF;
-
- if (VERBOSE)
- info("Write page [fullId=" + fullId + ", state=" + state +
- ", buf=" + pageAddr +
- ", bhc=" + U.hexLong(System.identityHashCode(pageAddr)) +
- ", page=" + U.hexLong(System.identityHashCode(page)) + ']');
-
- for (int i = PageIO.COMMON_HEADER_END; i < mem.pageSize(); i++)
- PageUtils.putByte(pageAddr, i, (byte)state);
-
- resMap.put(fullId, state);
- }
- finally {
- mem.writeUnlock(fullId.cacheId(), fullId.pageId(),page, null,true);
- }
- }
- finally {
- mem.releasePage(fullId.cacheId(), fullId.pageId(),page);}
- }
- finally {
- ig.context().cache().context().database().checkpointReadUnlock();
- }
- }
- finally {
- updLock.readLock().unlock();
- }
- }
- }
- }, 8, "update-thread");
-
- int checkpoints = 20;
-
- while (checkpoints > 0) {
- Map<FullPageId, Integer> snapshot = null;
-
- Collection<FullPageId> pageIds;
-
- updLock.writeLock().lock();
-
- try {
- snapshot = new HashMap<>(resMap);
-
- pageIds = mem.beginCheckpoint();
-
- checkpoints--;
-
- if (checkpoints == 0)
- // No more writes should be done at this point.
- run.set(false);
-
- info("Acquired pages for checkpoint: " + pageIds.size());
- }
- finally {
- updLock.writeLock().unlock();
- }
-
- boolean ok = false;
-
- try {
- ByteBuffer tmpBuf = ByteBuffer.allocate(mem.pageSize());
-
- tmpBuf.order(ByteOrder.nativeOrder());
-
- long begin = System.currentTimeMillis();
-
- long cp = 0;
-
- long write = 0;
-
- for (FullPageId fullId : pageIds) {
- long cpStart = System.nanoTime();
-
- Integer tag = mem.getForCheckpoint(fullId, tmpBuf, null);
-
- if (tag == null)
- continue;
-
- long cpEnd = System.nanoTime();
-
- cp += cpEnd - cpStart;
-
- Integer state = snapshot.get(fullId);
-
- if (allocated.contains(fullId) && state != -1) {
- tmpBuf.rewind();
-
- Integer first = null;
-
- for (int i = PageIO.COMMON_HEADER_END; i < mem.pageSize(); i++) {
- int val = tmpBuf.get(i) & 0xFF;
-
- if (first == null)
- first = val;
-
- // Avoid string concat.
- if (first != val)
- assertEquals("Corrupted buffer at position [pageId=" + fullId + ", pos=" + i + ']',
- (int)first, val);
-
- // Avoid string concat.
- if (state != val)
- assertEquals("Invalid value at position [pageId=" + fullId + ", pos=" + i + ']',
- (int)state, val);
- }
- }
-
- tmpBuf.rewind();
-
- long writeStart = System.nanoTime();
-
- storeMgr.write(cacheId, fullId.pageId(), tmpBuf, tag);
-
- long writeEnd = System.nanoTime();
-
- write += writeEnd - writeStart;
-
- tmpBuf.rewind();
- }
-
- long syncStart = System.currentTimeMillis();
-
- storeMgr.sync(cacheId, 0);
-
- long end = System.currentTimeMillis();
-
- info("Written pages in " + (end - begin) + "ms, copy took " + (cp / 1_000_000) + "ms, " +
- "write took " + (write / 1_000_000) + "ms, sync took " + (end - syncStart) + "ms");
-
- ok = true;
- }
- finally {
- info("Finishing checkpoint...");
-
- mem.finishCheckpoint();
-
- info("Finished checkpoint");
-
- if (!ok) {
- info("Cancelling updates...");
-
- run.set(false);
-
- updFut.get();
- }
- }
-
- if (checkpoints != 0)
- Thread.sleep(2_000);
- }
-
- info("checkpoints=" + checkpoints + ", done=" + updFut.isDone());
-
- updFut.get();
-
- // Mark the end.
- wal.fsync(wal.log(new CheckpointRecord(cpRec.checkpointId(), start, true)));
-
- assertEquals(0, mem.activePagesCount());
-
- for (FullPageId fullId : pages) {
-
- long page = mem.acquirePage(fullId.cacheId(), fullId.pageId());
-
- try {
- assertFalse("Page has a temp heap copy after the last checkpoint: [cacheId=" +
- fullId.cacheId() + ", pageId=" + fullId.pageId() + "]", mem.hasTempCopy(page));
-
- assertFalse("Page is dirty after the last checkpoint: [cacheId=" +
- fullId.cacheId() + ", pageId=" + fullId.pageId() + "]", mem.isDirty(fullId.cacheId(), fullId.pageId(), page));
- }
- finally {
- mem.releasePage(fullId.cacheId(), fullId.pageId(), page);
- }
- }
-
- return F.t((Map<FullPageId, Integer>)resMap, start);
- }
-
- /**
- *
- */
- private void deleteWorkFiles() throws IgniteCheckedException {
- deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false));
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/test/java/org/apache/ignite/cache/database/db/wal/IgnitePdsWalTlbTest.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/db/wal/IgnitePdsWalTlbTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/db/wal/IgnitePdsWalTlbTest.java
deleted file mode 100644
index 03b1384..0000000
--- a/modules/pds/src/test/java/org/apache/ignite/cache/database/db/wal/IgnitePdsWalTlbTest.java
+++ /dev/null
@@ -1,134 +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 javax.cache.CacheException;
-import org.apache.ignite.IgniteDataStreamer;
-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.internal.IgniteEx;
-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;
-
-import static org.apache.ignite.configuration.PersistentStoreConfiguration.DFLT_CHECKPOINTING_PAGE_BUFFER_SIZE;
-
-/**
- *
- */
-public class IgnitePdsWalTlbTest extends GridCommonAbstractTest {
- /** Ip finder. */
- private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
-
- /** Cache name. */
- private static final String CACHE_NAME = "cache";
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(gridName);
-
- CacheConfiguration<Integer, Integer> ccfg = new CacheConfiguration<>(CACHE_NAME);
-
- cfg.setCacheConfiguration(ccfg);
-
- MemoryConfiguration memCfg = new MemoryConfiguration();
-
- MemoryPolicyConfiguration memPlcCfg = new MemoryPolicyConfiguration();
-
- memPlcCfg.setName("dfltMemPlc");
- memPlcCfg.setInitialSize(100 * 1024 * 1024);
- memPlcCfg.setMaxSize(100 * 1024 * 1024);
-
- memCfg.setMemoryPolicies(memPlcCfg);
- memCfg.setDefaultMemoryPolicyName("dfltMemPlc");
-
- cfg.setMemoryConfiguration(memCfg);
-
- cfg.setPersistentStoreConfiguration(
- new PersistentStoreConfiguration()
- .setCheckpointingPageBufferSize(DFLT_CHECKPOINTING_PAGE_BUFFER_SIZE + 1)
- .setTlbSize(640000000)
- );
-
- TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
-
- discoSpi.setIpFinder(IP_FINDER);
-
- if (gridName.endsWith("1"))
- cfg.setClientMode(true);
-
- cfg.setDiscoverySpi(discoSpi);
-
- return cfg;
- }
-
- /** {@inheritDoc} */
- @Override protected long getTestTimeout() {
- return 30_000;
- }
-
- /** {@inheritDoc} */
- @Override protected void beforeTest() throws Exception {
- deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false));
-
- stopAllGrids();
-
- startGrids(2);
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- stopAllGrids();
-
- deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false));
- }
-
- /**
- * @throws Exception if failed.
- */
- public void testWalDirectOutOfMemory() throws Exception {
- IgniteEx ig = grid(1);
-
- boolean locked = true;
-
- try {
- IgniteDataStreamer<Integer, Integer> streamer = ig.dataStreamer(CACHE_NAME);
-
- for (int i = 0; i < 100_000; i++) {
- streamer.addData(i, 1);
-
- if (i > 0 && i % 10_000 == 0)
- info("Done put: " + i);
- }
- }
- catch (CacheException ignore) {
- // expected
- locked = false;
- }
- finally {
- assertFalse(locked);
-
- stopAllGrids();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/test/java/org/apache/ignite/cache/database/db/wal/IgniteWalDirectoriesConfigurationTest.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/db/wal/IgniteWalDirectoriesConfigurationTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/db/wal/IgniteWalDirectoriesConfigurationTest.java
deleted file mode 100644
index 4cca401..0000000
--- a/modules/pds/src/test/java/org/apache/ignite/cache/database/db/wal/IgniteWalDirectoriesConfigurationTest.java
+++ /dev/null
@@ -1,54 +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 org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.configuration.PersistentStoreConfiguration;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-/**
- *
- */
-public class IgniteWalDirectoriesConfigurationTest extends GridCommonAbstractTest {
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(gridName);
-
- PersistentStoreConfiguration pCfg = new PersistentStoreConfiguration();
-
- pCfg.setWalStorePath("test/db/wal");
-
- cfg.setPersistentStoreConfiguration(pCfg);
-
- return cfg;
- }
-
- /**
- *
- */
- public void testPartialWalConfigurationNotAllowed() {
- try {
- startGrid();
- }
- catch (Exception ignore) {
- return;
- }
-
- fail("Node successfully started with incorrect configuration, exception is expected.");
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/test/java/org/apache/ignite/cache/database/db/wal/IgniteWalHistoryReservationsTest.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/db/wal/IgniteWalHistoryReservationsTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/db/wal/IgniteWalHistoryReservationsTest.java
deleted file mode 100644
index fc46c2e..0000000
--- a/modules/pds/src/test/java/org/apache/ignite/cache/database/db/wal/IgniteWalHistoryReservationsTest.java
+++ /dev/null
@@ -1,395 +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.util.Map;
-import java.util.concurrent.locks.Lock;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.cache.CacheAtomicityMode;
-import org.apache.ignite.cache.CacheWriteSynchronizationMode;
-import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
-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.internal.IgniteEx;
-import org.apache.ignite.internal.processors.cache.database.GridCacheDatabaseSharedManager;
-import org.apache.ignite.internal.processors.cache.database.wal.FileWriteAheadLogManager;
-import org.apache.ignite.internal.util.lang.GridAbsPredicate;
-import org.apache.ignite.internal.util.typedef.G;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.testframework.GridTestUtils;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-import static org.apache.ignite.IgniteSystemProperties.IGNITE_PDS_WAL_REBALANCE_THRESHOLD;
-
-/**
- *
- */
-public class IgniteWalHistoryReservationsTest extends GridCommonAbstractTest {
- /** */
- private volatile boolean client;
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(gridName);
-
- cfg.setClientMode(client);
-
- MemoryConfiguration memCfg = new MemoryConfiguration();
-
- memCfg.setMemoryPolicies(new MemoryPolicyConfiguration().setInitialSize(200 * 1024 * 1024)
- .setMaxSize(200 * 1024 * 1024).setName("dfltMemPlc"));
-
- memCfg.setDefaultMemoryPolicyName("dfltMemPlc");
-
- cfg.setMemoryConfiguration(memCfg);
-
- CacheConfiguration ccfg1 = new CacheConfiguration();
-
- ccfg1.setName("cache1");
- ccfg1.setBackups(1);
- ccfg1.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
- ccfg1.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
- ccfg1.setAffinity(new RendezvousAffinityFunction(false, 32));
-
- cfg.setCacheConfiguration(ccfg1);
-
- cfg.setPersistentStoreConfiguration(new PersistentStoreConfiguration());
-
- return cfg;
- }
-
- /** {@inheritDoc} */
- @Override protected void beforeTestsStarted() throws Exception {
- stopAllGrids();
-
- deleteWorkFiles();
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- System.clearProperty(IGNITE_PDS_WAL_REBALANCE_THRESHOLD);
-
- client = false;
-
- stopAllGrids();
-
- deleteWorkFiles();
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testReservedOnExchange() throws Exception {
- System.setProperty(IGNITE_PDS_WAL_REBALANCE_THRESHOLD, "0");
-
- final int entryCnt = 10_000;
- final int initGridCnt = 4;
-
- final IgniteEx ig0 = (IgniteEx)startGrids(initGridCnt);
-
- IgniteCache<Object, Object> cache = ig0.cache("cache1");
-
- for (int k = 0; k < entryCnt; k++)
- cache.put(k, k);
-
- forceCheckpoint();
-
- for (int k = 0; k < entryCnt; k++)
- cache.put(k, k * 2);
-
- forceCheckpoint();
-
- for (int k = 0; k < entryCnt; k++)
- cache.put(k, k);
-
- forceCheckpoint();
-
- Lock lock = cache.lock(0);
-
- lock.lock();
-
- try {
- GridTestUtils.runAsync(new Runnable() {
- @Override public void run() {
- try {
- startGrid(initGridCnt);
- }
- catch (Exception e) {
- fail(e.getMessage());
- }
- }
- });
-
- boolean reserved = GridTestUtils.waitForCondition(new GridAbsPredicate() {
- @Override public boolean apply() {
- for (int g = 0; g < initGridCnt; g++) {
- IgniteEx ig = grid(g);
-
- FileWriteAheadLogManager wal = (FileWriteAheadLogManager)ig.context().cache().context().wal();
-
- Object archiver = GridTestUtils.getFieldValue(wal, "archiver");
-
- synchronized (archiver) {
- Map reserved = GridTestUtils.getFieldValue(archiver, "reserved");
-
- if (reserved.isEmpty())
- return false;
- }
- }
-
- return true;
- }
- }, 10_000);
-
- assert reserved;
- }
- finally {
- lock.unlock();
- }
-
- boolean released = GridTestUtils.waitForCondition(new GridAbsPredicate() {
- @Override public boolean apply() {
- for (int g = 0; g < initGridCnt; g++) {
- IgniteEx ig = grid(g);
-
- FileWriteAheadLogManager wal = (FileWriteAheadLogManager)ig.context().cache().context().wal();
-
- Object archiver = GridTestUtils.getFieldValue(wal, "archiver");
-
- synchronized (archiver) {
- Map reserved = GridTestUtils.getFieldValue(archiver, "reserved");
-
- if (!reserved.isEmpty())
- return false;
- }
- }
-
- return true;
- }
- }, 10_000);
-
- assert released;
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testRemovesArePreloadedIfHistoryIsAvailable() throws Exception {
- System.setProperty(IGNITE_PDS_WAL_REBALANCE_THRESHOLD, "0");
-
- int entryCnt = 10_000;
-
- Ignite ig0 = startGrids(2);
-
- IgniteCache<Integer, Integer> cache = ig0.cache("cache1");
-
- for (int k = 0; k < entryCnt; k++)
- cache.put(k, k);
-
- forceCheckpoint();
-
- stopGrid(1);
-
- for (int k = 0; k < entryCnt; k += 2)
- cache.remove(k);
-
- forceCheckpoint();
-
- Ignite ig1 = startGrid(1);
-
- IgniteCache<Integer, Integer> cache1 = ig1.cache("cache1");
-
- assertEquals(entryCnt / 2, cache.size());
- assertEquals(entryCnt / 2, cache1.size());
-
- for (Integer k = 0; k < entryCnt; k++) {
- if (k % 2 == 0) {
- assertTrue("k=" + k, !cache.containsKey(k));
- assertTrue("k=" + k, !cache1.containsKey(k));
- }
- else {
- assertEquals("k=" + k, k, cache.get(k));
- assertEquals("k=" + k, k, cache1.get(k));
- }
- }
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testNodeIsClearedIfHistoryIsUnavailable() throws Exception {
- int entryCnt = 10_000;
-
- Ignite ig0 = startGrids(2);
-
- IgniteCache<Integer, Integer> cache = ig0.cache("cache1");
-
- for (int k = 0; k < entryCnt; k++)
- cache.put(k, k);
-
- forceCheckpoint();
-
- stopGrid(1);
-
- for (int k = 0; k < entryCnt; k += 2)
- cache.remove(k);
-
- forceCheckpoint();
-
- for (Integer k = 0; k < entryCnt; k++) {
- if (k % 2 == 0)
- assertTrue("k=" + k, !cache.containsKey(k));
- else
- assertEquals("k=" + k, k, cache.get(k));
- }
-
- Ignite ig1 = startGrid(1);
-
- IgniteCache<Integer, Integer> cache1 = ig1.cache("cache1");
-
- assertEquals(entryCnt / 2, cache.size());
- assertEquals(entryCnt / 2, cache1.size());
-
- for (Integer k = 0; k < entryCnt; k++) {
- if (k % 2 == 0) {
- assertTrue("k=" + k, !cache.containsKey(k));
- assertTrue("k=" + k, !cache1.containsKey(k));
- }
- else {
- assertEquals("k=" + k, k, cache.get(k));
- assertEquals("k=" + k, k, cache1.get(k));
- }
- }
- }
-
- /**
- * @throws Exception If failed.
- */
- public void testNodeLeftDuringExchange() throws Exception {
- System.setProperty(IGNITE_PDS_WAL_REBALANCE_THRESHOLD, "0");
-
- final int entryCnt = 10_000;
- final int initGridCnt = 4;
-
- final IgniteEx ig0 = (IgniteEx)startGrids(initGridCnt);
-
- IgniteCache<Object, Object> cache = ig0.cache("cache1");
-
- for (int k = 0; k < entryCnt; k++)
- cache.put(k, k);
-
- forceCheckpoint();
-
- Lock lock = cache.lock(0);
-
- lock.lock();
-
- try {
- GridTestUtils.runAsync(new Runnable() {
- @Override public void run() {
- try {
- startGrid(initGridCnt);
- }
- catch (Exception e) {
- fail(e.getMessage());
- }
- }
- });
-
- boolean reserved = GridTestUtils.waitForCondition(new GridAbsPredicate() {
- @Override public boolean apply() {
- for (int g = 0; g < initGridCnt; g++) {
- IgniteEx ig = grid(g);
-
- FileWriteAheadLogManager wal = (FileWriteAheadLogManager)ig.context().cache().context().wal();
-
- Object archiver = GridTestUtils.getFieldValue(wal, "archiver");
-
- synchronized (archiver) {
- Map reserved = GridTestUtils.getFieldValue(archiver, "reserved");
-
- if (reserved.isEmpty())
- return false;
- }
- }
-
- return true;
- }
- }, 10_000);
-
- assert reserved;
-
- stopGrid(Integer.toString(initGridCnt - 1), true, false);
- }
- finally {
- lock.unlock();
- }
-
- boolean released = GridTestUtils.waitForCondition(new GridAbsPredicate() {
- @Override public boolean apply() {
- for (int g = 0; g < initGridCnt - 1; g++) {
- IgniteEx ig = grid(g);
-
- FileWriteAheadLogManager wal = (FileWriteAheadLogManager)ig.context().cache().context().wal();
-
- Object archiver = GridTestUtils.getFieldValue(wal, "archiver");
-
- synchronized (archiver) {
- Map reserved = GridTestUtils.getFieldValue(archiver, "reserved");
-
- if (!reserved.isEmpty())
- return false;
- }
- }
-
- return true;
- }
- }, 10_000);
-
- assert released;
-
- awaitPartitionMapExchange();
- }
-
- /**
- * @throws IgniteCheckedException If failed.
- */
- private void deleteWorkFiles() throws IgniteCheckedException {
- deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false));
- }
-
- /**
- *
- */
- private void forceCheckpoint() throws Exception {
- for (Ignite ignite : G.allGrids()) {
- if (ignite.cluster().localNode().isClient())
- continue;
-
- GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager)((IgniteEx)ignite).context()
- .cache().context().database();
-
- dbMgr.waitForCheckpoint("test");
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/ignite/blob/6bf5ce46/modules/pds/src/test/java/org/apache/ignite/cache/database/db/wal/IgniteWalRecoverySeveralRestartsTest.java
----------------------------------------------------------------------
diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/db/wal/IgniteWalRecoverySeveralRestartsTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/db/wal/IgniteWalRecoverySeveralRestartsTest.java
deleted file mode 100644
index d70bea2..0000000
--- a/modules/pds/src/test/java/org/apache/ignite/cache/database/db/wal/IgniteWalRecoverySeveralRestartsTest.java
+++ /dev/null
@@ -1,347 +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.util.Random;
-import java.util.concurrent.ThreadLocalRandom;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteDataStreamer;
-import org.apache.ignite.cache.CacheAtomicityMode;
-import org.apache.ignite.cache.CacheRebalanceMode;
-import org.apache.ignite.cache.CacheWriteSynchronizationMode;
-import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
-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.MemoryPolicyConfiguration;
-import org.apache.ignite.configuration.PersistentStoreConfiguration;
-import org.apache.ignite.configuration.WALMode;
-import org.apache.ignite.internal.IgniteEx;
-import org.apache.ignite.internal.util.typedef.internal.S;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.testframework.GridTestUtils;
-import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
-
-/**
- *
- */
-public class IgniteWalRecoverySeveralRestartsTest extends GridCommonAbstractTest {
- /** */
- public static final int PAGE_SIZE = 1024;
-
- /** */
- private static final int KEYS_COUNT = 100_000;
-
- /** */
- private static final int LARGE_KEYS_COUNT = 5_000;
-
- /** */
- private static final Random rnd = new Random(System.currentTimeMillis());
-
- /** */
- private String cacheName = "test";
-
- /** {@inheritDoc} */
- @Override protected long getTestTimeout() {
- return 3600_000;
- }
-
- /** {@inheritDoc} */
- @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
- IgniteConfiguration cfg = super.getConfiguration(gridName);
-
- CacheConfiguration<Integer, IndexedObject> ccfg = new CacheConfiguration<>(cacheName);
-
- ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
- ccfg.setRebalanceMode(CacheRebalanceMode.NONE);
- ccfg.setIndexedTypes(Integer.class, IndexedObject.class);
- ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
- ccfg.setAffinity(new RendezvousAffinityFunction(false, 64 * 4)); // 64 per node
- ccfg.setReadFromBackup(true);
-
- cfg.setCacheConfiguration(ccfg);
-
- MemoryConfiguration dbCfg = new MemoryConfiguration();
-
- dbCfg.setPageSize(PAGE_SIZE);
-
- MemoryPolicyConfiguration memPlcCfg = new MemoryPolicyConfiguration();
-
- memPlcCfg.setName("dfltMemPlc");
- memPlcCfg.setInitialSize(500 * 1024 * 1024);
- memPlcCfg.setMaxSize(500 * 1024 * 1024);
-
- dbCfg.setMemoryPolicies(memPlcCfg);
- dbCfg.setDefaultMemoryPolicyName("dfltMemPlc");
-
- cfg.setMemoryConfiguration(dbCfg);
-
- cfg.setPersistentStoreConfiguration(
- new PersistentStoreConfiguration()
- .setWalMode(WALMode.LOG_ONLY)
- );
-
- 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));
-
- super.beforeTest();
- }
-
- /** {@inheritDoc} */
- @Override protected void afterTest() throws Exception {
- super.afterTest();
-
- deleteRecursively(U.resolveWorkDirectory(U.defaultWorkDirectory(), "db", false));
- }
-
- /**
- * @throws Exception if failed.
- */
- public void testWalRecoverySeveralRestarts() throws Exception {
- try {
- IgniteEx ignite = startGrid(1);
-
- Random locRandom = ThreadLocalRandom.current();
-
- try (IgniteDataStreamer<Integer, IndexedObject> dataLdr = ignite.dataStreamer(cacheName)) {
- for (int i = 0; i < KEYS_COUNT; ++i) {
- if (i % (KEYS_COUNT / 100) == 0)
- info("Loading " + i * 100 / KEYS_COUNT + "%");
-
- dataLdr.addData(i, new IndexedObject(i));
- }
- }
-
- int size = ignite.cache(cacheName).size();
-
- for (int restartCnt = 0; restartCnt < 5; ++restartCnt) {
- stopGrid(1, true);
-
- info("Restart #" + restartCnt);
- U.sleep(500);
-
- ignite = startGrid(1);
-
- IgniteCache<Integer, IndexedObject> cache = ignite.cache(cacheName);
-
- assertEquals(size, cache.size());
-
- info("Restart #" + restartCnt);
-
- for (int i = 0; i < KEYS_COUNT / 100; ++i) {
- assertNotNull(cache.get(locRandom.nextInt(KEYS_COUNT / 100)));
-
- cache.put(locRandom.nextInt(KEYS_COUNT / 100), new IndexedObject(locRandom.nextInt(KEYS_COUNT / 100)));
- }
-
- cache.put(KEYS_COUNT + restartCnt, new IndexedObject(KEYS_COUNT + restartCnt));
-
- // Check recovery for partition meta pages.
- size = cache.size();
- }
- }
- finally {
- stopAllGrids();
- }
- }
-
- /**
- * @throws Exception if failed.
- */
- public void testWalRecoveryWithDynamicCache() throws Exception {
- try {
- IgniteEx ignite = startGrid(1);
-
- CacheConfiguration<Integer, IndexedObject> dynCacheCfg = new CacheConfiguration<>();
-
- dynCacheCfg.setName("dyncache");
- dynCacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
- dynCacheCfg.setRebalanceMode(CacheRebalanceMode.NONE);
- dynCacheCfg.setIndexedTypes(Integer.class, IndexedObject.class);
- dynCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
- dynCacheCfg.setAffinity(new RendezvousAffinityFunction(false, 64 * 4)); // 64 per node
- dynCacheCfg.setReadFromBackup(true);
-
- ignite.getOrCreateCache(dynCacheCfg);
-
- try (IgniteDataStreamer<Integer, IndexedObject> dataLdr = ignite.dataStreamer("dyncache")) {
- for (int i = 0; i < KEYS_COUNT; ++i) {
- if (i % (KEYS_COUNT / 100) == 0)
- info("Loading " + i * 100 / KEYS_COUNT + "%");
-
- dataLdr.addData(i, new IndexedObject(i));
- }
- }
-
- for (int restartCnt = 0; restartCnt < 5; ++restartCnt) {
- stopGrid(1, true);
-
- info("Restart #" + restartCnt);
- U.sleep(500);
-
- ignite = startGrid(1);
-
- ThreadLocalRandom locRandom = ThreadLocalRandom.current();
-
- IgniteCache<Integer, IndexedObject> cache = ignite.getOrCreateCache(dynCacheCfg);
-
- for (int i = 0; i < KEYS_COUNT; ++i)
- assertNotNull(cache.get(locRandom.nextInt(KEYS_COUNT)));
- }
- }
- finally {
- stopAllGrids();
- }
- }
-
- /**
- * @throws Exception if failed.
- */
- public void testWalRecoveryWithDynamicCacheLargeObjects() throws Exception {
- try {
- IgniteEx ignite = startGrid(1);
-
- CacheConfiguration<Integer, IndexedObject> dynCacheCfg = new CacheConfiguration<>();
-
- dynCacheCfg.setName("dyncache");
- dynCacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
- dynCacheCfg.setRebalanceMode(CacheRebalanceMode.NONE);
- dynCacheCfg.setIndexedTypes(Integer.class, IndexedObject.class);
- dynCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
- dynCacheCfg.setAffinity(new RendezvousAffinityFunction(false, 64 * 4)); // 64 per node
- dynCacheCfg.setReadFromBackup(true);
-
- ignite.getOrCreateCache(dynCacheCfg);
-
- try (IgniteDataStreamer<Integer, IndexedObject> dataLdr = ignite.dataStreamer("dyncache")) {
- for (int i = 0; i < LARGE_KEYS_COUNT; ++i) {
- if (i % (LARGE_KEYS_COUNT / 100) == 0)
- info("Loading " + i * 100 / LARGE_KEYS_COUNT + "%");
-
- IndexedObject obj = new IndexedObject(i);
-
- obj.payload = new byte[PAGE_SIZE + 2];
-
- dataLdr.addData(i, obj);
- }
- }
-
- for (int restartCnt = 0; restartCnt < 5; ++restartCnt) {
- stopGrid(1, true);
-
- info("Restart #" + restartCnt);
- U.sleep(500);
-
- ignite = startGrid(1);
-
- ThreadLocalRandom locRandom = ThreadLocalRandom.current();
-
- IgniteCache<Integer, IndexedObject> cache = ignite.getOrCreateCache(dynCacheCfg);
-
- for (int i = 0; i < LARGE_KEYS_COUNT; ++i) {
- IndexedObject val = cache.get(locRandom.nextInt(LARGE_KEYS_COUNT));
-
- assertNotNull(val);
-
- assertEquals(PAGE_SIZE + 2, val.payload.length);
- }
- }
- }
- finally {
- stopAllGrids();
- }
- }
-
- /**
- *
- */
- private static class IndexedObject {
- /** */
- @QuerySqlField(index = true)
- private int iVal;
-
- /** */
- @QuerySqlField(index = true)
- private String strVal0;
-
- /** */
- @QuerySqlField(index = true)
- private String strVal1;
-
- /** */
- private byte[] payload;
-
- /**
- * @param iVal Integer value.
- */
- private IndexedObject(int iVal) {
- this.iVal = iVal;
-
- strVal0 = "String value #0 " + iVal + " " + GridTestUtils.randomString(rnd, 256);
- strVal1 = GridTestUtils.randomString(rnd, 256);
- }
-
- /** {@inheritDoc} */
- @Override public boolean equals(Object o) {
- if (this == o)
- return true;
- if (o == null || getClass() != o.getClass())
- return false;
-
- IndexedObject obj = (IndexedObject)o;
-
- if (iVal != obj.iVal)
- return false;
-
- if (strVal0 != null ? !strVal0.equals(obj.strVal0) : obj.strVal0 != null)
- return false;
-
- return strVal1 != null ? strVal1.equals(obj.strVal1) : obj.strVal1 == null;
-
- }
-
- /** {@inheritDoc} */
- @Override public int hashCode() {
- int res = iVal;
-
- res = 31 * res + (strVal0 != null ? strVal0.hashCode() : 0);
- res = 31 * res + (strVal1 != null ? strVal1.hashCode() : 0);
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return S.toString(IndexedObject.class, this);
- }
- }
-}