use of org.apache.ignite.internal.processors.cache.persistence.tree.io.PageMetaIO in project ignite by apache.
the class GridCacheOffheapManager method addPartitions.
/**
* @param ctx Context.
*/
private void addPartitions(Context ctx) throws IgniteCheckedException {
int grpId = grp.groupId();
PageMemoryEx pageMem = (PageMemoryEx) grp.dataRegion().pageMemory();
long metaPageId = PageMemory.META_PAGE_ID;
long metaPage = pageMem.acquirePage(grpId, metaPageId);
try {
long metaPageAddr = pageMem.writeLock(grpId, metaPageId, metaPage);
if (metaPageAddr == 0L) {
U.warn(log, "Failed to acquire write lock for index meta page [grpId=" + grpId + ", metaPageId=" + metaPageId + ']');
return;
}
boolean changed = false;
try {
PageMetaIO metaIo = PageMetaIO.getPageIO(metaPageAddr);
int pageCnt = this.ctx.pageStore().pages(grpId, PageIdAllocator.INDEX_PARTITION);
changed = metaIo.setCandidatePageCount(metaPageAddr, pageCnt);
// Following method doesn't modify page data, it only reads last allocated page count from it.
addPartition(null, ctx.partitionStatMap(), metaPageAddr, metaIo, grpId, PageIdAllocator.INDEX_PARTITION, pageCnt, -1);
} finally {
pageMem.writeUnlock(grpId, metaPageId, metaPage, null, changed);
}
} finally {
pageMem.releasePage(grpId, metaPageId, metaPage);
}
}
use of org.apache.ignite.internal.processors.cache.persistence.tree.io.PageMetaIO in project ignite by apache.
the class TxLog method init.
/**
* @param ctx Kernal context.
* @throws IgniteCheckedException If failed.
*/
private void init(GridKernalContext ctx) throws IgniteCheckedException {
String txLogName = TX_LOG_CACHE_NAME + "##Tree";
DataRegion txLogDataRegion = mgr.dataRegion(TX_LOG_CACHE_NAME);
GridCacheSharedContext<?, ?> cacheCtx = ctx.cache().context();
if (CU.isPersistenceEnabled(ctx.config())) {
String txLogReuseListName = TX_LOG_CACHE_NAME + "##ReuseList";
mgr.checkpointReadLock();
try {
IgniteWriteAheadLogManager wal = cacheCtx.wal();
PageMemoryEx pageMemory = (PageMemoryEx) txLogDataRegion.pageMemory();
long metaId = PageMemory.META_PAGE_ID;
long metaPage = pageMemory.acquirePage(TX_LOG_CACHE_ID, metaId);
long treeRoot, reuseListRoot;
boolean isNew = false;
try {
long pageAddr = pageMemory.writeLock(TX_LOG_CACHE_ID, metaId, metaPage);
try {
if (PageIO.getType(pageAddr) != PageIO.T_META) {
// Initialize new page.
PageMetaIO io = PageMetaIOV2.VERSIONS.latest();
PageMetrics metrics = txLogDataRegion.metrics().pageMetrics();
io.initNewPage(pageAddr, metaId, pageMemory.pageSize(), metrics);
treeRoot = pageMemory.allocatePage(TX_LOG_CACHE_ID, INDEX_PARTITION, FLAG_IDX);
reuseListRoot = pageMemory.allocatePage(TX_LOG_CACHE_ID, INDEX_PARTITION, FLAG_IDX);
assert PageIdUtils.flag(treeRoot) == FLAG_IDX;
assert PageIdUtils.flag(reuseListRoot) == FLAG_IDX;
io.setTreeRoot(pageAddr, treeRoot);
io.setReuseListRoot(pageAddr, reuseListRoot);
if (PageHandler.isWalDeltaRecordNeeded(pageMemory, TX_LOG_CACHE_ID, metaId, metaPage, wal, null))
assert io.getType() == PageIO.T_META;
wal.log(new MetaPageInitRecord(TX_LOG_CACHE_ID, metaId, io.getType(), io.getVersion(), treeRoot, reuseListRoot));
isNew = true;
} else {
PageMetaIO io = PageIO.getPageIO(pageAddr);
treeRoot = io.getTreeRoot(pageAddr);
reuseListRoot = io.getReuseListRoot(pageAddr);
assert PageIdUtils.flag(treeRoot) == FLAG_IDX : U.hexLong(treeRoot) + ", TX_LOG_CACHE_ID=" + TX_LOG_CACHE_ID;
assert PageIdUtils.flag(reuseListRoot) == FLAG_IDX : U.hexLong(reuseListRoot) + ", TX_LOG_CACHE_ID=" + TX_LOG_CACHE_ID;
}
} finally {
pageMemory.writeUnlock(TX_LOG_CACHE_ID, metaId, metaPage, null, isNew);
}
} finally {
pageMemory.releasePage(TX_LOG_CACHE_ID, metaId, metaPage);
}
reuseList = new ReuseListImpl(TX_LOG_CACHE_ID, txLogReuseListName, pageMemory, wal, reuseListRoot, isNew, cacheCtx.diagnostic().pageLockTracker(), ctx, null, FLAG_IDX);
tree = new TxLogTree(TX_LOG_CACHE_NAME, pageMemory, wal, treeRoot, reuseList, ctx.failure(), isNew, cacheCtx.diagnostic().pageLockTracker());
((GridCacheDatabaseSharedManager) mgr).addCheckpointListener(this, txLogDataRegion);
} finally {
mgr.checkpointReadUnlock();
}
} else {
PageMemory pageMemory = txLogDataRegion.pageMemory();
ReuseList reuseList1 = mgr.reuseList(TX_LOG_CACHE_NAME);
long treeRoot;
if ((treeRoot = reuseList1.takeRecycledPage()) == 0L)
treeRoot = pageMemory.allocatePage(TX_LOG_CACHE_ID, INDEX_PARTITION, FLAG_IDX);
tree = new TxLogTree(txLogName, pageMemory, null, treeRoot, reuseList1, ctx.failure(), true, cacheCtx.diagnostic().pageLockTracker());
}
}
use of org.apache.ignite.internal.processors.cache.persistence.tree.io.PageMetaIO in project ignite by apache.
the class MetaPageInitRecord method applyDelta.
/**
* {@inheritDoc}
*/
@Override
public void applyDelta(PageMemory pageMem, long pageAddr) throws IgniteCheckedException {
PageMetaIO io = PageMetaIO.getPageIO(ioType, ioVer);
PageMetrics metrics = pageMem.metrics().cacheGrpPageMetrics(groupId());
io.initNewPage(pageAddr, newPageId, pageMem.realPageSize(groupId()), metrics);
io.setTreeRoot(pageAddr, treeRoot);
io.setReuseListRoot(pageAddr, reuseListRoot);
}
use of org.apache.ignite.internal.processors.cache.persistence.tree.io.PageMetaIO in project ignite by apache.
the class MetaPageUpdateLastSuccessfulFullSnapshotId method applyDelta.
/**
* {@inheritDoc}
*/
@Override
public void applyDelta(PageMemory pageMem, long pageAddr) throws IgniteCheckedException {
PageMetaIO io = PageMetaIO.VERSIONS.forPage(pageAddr);
io.setLastSuccessfulFullSnapshotId(pageAddr, lastSuccessfulFullSnapshotId);
}
use of org.apache.ignite.internal.processors.cache.persistence.tree.io.PageMetaIO in project ignite by apache.
the class MetaPageUpdateLastAllocatedIndex method applyDelta.
/**
* {@inheritDoc}
*/
@Override
public void applyDelta(PageMemory pageMem, long pageAddr) throws IgniteCheckedException {
int type = PageIO.getType(pageAddr);
assert type == PageIO.T_META || type == PageIO.T_PART_META;
PageMetaIO io = PageIO.getPageIO(type, PageIO.getVersion(pageAddr));
io.setLastAllocatedPageCount(pageAddr, lastAllocatedIdx);
}
Aggregations