Search in sources :

Example 1 with PagesListView

use of org.apache.ignite.spi.systemview.view.PagesListView in project ignite by apache.

the class IgniteCacheDatabaseSharedManager method start0.

/**
 * {@inheritDoc}
 */
@Override
protected void start0() throws IgniteCheckedException {
    if (cctx.kernalContext().clientNode() && cctx.kernalContext().config().getDataStorageConfiguration() == null)
        return;
    DataStorageConfiguration memCfg = cctx.kernalContext().config().getDataStorageConfiguration();
    assert memCfg != null;
    validateConfiguration(memCfg);
    pageSize = memCfg.getPageSize();
    initDataRegions(memCfg);
    cctx.kernalContext().systemView().registerView(DATA_REGION_PAGE_LIST_VIEW, DATA_REGION_PAGE_LIST_VIEW_DESC, new PagesListViewWalker(), () -> {
        Map<String, CacheFreeList> freeLists = freeListMap;
        if (freeLists == null)
            return Collections.emptyList();
        return freeLists.values().stream().flatMap(fl -> IntStream.range(0, fl.bucketsCount()).mapToObj(bucket -> new PagesListView(fl, bucket))).collect(Collectors.toList());
    }, Function.identity());
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) NoOpPageEvictionTracker(org.apache.ignite.internal.processors.cache.persistence.evict.NoOpPageEvictionTracker) Arrays(java.util.Arrays) TimeBag(org.apache.ignite.internal.util.TimeBag) IGNITE_THRESHOLD_WAL_ARCHIVE_SIZE_PERCENTAGE(org.apache.ignite.IgniteSystemProperties.IGNITE_THRESHOLD_WAL_ARCHIVE_SIZE_PERCENTAGE) MetastorageLifecycleListener(org.apache.ignite.internal.processors.cache.persistence.metastorage.MetastorageLifecycleListener) IgniteChangeGlobalStateSupport(org.apache.ignite.internal.processors.cluster.IgniteChangeGlobalStateSupport) WALPointer(org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer) IgniteSystemProperties(org.apache.ignite.IgniteSystemProperties) UnsafeMemoryProvider(org.apache.ignite.internal.mem.unsafe.UnsafeMemoryProvider) DataRegionMetricsProvider(org.apache.ignite.DataRegionMetricsProvider) Map(java.util.Map) Objects.isNull(java.util.Objects.isNull) AbstractFreeList(org.apache.ignite.internal.processors.cache.persistence.freelist.AbstractFreeList) IgniteKernal(org.apache.ignite.internal.IgniteKernal) HALF_MAX_WAL_ARCHIVE_SIZE(org.apache.ignite.configuration.DataStorageConfiguration.HALF_MAX_WAL_ARCHIVE_SIZE) FailureType(org.apache.ignite.failure.FailureType) ReuseList(org.apache.ignite.internal.processors.cache.persistence.tree.reuse.ReuseList) IgniteInClosure(org.apache.ignite.lang.IgniteInClosure) PageIdAllocator(org.apache.ignite.internal.pagemem.PageIdAllocator) IgniteOutClosure(org.apache.ignite.lang.IgniteOutClosure) DFLT_PAGE_SIZE(org.apache.ignite.configuration.DataStorageConfiguration.DFLT_PAGE_SIZE) Collection(java.util.Collection) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) MetaStorage(org.apache.ignite.internal.processors.cache.persistence.metastorage.MetaStorage) DirectMemoryProvider(org.apache.ignite.internal.mem.DirectMemoryProvider) CheckpointMarkersStorage(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointMarkersStorage) Collectors(java.util.stream.Collectors) VOLATILE_DATA_REGION_NAME(org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor.VOLATILE_DATA_REGION_NAME) GridCacheSharedManagerAdapter(org.apache.ignite.internal.processors.cache.GridCacheSharedManagerAdapter) WarmUpConfiguration(org.apache.ignite.configuration.WarmUpConfiguration) IgniteBiTuple(org.apache.ignite.lang.IgniteBiTuple) DataRegionMetrics(org.apache.ignite.DataRegionMetrics) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) CU(org.apache.ignite.internal.util.typedef.internal.CU) DataRegionMetricsMXBean(org.apache.ignite.mxbean.DataRegionMetricsMXBean) PagesListView(org.apache.ignite.spi.systemview.view.PagesListView) IgniteOutOfMemoryException(org.apache.ignite.internal.mem.IgniteOutOfMemoryException) MappedFileMemoryProvider(org.apache.ignite.internal.mem.file.MappedFileMemoryProvider) GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) Objects.nonNull(java.util.Objects.nonNull) PageEvictionTracker(org.apache.ignite.internal.processors.cache.persistence.evict.PageEvictionTracker) CacheFreeList(org.apache.ignite.internal.processors.cache.persistence.freelist.CacheFreeList) METASTORE_DATA_REGION_NAME(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager.METASTORE_DATA_REGION_NAME) IntStream(java.util.stream.IntStream) FreeList(org.apache.ignite.internal.processors.cache.persistence.freelist.FreeList) CheckpointProgress(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointProgress) PdsFolderSettings(org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderSettings) U(org.apache.ignite.internal.util.typedef.internal.U) IgniteLogger(org.apache.ignite.IgniteLogger) PageMemory(org.apache.ignite.internal.pagemem.PageMemory) IgniteSystemProperties.getDouble(org.apache.ignite.IgniteSystemProperties.getDouble) Function(java.util.function.Function) Supplier(java.util.function.Supplier) DirectMemoryRegion(org.apache.ignite.internal.mem.DirectMemoryRegion) CacheGroupContext(org.apache.ignite.internal.processors.cache.CacheGroupContext) LT(org.apache.ignite.internal.util.typedef.internal.LT) PageMemoryNoStoreImpl(org.apache.ignite.internal.pagemem.impl.PageMemoryNoStoreImpl) IGNITE_REUSE_MEMORY_ON_DEACTIVATE(org.apache.ignite.IgniteSystemProperties.IGNITE_REUSE_MEMORY_ON_DEACTIVATE) GridKernalContext(org.apache.ignite.internal.GridKernalContext) HashSet(java.util.HashSet) PagesListViewWalker(org.apache.ignite.internal.managers.systemview.walker.PagesListViewWalker) RandomLruPageEvictionTracker(org.apache.ignite.internal.processors.cache.persistence.evict.RandomLruPageEvictionTracker) FailureContext(org.apache.ignite.failure.FailureContext) DFLT_DATA_REG_DEFAULT_NAME(org.apache.ignite.configuration.DataStorageConfiguration.DFLT_DATA_REG_DEFAULT_NAME) IgniteClosure(org.apache.ignite.lang.IgniteClosure) GridDhtPartitionsExchangeFuture(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture) PageReadWriteManager(org.apache.ignite.internal.processors.cache.persistence.pagemem.PageReadWriteManager) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) InstanceNotFoundException(javax.management.InstanceNotFoundException) GridDiscoveryManager(org.apache.ignite.internal.managers.discovery.GridDiscoveryManager) DataStorageMetrics(org.apache.ignite.DataStorageMetrics) AffinityTopologyVersion(org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion) DataPageEvictionMode(org.apache.ignite.configuration.DataPageEvictionMode) UNLIMITED_WAL_ARCHIVE(org.apache.ignite.configuration.DataStorageConfiguration.UNLIMITED_WAL_ARCHIVE) WarmUpStrategy(org.apache.ignite.internal.processors.cache.warmup.WarmUpStrategy) File(java.io.File) T2(org.apache.ignite.internal.util.typedef.T2) TX_LOG_CACHE_NAME(org.apache.ignite.internal.processors.cache.mvcc.txlog.TxLog.TX_LOG_CACHE_NAME) Random2LruPageEvictionTracker(org.apache.ignite.internal.processors.cache.persistence.evict.Random2LruPageEvictionTracker) Collections(java.util.Collections) FairFifoPageEvictionTracker(org.apache.ignite.internal.processors.cache.persistence.evict.FairFifoPageEvictionTracker) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) PagesListViewWalker(org.apache.ignite.internal.managers.systemview.walker.PagesListViewWalker) CacheFreeList(org.apache.ignite.internal.processors.cache.persistence.freelist.CacheFreeList) PagesListView(org.apache.ignite.spi.systemview.view.PagesListView)

