Search in sources :

Example 1 with PageMetaIOV2

use of org.apache.ignite.internal.processors.cache.persistence.tree.io.PageMetaIOV2 in project ignite by apache.

the class MetaPageUpdateIndexDataRecord method applyDelta.

/**
 * {@inheritDoc}
 */
@Override
public void applyDelta(PageMemory pageMem, long pageAddr) throws IgniteCheckedException {
    if (PageIO.getVersion(pageAddr) < 2)
        ((PageMetaIOV2) PageMetaIOV2.VERSIONS.latest()).upgradePage(pageAddr);
    PageMetaIOV2 io = (PageMetaIOV2) PageMetaIOV2.VERSIONS.forPage(pageAddr);
    io.setEncryptedPageIndex(pageAddr, encryptPageIdx);
    io.setEncryptedPageCount(pageAddr, encryptPageCnt);
}
Also used : PageMetaIOV2(org.apache.ignite.internal.processors.cache.persistence.tree.io.PageMetaIOV2)

Example 2 with PageMetaIOV2

use of org.apache.ignite.internal.processors.cache.persistence.tree.io.PageMetaIOV2 in project ignite by apache.

the class GridCacheOffheapManager method getOrAllocateCacheMetas.

/**
 * @return Meta root pages info.
 * @throws IgniteCheckedException If failed.
 */
private Metas getOrAllocateCacheMetas() throws IgniteCheckedException {
    PageMemoryEx pageMem = (PageMemoryEx) grp.dataRegion().pageMemory();
    IgniteWriteAheadLogManager wal = ctx.wal();
    int grpId = grp.groupId();
    long metaId = PageMemory.META_PAGE_ID;
    long metaPage = pageMem.acquirePage(grpId, metaId);
    try {
        long pageAddr = pageMem.writeLock(grpId, metaId, metaPage);
        boolean allocated = false;
        boolean markDirty = false;
        try {
            long metastoreRoot, reuseListRoot;
            PageMetaIOV2 io = (PageMetaIOV2) PageMetaIO.VERSIONS.latest();
            if (PageIO.getType(pageAddr) != PageIO.T_META) {
                PageMetrics metrics = pageMem.metrics().cacheGrpPageMetrics(grpId);
                io.initNewPage(pageAddr, metaId, pageMem.realPageSize(grpId), metrics);
                metastoreRoot = pageMem.allocatePage(grpId, PageIdAllocator.INDEX_PARTITION, PageMemory.FLAG_IDX);
                reuseListRoot = pageMem.allocatePage(grpId, PageIdAllocator.INDEX_PARTITION, PageMemory.FLAG_IDX);
                io.setTreeRoot(pageAddr, metastoreRoot);
                io.setReuseListRoot(pageAddr, reuseListRoot);
                if (isWalDeltaRecordNeeded(pageMem, grpId, metaId, metaPage, wal, null)) {
                    assert io.getType() == PageIO.T_META;
                    wal.log(new MetaPageInitRecord(grpId, metaId, io.getType(), io.getVersion(), metastoreRoot, reuseListRoot));
                }
                allocated = true;
            } else {
                if (io != PageIO.getPageIO(pageAddr)) {
                    if (log.isDebugEnabled()) {
                        log.debug("Upgrade index partition meta page version: [grpId=" + grpId + ", oldVer=" + PagePartitionMetaIO.getVersion(pageAddr) + ", newVer=" + io.getVersion() + ']');
                    }
                    io.upgradePage(pageAddr);
                    markDirty = true;
                }
                metastoreRoot = io.getTreeRoot(pageAddr);
                reuseListRoot = io.getReuseListRoot(pageAddr);
                int encrPageCnt = io.getEncryptedPageCount(pageAddr);
                if (encrPageCnt > 0) {
                    ctx.kernalContext().encryption().setEncryptionState(grp, PageIdAllocator.INDEX_PARTITION, io.getEncryptedPageIndex(pageAddr), encrPageCnt);
                    markDirty = true;
                }
                assert reuseListRoot != 0L;
                if (markDirty && isWalDeltaRecordNeeded(pageMem, grpId, metaId, metaPage, wal, null)) {
                    wal.log(new PageSnapshot(new FullPageId(PageIdAllocator.INDEX_PARTITION, grpId), pageAddr, pageMem.pageSize(), pageMem.realPageSize(grpId)));
                }
            }
            return new Metas(new RootPage(new FullPageId(metastoreRoot, grpId), allocated), new RootPage(new FullPageId(reuseListRoot, grpId), allocated), null, null);
        } finally {
            pageMem.writeUnlock(grpId, metaId, metaPage, null, allocated || markDirty);
        }
    } finally {
        pageMem.releasePage(grpId, metaId, metaPage);
    }
}
Also used : IgniteWriteAheadLogManager(org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager) PageMetaIOV2(org.apache.ignite.internal.processors.cache.persistence.tree.io.PageMetaIOV2) PageMetrics(org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMetrics) MetaPageInitRecord(org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageInitRecord) PageMemoryEx(org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryEx) PageSnapshot(org.apache.ignite.internal.pagemem.wal.record.PageSnapshot) FullPageId(org.apache.ignite.internal.pagemem.FullPageId)

