use of org.apache.ignite.internal.processors.cache.persistence.tree.io.PageMetaIO 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 = pageMem.metaPageId(grpId);
long metaPage = pageMem.acquirePage(grpId, metaId);
try {
final long pageAddr = pageMem.writeLock(grpId, metaId, metaPage);
boolean allocated = false;
try {
long metastoreRoot, reuseListRoot;
if (PageIO.getType(pageAddr) != PageIO.T_META) {
PageMetaIO pageIO = PageMetaIO.VERSIONS.latest();
pageIO.initNewPage(pageAddr, metaId, pageMem.pageSize());
metastoreRoot = pageMem.allocatePage(grpId, PageIdAllocator.INDEX_PARTITION, PageMemory.FLAG_IDX);
reuseListRoot = pageMem.allocatePage(grpId, PageIdAllocator.INDEX_PARTITION, PageMemory.FLAG_IDX);
pageIO.setTreeRoot(pageAddr, metastoreRoot);
pageIO.setReuseListRoot(pageAddr, reuseListRoot);
if (PageHandler.isWalDeltaRecordNeeded(pageMem, grpId, metaId, metaPage, wal, null))
wal.log(new MetaPageInitRecord(grpId, metaId, pageIO.getType(), pageIO.getVersion(), metastoreRoot, reuseListRoot));
allocated = true;
} else {
PageMetaIO pageIO = PageIO.getPageIO(pageAddr);
metastoreRoot = pageIO.getTreeRoot(pageAddr);
reuseListRoot = pageIO.getReuseListRoot(pageAddr);
assert reuseListRoot != 0L;
}
return new Metas(new RootPage(new FullPageId(metastoreRoot, grpId), allocated), new RootPage(new FullPageId(reuseListRoot, grpId), allocated));
} finally {
pageMem.writeUnlock(grpId, metaId, metaPage, null, allocated);
}
} finally {
pageMem.releasePage(grpId, metaId, metaPage);
}
}
use of org.apache.ignite.internal.processors.cache.persistence.tree.io.PageMetaIO in project ignite by apache.
the class GridCacheOffheapManager method saveMeta.
/**
* @param ctx Context.
*/
private void saveMeta(Context ctx) throws IgniteCheckedException {
int grpId = grp.groupId();
PageMemoryEx pageMem = (PageMemoryEx) grp.dataRegion().pageMemory();
IgniteWriteAheadLogManager wal = this.ctx.wal();
long metaPageId = pageMem.metaPageId(grpId);
long metaPage = pageMem.acquirePage(grpId, metaPageId);
try {
long metaPageAddr = pageMem.writeLock(grpId, metaPageId, metaPage);
try {
PageMetaIO metaIo = PageMetaIO.getPageIO(metaPageAddr);
long nextSnapshotTag = metaIo.getNextSnapshotTag(metaPageAddr);
metaIo.setNextSnapshotTag(metaPageAddr, nextSnapshotTag + 1);
if (log != null && log.isDebugEnabled())
log.debug("Save next snapshot before checkpoint start for grId = " + grpId + ", nextSnapshotTag = " + nextSnapshotTag);
if (PageHandler.isWalDeltaRecordNeeded(pageMem, grpId, metaPageId, metaPage, wal, null))
wal.log(new MetaPageUpdateNextSnapshotId(grpId, metaPageId, nextSnapshotTag + 1));
addPartition(null, ctx.partitionStatMap(), metaPageAddr, metaIo, grpId, PageIdAllocator.INDEX_PARTITION, this.ctx.pageStore().pages(grpId, PageIdAllocator.INDEX_PARTITION), -1);
} finally {
pageMem.writeUnlock(grpId, metaPageId, metaPage, null, true);
}
} finally {
pageMem.releasePage(grpId, metaPageId, metaPage);
}
}
Aggregations