use of org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMetrics in project ignite by apache.
the class BPlusTreeBenchmark method createPageMemory.
/**
* @return Page memory.
*/
private PageMemory createPageMemory() {
DataRegionConfiguration dataRegionConfiguration = new DataRegionConfiguration().setMaxSize(1024 * MB);
DataRegionMetricsImpl dataRegionMetrics = mock(DataRegionMetricsImpl.class);
PageMetrics pageMetrics = mock(PageMetrics.class);
LongAdderMetric noOpMetric = new LongAdderMetric("foobar", null);
when(dataRegionMetrics.cacheGrpPageMetrics(anyInt())).thenReturn(pageMetrics);
when(pageMetrics.totalPages()).thenReturn(noOpMetric);
when(pageMetrics.indexPages()).thenReturn(noOpMetric);
PageMemory pageMem = new PageMemoryNoStoreImpl(new JavaLogger(), new UnsafeMemoryProvider(new JavaLogger()), null, PAGE_SIZE, dataRegionConfiguration, dataRegionMetrics, false);
pageMem.start();
return pageMem;
}
use of org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMetrics in project ignite by apache.
the class DataRegionMetricsImpl method removeCacheGrpPageMetrics.
/**
* Removes all memory page metrics associated with the given cache group.
*/
public void removeCacheGrpPageMetrics(Integer grpId) {
PageMetrics rmvMetrics;
synchronized (cacheGrpMetricsLock) {
IntMap<PageMetrics> copy = new IntHashMap<>(cacheGrpMetrics);
rmvMetrics = copy.remove(grpId);
cacheGrpMetrics = copy;
}
// (it hasn't been done in previous implementations)
if (rmvMetrics != null)
dataRegionPageMetrics.indexPages().add(-rmvMetrics.indexPages().value());
}
use of org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMetrics in project ignite by apache.
the class DataRegionMetricsImpl method cacheGrpPageMetrics.
/**
* Returns memory page metrics associated with the given cache group.
*/
public PageMetrics cacheGrpPageMetrics(int cacheGrpId) {
PageMetrics pageMetrics = cacheGrpMetrics.get(cacheGrpId);
if (pageMetrics != null)
return pageMetrics;
synchronized (cacheGrpMetricsLock) {
IntMap<PageMetrics> localCacheGrpMetrics = cacheGrpMetrics;
// double check
PageMetrics doubleCheckPageMetrics = localCacheGrpMetrics.get(cacheGrpId);
if (doubleCheckPageMetrics != null)
return doubleCheckPageMetrics;
IntMap<PageMetrics> copy = new IntHashMap<>(localCacheGrpMetrics);
PageMetrics newMetrics = Optional.of(kernalCtx).map(GridKernalContext::cache).map(cache -> cache.cacheGroupDescriptors().get(cacheGrpId)).map(decs -> createCacheGrpPageMetrics(decs.cacheOrGroupName())).orElse(dataRegionPageMetrics);
copy.put(cacheGrpId, newMetrics);
cacheGrpMetrics = copy;
return newMetrics;
}
}
use of org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMetrics in project ignite by apache.
the class DataRegionMetricsImpl method clear.
/**
* Clear metrics.
*/
public void clear() {
largeEntriesPages.reset();
dirtyPages.reset();
readPages.reset();
writtenPages.reset();
replacedPages.reset();
offHeapSize.reset();
checkpointBufSize.reset();
allocRate.reset();
evictRate.reset();
pageReplaceRate.reset();
pageReplaceAge.reset();
dataRegionPageMetrics.reset();
for (PageMetrics metrics : cacheGrpMetrics.values()) metrics.reset();
}
use of org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMetrics 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());
}
}
Aggregations