Search in sources :

Example 6 with FullPageId

use of org.apache.ignite.internal.pagemem.FullPageId in project ignite by apache.

the class PageMemoryNoLoadSelfTest method testPageTearingInner.

/**
     * @throws Exception If failed.
     */
public void testPageTearingInner() throws Exception {
    PageMemory mem = memory();
    mem.start();
    try {
        FullPageId fullId1 = allocatePage(mem);
        FullPageId fullId2 = allocatePage(mem);
        long page1 = mem.acquirePage(fullId1.cacheId(), fullId1.pageId());
        try {
            long page2 = mem.acquirePage(fullId2.cacheId(), fullId2.pageId());
            info("Allocated pages [page1Id=" + fullId1.pageId() + ", page1=" + page1 + ", page2Id=" + fullId2.pageId() + ", page2=" + page2 + ']');
            try {
                writePage(mem, fullId1.pageId(), page1, 1);
                writePage(mem, fullId2.pageId(), 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.cacheId(), fullId2.pageId(), page2);
            }
        } finally {
            mem.releasePage(fullId1.cacheId(), fullId1.pageId(), page1);
        }
    } finally {
        mem.stop();
    }
}
Also used : PageMemory(org.apache.ignite.internal.pagemem.PageMemory) FullPageId(org.apache.ignite.internal.pagemem.FullPageId)

Aggregations

FullPageId (org.apache.ignite.internal.pagemem.FullPageId)6 PageMemory (org.apache.ignite.internal.pagemem.PageMemory)5 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 MetadataStorage (org.apache.ignite.internal.processors.cache.database.MetadataStorage)1 RootPage (org.apache.ignite.internal.processors.cache.database.RootPage)1