Example 3 with PageMetaIOV2

use of org.apache.ignite.internal.processors.cache.persistence.tree.io.PageMetaIOV2 in project ignite by apache.

the class GridCacheOffheapManager method saveIndexReencryptionStatus.

/**
 * @param grpId Cache group ID.
 * @throws IgniteCheckedException If failed.
 */
private void saveIndexReencryptionStatus(int grpId) throws IgniteCheckedException {
    long state = ctx.kernalContext().encryption().getEncryptionState(grpId, PageIdAllocator.INDEX_PARTITION);
    if (state == 0)
        return;
    PageMemoryEx pageMem = (PageMemoryEx) grp.dataRegion().pageMemory();
    long metaPageId = PageIdAllocator.META_PAGE_ID;
    long metaPage = pageMem.acquirePage(grpId, metaPageId);
    try {
        boolean changed = false;
        long metaPageAddr = pageMem.writeLock(grpId, metaPageId, metaPage);
        try {
            PageMetaIOV2 metaIo = PageMetaIO.getPageIO(metaPageAddr);
            int encryptIdx = ReencryptStateUtils.pageIndex(state);
            int encryptCnt = ReencryptStateUtils.pageCount(state);
            if (encryptIdx == encryptCnt) {
                ctx.kernalContext().encryption().setEncryptionState(grp, PageIdAllocator.INDEX_PARTITION, 0, 0);
                encryptIdx = encryptCnt = 0;
            }
            changed |= metaIo.setEncryptedPageIndex(metaPageAddr, encryptIdx);
            changed |= metaIo.setEncryptedPageCount(metaPageAddr, encryptCnt);
            IgniteWriteAheadLogManager wal = ctx.cache().context().wal();
            if (changed && PageHandler.isWalDeltaRecordNeeded(pageMem, grpId, metaPageId, metaPage, wal, null))
                wal.log(new MetaPageUpdateIndexDataRecord(grpId, metaPageId, encryptIdx, encryptCnt));
        } finally {
            pageMem.writeUnlock(grpId, metaPageId, metaPage, null, changed);
        }
    } finally {
        pageMem.releasePage(grpId, metaPageId, metaPage);
    }
}
Also used : MetaPageUpdateIndexDataRecord(org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageUpdateIndexDataRecord) IgniteWriteAheadLogManager(org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager) PageMetaIOV2(org.apache.ignite.internal.processors.cache.persistence.tree.io.PageMetaIOV2) PageMemoryEx(org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryEx)

Aggregations

PageMetaIOV2 (org.apache.ignite.internal.processors.cache.persistence.tree.io.PageMetaIOV2)3 IgniteWriteAheadLogManager (org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager)2 PageMemoryEx (org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryEx)2 FullPageId (org.apache.ignite.internal.pagemem.FullPageId)1 PageSnapshot (org.apache.ignite.internal.pagemem.wal.record.PageSnapshot)1 MetaPageInitRecord (org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageInitRecord)1 MetaPageUpdateIndexDataRecord (org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageUpdateIndexDataRecord)1 PageMetrics (org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMetrics)1