use of org.apache.ignite.internal.processors.cache.persistence.DataRegion in project ignite by apache.
the class ClusterNodeMetricsSelfTest method testAllocatedMemory.
/**
* @throws Exception If failed.
*/
@Test
public void testAllocatedMemory() throws Exception {
IgniteEx ignite = grid();
final IgniteCache cache = ignite.getOrCreateCache(CACHE_NAME);
DataRegion dataRegion = getDefaultDataRegion(ignite);
DataRegionMetricsImpl memMetrics = dataRegion.metrics();
memMetrics.enableMetrics();
int pageSize = getPageSize(ignite);
assertEquals(dataRegion.pageMemory().loadedPages(), memMetrics.getTotalAllocatedPages());
fillCache(cache);
assertTrue(memMetrics.getTotalAllocatedPages() * pageSize > MAX_VALS_AMOUNT * VAL_SIZE);
}
use of org.apache.ignite.internal.processors.cache.persistence.DataRegion in project ignite by apache.
the class IndexPagesMetricsPersistentTest method validateIdxPagesCnt.
/**
* {@inheritDoc}
*/
@Override
void validateIdxPagesCnt() throws IgniteCheckedException {
DataRegion dataRegion = defaultDataRegion();
DataRegionMetricsImpl dataRegionMetrics = dataRegion.metrics();
long totalIdxPages = 0;
for (IgniteInternalCache<?, ?> cache : gridCacheProcessor().caches()) {
int grpId = cache.context().groupId();
long idxPages = indexPageCounter.countIdxPagesInMemory(grpId);
PageMetrics metrics = dataRegionMetrics.cacheGrpPageMetrics(grpId);
assertThat(metrics.indexPages().value(), is(idxPages));
totalIdxPages += idxPages;
}
assertThat(dataRegionMetrics.pageMetrics().indexPages().value(), is(totalIdxPages));
}
use of org.apache.ignite.internal.processors.cache.persistence.DataRegion in project ignite by apache.
the class IndexPageCounter method countIdxPagesInMemory.
/**
* Returns the number of index pages residing inside the Page Memory of the given cache group.
*/
long countIdxPagesInMemory(int grpId) throws IgniteCheckedException {
DataRegion dataRegion = grid.context().cache().context().database().dataRegion(null);
PageMemory pageMemory = dataRegion.pageMemory();
long idxPageCnt = 0;
for (int i = 0; i < pageMemory.loadedPages(); i++) {
long pageId = PageIdUtils.pageId(PageIdAllocator.INDEX_PARTITION, (byte) 0, i);
if (persistenceEnabled) {
// if persistence is enabled, avoid loading a displaced page into memory
PageMemoryImpl pageMemoryImpl = (PageMemoryImpl) dataRegion.pageMemory();
if (!pageMemoryImpl.hasLoadedPage(new FullPageId(pageId, grpId)))
continue;
}
long pageAddr = pageMemory.acquirePage(grpId, pageId);
try {
long pageReadAddr = pageMemory.readLockForce(grpId, pageId, pageAddr);
try {
// check the rotation ID in case a page was freed (its page type does not get overwritten)
long rotationId = PageIdUtils.rotationId(PageIO.getPageId(pageReadAddr));
long prevRotationId = pageIdToRotationId.computeIfAbsent(pageId, id -> rotationId);
if (prevRotationId == rotationId && PageIO.isIndexPage(PageIO.getType(pageReadAddr)))
idxPageCnt += 1;
} finally {
pageMemory.readUnlock(grpId, pageId, pageAddr);
}
} finally {
pageMemory.releasePage(grpId, pageId, pageAddr);
}
}
return idxPageCnt;
}
use of org.apache.ignite.internal.processors.cache.persistence.DataRegion in project ignite by apache.
the class IndexPagesMetricsPageDisplacementTest method touchIdxPages.
/**
* Acquires all pages inside the index partition for the given cache group in order to load them back into
* memory if some of them had been displaced to the storage earlier.
*/
private void touchIdxPages(int grpId) throws IgniteCheckedException {
DataRegion dataRegion = grid.context().cache().context().database().dataRegion(null);
PageMemory pageMemory = dataRegion.pageMemory();
for (long pageId : getIdxPagesOnDisk(grpId)) // acquire, but not release all pages, so that they don't get displaced back to the storage
pageMemory.acquirePage(grpId, pageId);
}
Aggregations