Search in sources :

Example 1 with PageLockTrackerManager

use of org.apache.ignite.internal.processors.cache.persistence.diagnostic.pagelocktracker.PageLockTrackerManager in project ignite by apache.

the class CacheDiagnosticManager method start0.

/**
 * {@inheritDoc}
 */
@Override
protected void start0() throws IgniteCheckedException {
    super.start0();
    String name = U.maskForFileName(cctx.kernalContext().pdsFolderResolver().resolveFolders().consistentId().toString());
    pageLockTrackerManager = new PageLockTrackerManager(log, name);
    pageLockTrackerManager.start();
    registerMetricsMBean(cctx.gridConfig(), MBEAN_GROUP, PageLockTrackerMXBean.MBEAN_NAME, pageLockTrackerManager.mxBean(), PageLockTrackerMXBean.class);
}
Also used : PageLockTrackerManager(org.apache.ignite.internal.processors.cache.persistence.diagnostic.pagelocktracker.PageLockTrackerManager)

Example 2 with PageLockTrackerManager

use of org.apache.ignite.internal.processors.cache.persistence.diagnostic.pagelocktracker.PageLockTrackerManager in project ignite by apache.

the class BPlusTreeReuseSelfTest method createReuseList.

/**
 * {@inheritDoc}
 */
@Override
protected ReuseList createReuseList(int cacheId, PageMemory pageMem, long rootId, boolean initNew) throws IgniteCheckedException {
    PageLockTrackerManager pageLockTrackerManager = mock(PageLockTrackerManager.class);
    when(pageLockTrackerManager.createPageLockTracker(anyString())).thenReturn(new TestPageLockListener());
    return new TestReuseList(cacheId, "test", pageMem, rootId, pageLockTrackerManager, new GridTestKernalContext(log), initNew);
}
Also used : GridTestKernalContext(org.apache.ignite.testframework.junits.GridTestKernalContext) PageLockTrackerManager(org.apache.ignite.internal.processors.cache.persistence.diagnostic.pagelocktracker.PageLockTrackerManager)

Example 3 with PageLockTrackerManager

use of org.apache.ignite.internal.processors.cache.persistence.diagnostic.pagelocktracker.PageLockTrackerManager in project ignite by apache.

the class CacheFreeListSelfTest method createFreeList.

/**
 * @param pageSize Page size.
 * @return Free list.
 * @throws Exception If failed.
 */
private FreeList<CacheDataRow> createFreeList(int pageSize) throws Exception {
    DataRegionConfiguration plcCfg = new DataRegionConfiguration().setInitialSize(1024 * MB).setMaxSize(1024 * MB);
    pageMem = createPageMemory(pageSize, plcCfg);
    long metaPageId = pageMem.allocatePage(1, 1, PageIdAllocator.FLAG_DATA);
    IgniteConfiguration cfg = new IgniteConfiguration().setMetricExporterSpi(new NoopMetricExporterSpi());
    GridTestKernalContext ctx = new GridTestKernalContext(new GridTestLog4jLogger(), cfg);
    ctx.add(new GridMetricManager(ctx));
    ctx.add(new PerformanceStatisticsProcessor(ctx));
    DataRegionMetricsImpl regionMetrics = new DataRegionMetricsImpl(plcCfg, ctx);
    DataRegion dataRegion = new DataRegion(pageMem, plcCfg, regionMetrics, new NoOpPageEvictionTracker());
    PageLockTrackerManager pageLockTrackerManager = mock(PageLockTrackerManager.class);
    when(pageLockTrackerManager.createPageLockTracker(anyString())).thenReturn(PageLockTrackerManager.NOOP_LSNR);
    return new CacheFreeList(1, "freelist", dataRegion, null, metaPageId, true, pageLockTrackerManager, new GridTestKernalContext(log), null, PageIdAllocator.FLAG_IDX);
}
Also used : GridTestKernalContext(org.apache.ignite.testframework.junits.GridTestKernalContext) CacheFreeList(org.apache.ignite.internal.processors.cache.persistence.freelist.CacheFreeList) DataRegionMetricsImpl(org.apache.ignite.internal.processors.cache.persistence.DataRegionMetricsImpl) PageLockTrackerManager(org.apache.ignite.internal.processors.cache.persistence.diagnostic.pagelocktracker.PageLockTrackerManager) PerformanceStatisticsProcessor(org.apache.ignite.internal.processors.performancestatistics.PerformanceStatisticsProcessor) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) NoOpPageEvictionTracker(org.apache.ignite.internal.processors.cache.persistence.evict.NoOpPageEvictionTracker) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) NoopMetricExporterSpi(org.apache.ignite.spi.metric.noop.NoopMetricExporterSpi) GridMetricManager(org.apache.ignite.internal.processors.metric.GridMetricManager) GridTestLog4jLogger(org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger) DataRegion(org.apache.ignite.internal.processors.cache.persistence.DataRegion)

Example 4 with PageLockTrackerManager

use of org.apache.ignite.internal.processors.cache.persistence.diagnostic.pagelocktracker.PageLockTrackerManager in project ignite by apache.

the class IndexStorageSelfTest method metaAllocation.

