Search in sources :

Example 11 with FullPageId

use of org.apache.ignite.internal.pagememory.FullPageId in project ignite-3 by apache.

the class ClockPageReplacementPolicy method replace.

/**
 * {@inheritDoc}
 */
@Override
public long replace() throws IgniteInternalCheckedException {
    LoadedPagesMap loadedPages = seg.loadedPages();
    for (int i = 0; i < loadedPages.size(); i++) {
        int pageIdx = flags.poll();
        long relPtr = seg.relative(pageIdx);
        long absPtr = seg.absolute(relPtr);
        FullPageId fullId = fullPageId(absPtr);
        // Check loaded pages map for outdated page.
        relPtr = loadedPages.get(fullId.groupId(), fullId.effectivePageId(), seg.partGeneration(fullId.groupId(), partitionId(fullId.pageId())), INVALID_REL_PTR, OUTDATED_REL_PTR);
        assert relPtr != INVALID_REL_PTR;
        if (relPtr == OUTDATED_REL_PTR) {
            return seg.refreshOutdatedPage(fullId.groupId(), fullId.pageId(), true);
        }
        if (seg.tryToRemovePage(fullId, absPtr)) {
            return relPtr;
        }
        flags.setFlag(pageIdx);
    }
    throw seg.oomException("no pages to replace");
}
Also used : FullPageId(org.apache.ignite.internal.pagememory.FullPageId)

Aggregations

FullPageId (org.apache.ignite.internal.pagememory.FullPageId)11 PageMemory (org.apache.ignite.internal.pagememory.PageMemory)4 BaseIgniteAbstractTest (org.apache.ignite.internal.testframework.BaseIgniteAbstractTest)4 Test (org.junit.jupiter.api.Test)4 ArrayList (java.util.ArrayList)2 ByteBuffer (java.nio.ByteBuffer)1 HashSet (java.util.HashSet)1 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 IgniteOutOfMemoryException (org.apache.ignite.internal.pagememory.mem.IgniteOutOfMemoryException)1