Search in sources :

Example 11 with CacheMetricsImpl

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());
    }
}
Also used : CacheMetricsImpl(org.apache.ignite.internal.processors.cache.CacheMetricsImpl) IgniteEx(org.apache.ignite.internal.IgniteEx) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 12 with CacheMetricsImpl

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());
}
Also used : CacheMetricsImpl(org.apache.ignite.internal.processors.cache.CacheMetricsImpl)

Aggregations

CacheMetricsImpl (org.apache.ignite.internal.processors.cache.CacheMetricsImpl)12 ArrayList (java.util.ArrayList)4 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4 ClusterNode (org.apache.ignite.cluster.ClusterNode)4 GridCacheContext (org.apache.ignite.internal.processors.cache.GridCacheContext)4 UUID (java.util.UUID)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)3 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 IgniteLogger (org.apache.ignite.IgniteLogger)2 CacheRebalanceMode (org.apache.ignite.cache.CacheRebalanceMode)2 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)2 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)2