use of org.apache.ignite.internal.pagemem.PageMemory in project ignite by apache.
the class IgnitePdsRecoveryAfterFileCorruptionTest method checkRestore.
/**
* @param ig Ig.
* @param pages Pages.
*/
private void checkRestore(IgniteEx ig, FullPageId[] pages) throws IgniteCheckedException {
GridCacheSharedContext<Object, Object> shared = ig.context().cache().context();
GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager) shared.database();
dbMgr.enableCheckpoints(false).get();
PageMemory mem = shared.database().dataRegion(null).pageMemory();
dbMgr.checkpointReadLock();
try {
for (FullPageId fullId : pages) {
long page = mem.acquirePage(fullId.groupId(), fullId.pageId());
try {
long pageAddr = mem.readLock(fullId.groupId(), fullId.pageId(), page);
for (int j = PageIO.COMMON_HEADER_END; j < mem.realPageSize(fullId.groupId()); j += 4) assertEquals(j + (int) fullId.pageId(), PageUtils.getInt(pageAddr, j));
mem.readUnlock(fullId.groupId(), fullId.pageId(), page);
} finally {
mem.releasePage(fullId.groupId(), fullId.pageId(), page);
}
}
} finally {
dbMgr.checkpointReadUnlock();
}
}
use of org.apache.ignite.internal.pagemem.PageMemory in project ignite by apache.
the class CacheFreeListSelfTest method createPageMemory.
/**
* @return Page memory.
*/
protected PageMemory createPageMemory(int pageSize, DataRegionConfiguration plcCfg) {
PageMemory pageMem = new PageMemoryNoStoreImpl(log, new UnsafeMemoryProvider(log), null, pageSize, plcCfg, new DataRegionMetricsImpl(plcCfg, new GridTestKernalContext(log())), true);
pageMem.start();
return pageMem;
}
use of org.apache.ignite.internal.pagemem.PageMemory in project ignite by apache.
the class IndexStorageSelfTest method metaAllocation.
/**
* @throws Exception If failed.
*/
private void metaAllocation() throws Exception {
PageMemory mem = memory(true);
int[] cacheIds = new int[] { 1, "partitioned".hashCode(), "replicated".hashCode() };
Map<Integer, Map<String, RootPage>> allocatedIdxs = new HashMap<>();
mem.start();
try {
final Map<Integer, IndexStorageImpl> storeMap = new HashMap<>();
for (int i = 0; i < 1_000; i++) {
int cacheId = cacheIds[i % cacheIds.length];
Map<String, RootPage> idxMap = allocatedIdxs.get(cacheId);
if (idxMap == null) {
idxMap = new HashMap<>();
allocatedIdxs.put(cacheId, idxMap);
}
String idxName;
do {
idxName = randomName();
} while (idxMap.containsKey(idxName));
IndexStorageImpl metaStore = storeMap.get(cacheId);
if (metaStore == null) {
PageLockTrackerManager pageLockTrackerManager = mock(PageLockTrackerManager.class);
when(pageLockTrackerManager.createPageLockTracker(anyString())).thenReturn(NOOP_LSNR);
metaStore = new IndexStorageImpl("indexStorageTree", mem, null, new AtomicLong(), cacheId, false, PageIdAllocator.INDEX_PARTITION, PageMemory.FLAG_IDX, null, mem.allocatePage(cacheId, PageIdAllocator.INDEX_PARTITION, PageMemory.FLAG_IDX), true, null, pageLockTrackerManager);
storeMap.put(cacheId, metaStore);
}
final RootPage rootPage = metaStore.allocateIndex(idxName);
assertTrue(rootPage.isAllocated());
idxMap.put(idxName, rootPage);
}
for (int cacheId : cacheIds) {
Map<String, RootPage> idxMap = allocatedIdxs.get(cacheId);
for (Map.Entry<String, RootPage> entry : idxMap.entrySet()) {
String idxName = entry.getKey();
FullPageId rootPageId = entry.getValue().pageId();
final RootPage rootPage = storeMap.get(cacheId).allocateIndex(idxName);
assertEquals("Invalid root page ID restored [cacheId=" + cacheId + ", idxName=" + idxName + ']', rootPageId, rootPage.pageId());
assertFalse("Root page already allocated [cacheId=" + cacheId + ", idxName=" + idxName + ']', rootPage.isAllocated());
}
}
} finally {
mem.stop(true);
}
}
use of org.apache.ignite.internal.pagemem.PageMemory in project ignite by apache.
the class BPlusTreeSelfTest method createPageMemory.
/**
* @return Page memory.
*/
protected PageMemory createPageMemory() throws Exception {
DataRegionConfiguration plcCfg = new DataRegionConfiguration().setInitialSize(1024 * MB).setMaxSize(1024 * MB);
PageMemory pageMem = new PageMemoryNoStoreImpl(log, new UnsafeMemoryProvider(log), null, PAGE_SIZE, plcCfg, new DataRegionMetricsImpl(plcCfg, new GridTestKernalContext(log())), true);
pageMem.start();
return pageMem;
}
use of org.apache.ignite.internal.pagemem.PageMemory in project ignite by apache.
the class PageMemoryNoLoadSelfTest method testLoadedPagesCount.
/**
* @throws Exception If failed.
*/
@Test
public void testLoadedPagesCount() throws Exception {
PageMemory mem = memory();
mem.start();
int expPages = MAX_MEMORY_SIZE / mem.systemPageSize();
try {
for (int i = 0; i < expPages * 2; i++) allocatePage(mem);
} catch (IgniteOutOfMemoryException e) {
e.printStackTrace();
// Expected.
assertEquals(mem.loadedPages(), expPages);
} finally {
mem.stop(true);
}
}
Aggregations