/** {@inheritDoc} */ @Override public long getRowCount() { return ctx.ioStats().statistics(IoStatisticsType.CACHE_GROUP).size(); } }
SqlSystemViewColumnCondition nameCond = conditionForColumn("GROUP_NAME", first, last); Map<IoStatisticsHolderKey, IoStatisticsHolder> stats = ctx.ioStats().statistics(IoStatisticsType.CACHE_GROUP);
/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { super.beforeTest(); ignite.context().ioStats().reset(); }
/** * Prepare Ignite instance and fill cache. * * @param isPersistent {@code true} in case persistence should be enable. * @return IO statistic manager. * @throws Exception In case of failure. */ @NotNull private IoStatisticsManager prepareData(boolean isPersistent) throws Exception { IgniteEx ign = prepareIgnite(isPersistent); IoStatisticsManager ioStatMgr = ign.context().ioStats(); IgniteCache cache = ign.getOrCreateCache(DEFAULT_CACHE_NAME); ioStatMgr.reset(); for (int i = 0; i < RECORD_COUNT; i++) cache.put("KEY-" + i, "VAL-" + i); return ioStatMgr; }
/** * Test statistics for three caches in the same time. */ @Test public void testForThreeCaches() { prepareData(RECORD_COUNT, ATOMIC_CACHE_NAME, TRANSACTIONAL_CACHE_NAME, MVCC_CACHE_NAME); IoStatisticsManager ioStatMgr = ignite.context().ioStats(); Set<String> statisticCacheNames = ioStatMgr.deriveStatisticNames(IoStatisticsType.CACHE_GROUP); Assert.assertEquals(ALL_CACHE_GROUP_NAMES, statisticCacheNames); Stream.of(ATOMIC_CACHE_NAME, TRANSACTIONAL_CACHE_NAME, MVCC_CACHE_NAME).forEach((cacheName) -> { long logicalReads = ioStatMgr.logicalReads(IoStatisticsType.CACHE_GROUP, cacheName, null); Assert.assertTrue(logicalReads > RECORD_COUNT); }); }
/** */ private void checkStat() { IoStatisticsManager ioStat = grid().context().ioStats(); Set<String> hashIndexes = ioStat.deriveStatisticNames(IoStatisticsType.HASH_INDEX); Assert.assertEquals(PK_HASH_INDEXES, hashIndexes); Set<String> sortedIndexCaches = ioStat.deriveStatisticNames(IoStatisticsType.SORTED_INDEX); Assert.assertEquals(1, sortedIndexCaches.size()); Set<String> sortedIdxNames = ioStat.deriveStatisticSubNames(IoStatisticsType.SORTED_INDEX, sortedIndexCaches.toArray()[0].toString()); Assert.assertEquals(sortedIndexCaches.toString(), indexes.size() + NUMBER_OF_PK_SORTED_INDEXES, sortedIdxNames.size()); for (String idxName : sortedIdxNames) { Long logicalReads = ioStat.logicalReads(IoStatisticsType.SORTED_INDEX, DEFAULT_CACHE_NAME, idxName); Assert.assertNotNull(idxName, logicalReads); Assert.assertTrue(logicalReads > 0); } ioStat.reset(); }
/** * Simple test JMX bean for caches IO stats. * * @throws Exception In case of failure. */ @Test public void testCacheBasic() throws Exception { IoStatisticsMetricsMXBean bean = ioStatMXBean(); IoStatisticsManager ioStatMgr = ignite.context().ioStats(); Assert.assertEquals(ioStatMgr.startTime().toEpochSecond(), bean.getStartTime()); Assert.assertEquals(ioStatMgr.startTime().format(DateTimeFormatter.ISO_DATE_TIME), bean.getStartTimeLocal()); bean.reset(); Assert.assertEquals(ioStatMgr.startTime().toEpochSecond(), bean.getStartTime()); Assert.assertEquals(ioStatMgr.startTime().format(DateTimeFormatter.ISO_DATE_TIME), bean.getStartTimeLocal()); int cnt = 100; warmUpMemmory(bean, cnt); populateCache(cnt); Long cacheLogicalReadsCnt = bean.getCacheGroupLogicalReads(DEFAULT_CACHE_NAME); Assert.assertNotNull(cacheLogicalReadsCnt); Assert.assertEquals(cnt, cacheLogicalReadsCnt.longValue()); Long cachePhysicalReadsCnt = bean.getCacheGroupPhysicalReads(DEFAULT_CACHE_NAME); Assert.assertNotNull(cachePhysicalReadsCnt); Assert.assertEquals(0, cachePhysicalReadsCnt.longValue()); String formatted = bean.getCacheGroupStatistics(DEFAULT_CACHE_NAME); Assert.assertEquals("CACHE_GROUP default [LOGICAL_READS=100, PHYSICAL_READS=0]", formatted); String unexistedStats = bean.getCacheGroupStatistics("unknownCache"); Assert.assertEquals("CACHE_GROUP unknownCache []", unexistedStats); }
IoStatisticsMetricsMXBean bean = ioStatMXBean(); IoStatisticsManager ioStatMgr = ignite.context().ioStats();
/** * Test statistics for two caches in the same cache group. */ @Test public void testCacheGroupCaches() { prepareData(RECORD_COUNT, CACHE1_IN_GROUP_NAME, CACHE2_IN_GROUP_NAME); IoStatisticsManager ioStatMgr = ignite.context().ioStats(); Set<String> statisticCacheNames = ioStatMgr.deriveStatisticNames(IoStatisticsType.CACHE_GROUP); Assert.assertEquals(ALL_CACHE_GROUP_NAMES, statisticCacheNames); long logicalReads = ioStatMgr.logicalReads(IoStatisticsType.CACHE_GROUP, CACHE_GROUP_NAME, null); Assert.assertEquals(RECORD_COUNT * 6, logicalReads); }
/** * @param cacheName Name of cache. * @param rowCnt Number of row need to put into cache. * @param dataPageReads How many data page reads operation expected. * @param idxPageReadsCnt How many index page reads scan expected. */ protected void cacheTest(String cacheName, int rowCnt, int dataPageReads, int idxPageReadsCnt) { prepareData(rowCnt, cacheName); IoStatisticsManager ioStatMgr = ignite.context().ioStats(); Set<String> statisticCacheNames = ioStatMgr.deriveStatisticNames(IoStatisticsType.CACHE_GROUP); Assert.assertEquals(ALL_CACHE_GROUP_NAMES, statisticCacheNames); Assert.assertTrue(statisticCacheNames.contains(cacheName)); long logicalReadsCache = ioStatMgr.logicalReads(IoStatisticsType.CACHE_GROUP, cacheName, null); Assert.assertEquals(dataPageReads, logicalReadsCache); long logicalReadsIdx = ioStatMgr.logicalReads(IoStatisticsType.HASH_INDEX, cacheName, HASH_PK_IDX_NAME); Assert.assertEquals(idxPageReadsCnt, logicalReadsIdx); }
/** * Test existing zero statistics for not touched caches. * * @throws Exception In case of failure. */ @Test public void testEmptyIOStat() throws Exception { IgniteEx ign = prepareIgnite(true); IoStatisticsManager ioStatMgr = ign.context().ioStats(); Map<IoStatisticsHolderKey, IoStatisticsHolder> stat = ioStatMgr.statistics(IoStatisticsType.CACHE_GROUP); checkEmptyStat(stat, DEFAULT_CACHE_NAME, null); stat = ioStatMgr.statistics(IoStatisticsType.HASH_INDEX); checkEmptyStat(stat, DEFAULT_CACHE_NAME, HASH_PK_IDX_NAME); }
/** * Warm up and fill cache. * * @param cacheNames Names of caches to populate. * @param cnt Number of entries to put. */ private void prepareData(int cnt, String... cacheNames) { //Need to initialize partition and data memory pages for (String cacheName : cacheNames) { IgniteCache cache = ignite.cache(cacheName); for (int i = 0; i < cnt; i++) { cache.put(i, i); cache.put(i, i); //Second invocation required to warm up MVCC cache to fill old versions chains. } } ignite.context().ioStats().reset(); for (String cacheName : cacheNames) { IgniteCache cache = ignite.cache(cacheName); for (int i = 0; i < cnt; i++) cache.put(i, i); } }
IoStatisticsHolder stats = cctx.kernalContext().ioStats().registerIndex( IoStatisticsType.SORTED_INDEX, cctx.name(),