Search in sources :

Example 1 with PageMetrics

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;
}
Also used : DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) PageMemoryNoStoreImpl(org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl) PageMemory(org.apache.ignite.internal.pagemem.PageMemory) PageMetrics(org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMetrics) LongAdderMetric(org.apache.ignite.internal.processors.metric.impl.LongAdderMetric) DataRegionMetricsImpl(org.apache.ignite.internal.processors.cache.persistence.DataRegionMetricsImpl) JavaLogger(org.apache.ignite.logger.java.JavaLogger) UnsafeMemoryProvider(org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider)

Example 2 with PageMetrics

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());
}
Also used : IntHashMap(org.apache.ignite.internal.util.collection.IntHashMap) PageMetrics(org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMetrics)

Example 3 with PageMetrics

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;
    }
}
Also used : PageMetricsImpl(org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMetricsImpl) IntMap(org.apache.ignite.internal.util.collection.IntMap) U(org.apache.ignite.internal.util.typedef.internal.U) PageMemory(org.apache.ignite.internal.pagemem.PageMemory) PageMetrics(org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMetrics) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) GridKernalContext(org.apache.ignite.internal.GridKernalContext) TestOnly(org.jetbrains.annotations.TestOnly) DataRegionMetrics(org.apache.ignite.DataRegionMetrics) Nullable(org.jetbrains.annotations.Nullable) DataRegionMetricsProvider(org.apache.ignite.DataRegionMetricsProvider) LongAdderMetric(org.apache.ignite.internal.processors.metric.impl.LongAdderMetric) AtomicLongMetric(org.apache.ignite.internal.processors.metric.impl.AtomicLongMetric) LongAdderWithDelegateMetric(org.apache.ignite.internal.processors.metric.impl.LongAdderWithDelegateMetric) MetricUtils(org.apache.ignite.internal.processors.metric.impl.MetricUtils) MetricsMxBean(org.apache.ignite.mxbean.MetricsMxBean) Optional(java.util.Optional) HitRateMetric(org.apache.ignite.internal.processors.metric.impl.HitRateMetric) IntHashMap(org.apache.ignite.internal.util.collection.IntHashMap) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IntHashMap(org.apache.ignite.internal.util.collection.IntHashMap) PageMetrics(org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMetrics)

Example 4 with PageMetrics

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();
}
Also used : PageMetrics(org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMetrics)

Example 5 with PageMetrics

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());
    }
}
Also used : PageMetaIO(org.apache.ignite.internal.processors.cache.persistence.tree.io.PageMetaIO) IgniteWriteAheadLogManager(org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager) GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) PageMemory(org.apache.ignite.internal.pagemem.PageMemory) PageMetrics(org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMetrics) MetaPageInitRecord(org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageInitRecord) ReuseListImpl(org.apache.ignite.internal.processors.cache.persistence.tree.reuse.ReuseListImpl) PageMemoryEx(org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryEx) ReuseList(org.apache.ignite.internal.processors.cache.persistence.tree.reuse.ReuseList) DataRegion(org.apache.ignite.internal.processors.cache.persistence.DataRegion)

Aggregations

PageMetrics (org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMetrics)21 DataRegion (org.apache.ignite.internal.processors.cache.persistence.DataRegion)6 PageMemory (org.apache.ignite.internal.pagemem.PageMemory)3 MetaPageInitRecord (org.apache.ignite.internal.pagemem.wal.record.delta.MetaPageInitRecord)3 PageMemoryEx (org.apache.ignite.internal.processors.cache.persistence.pagemem.PageMemoryEx)3 File (java.io.File)2 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)2 FullPageId (org.apache.ignite.internal.pagemem.FullPageId)2 IgniteWriteAheadLogManager (org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager)2 DataRegionMetricsImpl (org.apache.ignite.internal.processors.cache.persistence.DataRegionMetricsImpl)2 PageMetaIO (org.apache.ignite.internal.processors.cache.persistence.tree.io.PageMetaIO)2 LongAdderMetric (org.apache.ignite.internal.processors.metric.impl.LongAdderMetric)2 IntHashMap (org.apache.ignite.internal.util.collection.IntHashMap)2 Optional (java.util.Optional)1 DataRegionMetrics (org.apache.ignite.DataRegionMetrics)1 DataRegionMetricsProvider (org.apache.ignite.DataRegionMetricsProvider)1 Person (org.apache.ignite.client.Person)1 FailureContext (org.apache.ignite.failure.FailureContext)1 GridKernalContext (org.apache.ignite.internal.GridKernalContext)1 IgniteOutOfMemoryException (org.apache.ignite.internal.mem.IgniteOutOfMemoryException)1