use of org.apache.ignite.internal.pagememory.PageMemory in project ignite-3 by apache.
the class PageMemoryNoLoadSelfTest method testLoadedPagesCount.
@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) {
log.error(e.getMessage(), e);
// Expected.
assertEquals(mem.loadedPages(), expPages);
} finally {
mem.stop(true);
}
}
use of org.apache.ignite.internal.pagememory.PageMemory in project ignite-3 by apache.
the class PageMemoryNoLoadSelfTest method testPageTearingSequential.
@Test
public void testPageTearingSequential() throws Exception {
PageMemory mem = memory();
mem.start();
try {
int pagesCnt = 1024;
List<FullPageId> pages = new ArrayList<>(pagesCnt);
for (int i = 0; i < pagesCnt; i++) {
FullPageId fullId = allocatePage(mem);
pages.add(fullId);
long page = mem.acquirePage(fullId.groupId(), fullId.pageId());
try {
if (i % 64 == 0) {
log.info("Writing page [idx=" + i + ", pageId=" + fullId.pageId() + ", page=" + page + ']');
}
writePage(mem, fullId, page, i + 1);
} finally {
mem.releasePage(fullId.groupId(), fullId.pageId(), page);
}
}
for (int i = 0; i < pagesCnt; i++) {
FullPageId fullId = pages.get(i);
long page = mem.acquirePage(fullId.groupId(), fullId.pageId());
try {
if (i % 64 == 0) {
log.info("Reading page [idx=" + i + ", pageId=" + fullId.pageId() + ", page=" + page + ']');
}
readPage(mem, fullId.pageId(), page, i + 1);
} finally {
mem.releasePage(fullId.groupId(), fullId.pageId(), page);
}
}
} finally {
mem.stop(true);
}
}
use of org.apache.ignite.internal.pagememory.PageMemory in project ignite-3 by apache.
the class PageMemoryNoLoadSelfTest method memory.
/**
* Creates new page memory instance.
*
* @return Page memory implementation.
* @throws Exception If failed.
*/
protected PageMemory memory() throws Exception {
dataRegionCfg.change(cfg -> cfg.convert(PageMemoryDataRegionChange.class).changePageSize(PAGE_SIZE).changeInitSize(MAX_MEMORY_SIZE).changeMaxSize(MAX_MEMORY_SIZE)).get(1, SECONDS);
DirectMemoryProvider provider = new UnsafeMemoryProvider(null);
PageIoRegistry ioRegistry = new PageIoRegistry();
ioRegistry.loadFromServiceLoader();
return new PageMemoryNoStoreImpl(provider, (PageMemoryDataRegionConfiguration) fixConfiguration(dataRegionCfg), ioRegistry);
}
use of org.apache.ignite.internal.pagememory.PageMemory in project ignite-3 by apache.
the class PageMemoryNoLoadSelfTest method testPageTearingInner.
@Test
public void testPageTearingInner() throws Exception {
PageMemory mem = memory();
mem.start();
try {
FullPageId fullId1 = allocatePage(mem);
FullPageId fullId2 = allocatePage(mem);
long page1 = mem.acquirePage(fullId1.groupId(), fullId1.pageId());
try {
long page2 = mem.acquirePage(fullId2.groupId(), fullId2.pageId());
log.info("Allocated pages [page1Id=" + fullId1.pageId() + ", page1=" + page1 + ", page2Id=" + fullId2.pageId() + ", page2=" + page2 + ']');
try {
writePage(mem, fullId1, page1, 1);
writePage(mem, fullId2, page2, 2);
readPage(mem, fullId1.pageId(), page1, 1);
readPage(mem, fullId2.pageId(), page2, 2);
// Check read after read.
readPage(mem, fullId1.pageId(), page1, 1);
readPage(mem, fullId2.pageId(), page2, 2);
} finally {
mem.releasePage(fullId2.groupId(), fullId2.pageId(), page2);
}
} finally {
mem.releasePage(fullId1.groupId(), fullId1.pageId(), page1);
}
} finally {
mem.stop(true);
}
}
use of org.apache.ignite.internal.pagememory.PageMemory in project ignite-3 by apache.
the class AbstractFreeListTest method createPageMemory.
private PageMemory createPageMemory(int pageSize) throws Exception {
dataRegionCfg.change(c -> c.convert(PageMemoryDataRegionChange.class).changePageSize(pageSize).changeInitSize(MAX_SIZE).changeMaxSize(MAX_SIZE)).get(1, TimeUnit.SECONDS);
TestPageIoRegistry ioRegistry = new TestPageIoRegistry();
ioRegistry.loadFromServiceLoader();
ioRegistry.load(TestDataPageIo.VERSIONS);
return new PageMemoryNoStoreImpl(new UnsafeMemoryProvider(null), (PageMemoryDataRegionConfiguration) fixConfiguration(dataRegionCfg), ioRegistry);
}
Aggregations