/**
 * @throws Exception If failed.
 */
private void metaAllocation() throws Exception {
    PageMemory mem = memory(true);
    int[] cacheIds = new int[] { 1, "partitioned".hashCode(), "replicated".hashCode() };
    Map<Integer, Map<String, RootPage>> allocatedIdxs = new HashMap<>();
    mem.start();
    try {
        final Map<Integer, IndexStorageImpl> storeMap = new HashMap<>();
        for (int i = 0; i < 1_000; i++) {
            int cacheId = cacheIds[i % cacheIds.length];
            Map<String, RootPage> idxMap = allocatedIdxs.get(cacheId);
            if (idxMap == null) {
                idxMap = new HashMap<>();
                allocatedIdxs.put(cacheId, idxMap);
            }
            String idxName;
            do {
                idxName = randomName();
            } while (idxMap.containsKey(idxName));
            IndexStorageImpl metaStore = storeMap.get(cacheId);
            if (metaStore == null) {
                PageLockTrackerManager pageLockTrackerManager = mock(PageLockTrackerManager.class);
                when(pageLockTrackerManager.createPageLockTracker(anyString())).thenReturn(NOOP_LSNR);
                metaStore = new IndexStorageImpl("indexStorageTree", mem, null, new AtomicLong(), cacheId, false, PageIdAllocator.INDEX_PARTITION, PageMemory.FLAG_IDX, null, mem.allocatePage(cacheId, PageIdAllocator.INDEX_PARTITION, PageMemory.FLAG_IDX), true, null, pageLockTrackerManager);
                storeMap.put(cacheId, metaStore);
            }
            final RootPage rootPage = metaStore.allocateIndex(idxName);
            assertTrue(rootPage.isAllocated());
            idxMap.put(idxName, rootPage);
        }
        for (int cacheId : cacheIds) {
            Map<String, RootPage> idxMap = allocatedIdxs.get(cacheId);
            for (Map.Entry<String, RootPage> entry : idxMap.entrySet()) {
                String idxName = entry.getKey();
                FullPageId rootPageId = entry.getValue().pageId();
                final RootPage rootPage = storeMap.get(cacheId).allocateIndex(idxName);
                assertEquals("Invalid root page ID restored [cacheId=" + cacheId + ", idxName=" + idxName + ']', rootPageId, rootPage.pageId());
                assertFalse("Root page already allocated [cacheId=" + cacheId + ", idxName=" + idxName + ']', rootPage.isAllocated());
            }
        }
    } finally {
        mem.stop(true);
    }
}
Also used : IndexStorageImpl(org.apache.ignite.internal.processors.cache.persistence.IndexStorageImpl) HashMap(java.util.HashMap) PageMemory(org.apache.ignite.internal.pagemem.PageMemory) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) PageLockTrackerManager(org.apache.ignite.internal.processors.cache.persistence.diagnostic.pagelocktracker.PageLockTrackerManager) AtomicLong(java.util.concurrent.atomic.AtomicLong) RootPage(org.apache.ignite.internal.processors.cache.persistence.RootPage) HashMap(java.util.HashMap) Map(java.util.Map) FullPageId(org.apache.ignite.internal.pagemem.FullPageId)

Example 5 with PageLockTrackerManager

use of org.apache.ignite.internal.processors.cache.persistence.diagnostic.pagelocktracker.PageLockTrackerManager in project ignite by apache.

the class BPlusTreeReplaceRemoveRaceTest method beforeTest.

/**
 * {@inheritDoc}
 */
@Override
protected void beforeTest() throws Exception {
    pageMem = createPageMemory();
    lockTrackerManager = new PageLockTrackerManager(log, "testTreeManager");
    lockTrackerManager.start();
}
Also used : PageLockTrackerManager(org.apache.ignite.internal.processors.cache.persistence.diagnostic.pagelocktracker.PageLockTrackerManager)

Aggregations

PageLockTrackerManager (org.apache.ignite.internal.processors.cache.persistence.diagnostic.pagelocktracker.PageLockTrackerManager)7 FullPageId (org.apache.ignite.internal.pagemem.FullPageId)2 GridTestKernalContext (org.apache.ignite.testframework.junits.GridTestKernalContext)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Random (java.util.Random)1 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)1 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)1 PageMemory (org.apache.ignite.internal.pagemem.PageMemory)1 DataRegion (org.apache.ignite.internal.processors.cache.persistence.DataRegion)1 DataRegionMetricsImpl (org.apache.ignite.internal.processors.cache.persistence.DataRegionMetricsImpl)1 IndexStorageImpl (org.apache.ignite.internal.processors.cache.persistence.IndexStorageImpl)1 RootPage (org.apache.ignite.internal.processors.cache.persistence.RootPage)1 NoOpPageEvictionTracker (org.apache.ignite.internal.processors.cache.persistence.evict.NoOpPageEvictionTracker)1 CacheFreeList (org.apache.ignite.internal.processors.cache.persistence.freelist.CacheFreeList)1 PageLockListener (org.apache.ignite.internal.processors.cache.persistence.tree.util.PageLockListener)1 GridMetricManager (org.apache.ignite.internal.processors.metric.GridMetricManager)1