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);
}
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);
}
}
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);
}
}
Aggregations