use of org.apache.ignite.internal.processors.cache.CacheMetricsImpl in project ignite by apache.
the class RebalanceMetricsTest method testReceivedKeys.
/**
* Testing the correctness of metric {@link CacheMetrics#getRebalancedKeys()}.
*
* @throws Exception If failed.
*/
@Test
public void testReceivedKeys() throws Exception {
cacheConfigs = new CacheConfiguration[] { new CacheConfiguration<>(DEFAULT_CACHE_NAME + "0").setGroupName(DEFAULT_CACHE_NAME).setStatisticsEnabled(true), new CacheConfiguration<>(DEFAULT_CACHE_NAME + "1").setGroupName(DEFAULT_CACHE_NAME).setStatisticsEnabled(true), new CacheConfiguration<>(DEFAULT_CACHE_NAME + "2").setGroupName(DEFAULT_CACHE_NAME).setStatisticsEnabled(false) };
IgniteEx n0 = startGrid(0);
n0.cluster().state(ClusterState.ACTIVE);
awaitPartitionMapExchange();
for (CacheConfiguration<?, ?> cacheCfg : cacheConfigs) {
for (int i = 0; i < 100; i++) n0.cache(cacheCfg.getName()).put(i + CU.cacheId(cacheCfg.getName()), new byte[64]);
}
IgniteEx n1 = startGrid(1);
awaitPartitionMapExchange();
for (CacheConfiguration<?, ?> cacheCfg : cacheConfigs) {
GridCacheContext<?, ?> cacheCtx0 = n0.context().cache().cache(cacheCfg.getName()).context();
GridCacheContext<?, ?> cacheCtx1 = n1.context().cache().cache(cacheCfg.getName()).context();
assertEquals(cacheCfg.getName(), cacheCfg.isStatisticsEnabled(), cacheCtx0.statisticsEnabled());
assertEquals(cacheCfg.getName(), cacheCfg.isStatisticsEnabled(), cacheCtx1.statisticsEnabled());
CacheMetricsImpl metrics0 = cacheCtx0.cache().metrics0();
CacheMetricsImpl metrics1 = cacheCtx1.cache().metrics0();
assertEquals(cacheCfg.getName(), cacheCfg.isStatisticsEnabled(), metrics0.isStatisticsEnabled());
assertEquals(cacheCfg.getName(), cacheCfg.isStatisticsEnabled(), metrics1.isStatisticsEnabled());
assertEquals(cacheCfg.getName(), 0, metrics0.getRebalancedKeys());
assertEquals(cacheCfg.getName(), cacheCfg.isStatisticsEnabled() ? metrics1.getKeySize() : 0, metrics1.getRebalancedKeys());
}
}
use of org.apache.ignite.internal.processors.cache.CacheMetricsImpl in project ignite by apache.
the class AbstractRebuildIndexTest method checkCacheMetrics0.
/**
* Checking metrics rebuilding indexes of cache.
*
* @param n Node.
* @param cacheName Cache name.
* @param expIdxRebuildInProgress The expected status of rebuilding indexes.
* @param expIdxRebuildKeysProcessed The expected number of keys processed during index rebuilding.
*/
protected void checkCacheMetrics0(IgniteEx n, String cacheName, boolean expIdxRebuildInProgress, @Nullable Long expIdxRebuildKeysProcessed) {
CacheMetricsImpl metrics0 = cacheMetrics0(n, cacheName);
assertNotNull(metrics0);
assertEquals(expIdxRebuildInProgress, metrics0.isIndexRebuildInProgress());
if (expIdxRebuildKeysProcessed != null)
assertEquals(expIdxRebuildKeysProcessed.longValue(), metrics0.getIndexRebuildKeysProcessed());
}
Aggregations