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());
}
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));
}
}
Aggregations