Example 2 with PagesListView

use of org.apache.ignite.spi.systemview.view.PagesListView in project ignite by apache.

the class SystemViewSelfTest method testPagesList.

/**
 */
@Test
public void testPagesList() throws Exception {
    cleanPersistenceDir();
    try (IgniteEx ignite = startGrid(getConfiguration().setDataStorageConfiguration(new DataStorageConfiguration().setDataRegionConfigurations(new DataRegionConfiguration().setName("dr0").setMaxSize(100L * 1024 * 1024), new DataRegionConfiguration().setName("dr1").setMaxSize(100L * 1024 * 1024).setPersistenceEnabled(true))))) {
        ignite.cluster().active(true);
        GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager) ignite.context().cache().context().database();
        int pageSize = dbMgr.pageSize();
        dbMgr.enableCheckpoints(false).get();
        for (int i = 0; i < 2; i++) {
            IgniteCache<Object, Object> cache = ignite.getOrCreateCache(new CacheConfiguration<>("cache" + i).setDataRegionName("dr" + i).setAffinity(new RendezvousAffinityFunction().setPartitions(2)));
            int key = 0;
            // Fill up different free-list buckets.
            for (int j = 0; j < pageSize / 2; j++) cache.put(key++, new byte[j + 1]);
            // Put some pages to one bucket to overflow pages cache.
            for (int j = 0; j < 1000; j++) cache.put(key++, new byte[pageSize / 2]);
        }
        long dr0flPages = 0;
        int dr0flStripes = 0;
        SystemView<PagesListView> dataRegionPageLists = ignite.context().systemView().view(DATA_REGION_PAGE_LIST_VIEW);
        for (PagesListView pagesListView : dataRegionPageLists) {
            if (pagesListView.name().startsWith("dr0")) {
                dr0flPages += pagesListView.bucketSize();
                dr0flStripes += pagesListView.stripesCount();
            }
        }
        assertTrue(dr0flPages > 0);
        assertTrue(dr0flStripes > 0);
        SystemView<CachePagesListView> cacheGrpPageLists = ignite.context().systemView().view(CACHE_GRP_PAGE_LIST_VIEW);
        long dr1flPages = 0;
        int dr1flStripes = 0;
        int dr1flCached = 0;
        for (CachePagesListView pagesListView : cacheGrpPageLists) {
            if (pagesListView.cacheGroupId() == cacheId("cache1")) {
                dr1flPages += pagesListView.bucketSize();
                dr1flStripes += pagesListView.stripesCount();
                dr1flCached += pagesListView.cachedPagesCount();
            }
        }
        assertTrue(dr1flPages > 0);
        assertTrue(dr1flStripes > 0);
        assertTrue(dr1flCached > 0);
        // Test filtering.
        assertTrue(cacheGrpPageLists instanceof FiltrableSystemView);
        Iterator<CachePagesListView> iter = ((FiltrableSystemView<CachePagesListView>) cacheGrpPageLists).iterator(U.map(CachePagesListViewWalker.CACHE_GROUP_ID_FILTER, cacheId("cache1"), CachePagesListViewWalker.PARTITION_ID_FILTER, 0, CachePagesListViewWalker.BUCKET_NUMBER_FILTER, 0));
        assertEquals(1, F.size(iter));
        iter = ((FiltrableSystemView<CachePagesListView>) cacheGrpPageLists).iterator(U.map(CachePagesListViewWalker.CACHE_GROUP_ID_FILTER, cacheId("cache1"), CachePagesListViewWalker.BUCKET_NUMBER_FILTER, 0));
        assertEquals(2, F.size(iter));
    }
}
Also used : CachePagesListView(org.apache.ignite.spi.systemview.view.CachePagesListView) GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) CachePagesListView(org.apache.ignite.spi.systemview.view.CachePagesListView) PagesListView(org.apache.ignite.spi.systemview.view.PagesListView) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) FiltrableSystemView(org.apache.ignite.spi.systemview.view.FiltrableSystemView) IgniteEx(org.apache.ignite.internal.IgniteEx) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) Test(org.junit.Test) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)

Aggregations

DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)2 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)2 PagesListView (org.apache.ignite.spi.systemview.view.PagesListView)2 File (java.io.File)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Objects.isNull (java.util.Objects.isNull)1 Objects.nonNull (java.util.Objects.nonNull)1 Set (java.util.Set)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Function (java.util.function.Function)1 Supplier (java.util.function.Supplier)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1 InstanceNotFoundException (javax.management.InstanceNotFoundException)1 DataRegionMetrics (org.apache.ignite.DataRegionMetrics)1