Search in sources :

Example 1 with LocalMapStats

use of com.hazelcast.map.LocalMapStats in project hazelcast by hazelcast.

the class MapService method provideDynamicMetrics.

@Override
public void provideDynamicMetrics(MetricDescriptor descriptor, MetricsCollectionContext context) {
    Map<String, LocalMapStats> stats = getStats();
    if (stats == null) {
        return;
    }
    for (Map.Entry<String, LocalMapStats> entry : stats.entrySet()) {
        String mapName = entry.getKey();
        LocalMapStats localInstanceStats = entry.getValue();
        // map
        MetricDescriptor dsDescriptor = descriptor.copy().withPrefix(MAP_PREFIX).withDiscriminator(MAP_DISCRIMINATOR_NAME, mapName);
        context.collect(dsDescriptor, localInstanceStats);
        // index
        Map<String, LocalIndexStats> indexStats = localInstanceStats.getIndexStats();
        for (Map.Entry<String, LocalIndexStats> indexEntry : indexStats.entrySet()) {
            MetricDescriptor indexDescriptor = descriptor.copy().withPrefix(MAP_PREFIX_INDEX).withDiscriminator(MAP_DISCRIMINATOR_NAME, mapName).withTag(MAP_TAG_INDEX, indexEntry.getKey());
            context.collect(indexDescriptor, indexEntry.getValue());
        }
        // near cache
        NearCacheStats nearCacheStats = localInstanceStats.getNearCacheStats();
        if (nearCacheStats != null) {
            MetricDescriptor nearCacheDescriptor = descriptor.copy().withPrefix(MAP_PREFIX_NEARCACHE).withDiscriminator(MAP_DISCRIMINATOR_NAME, mapName);
            context.collect(nearCacheDescriptor, nearCacheStats);
        }
    }
    // stats of offloaded-entry-processor's executor
    ExecutorStats executorStats = mapServiceContext.getOffloadedEntryProcessorExecutorStats();
    executorStats.getStatsMap().forEach((name, offloadedExecutorStats) -> {
        MetricDescriptor nearCacheDescriptor = descriptor.copy().withPrefix(MAP_PREFIX_ENTRY_PROCESSOR_OFFLOADABLE_EXECUTOR).withDiscriminator(MAP_DISCRIMINATOR_NAME, name);
        context.collect(nearCacheDescriptor, offloadedExecutorStats);
    });
}
Also used : LocalMapStats(com.hazelcast.map.LocalMapStats) MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) NearCacheStats(com.hazelcast.nearcache.NearCacheStats) Map(java.util.Map) LocalIndexStats(com.hazelcast.query.LocalIndexStats)

Example 2 with LocalMapStats

use of com.hazelcast.map.LocalMapStats in project hazelcast by hazelcast.

the class LocalMultiMapStatsTest method testRemove.

@Test
public void testRemove() {
    MultiMap<Integer, Integer> map = getMultiMap();
    for (int i = 0; i < 100; i++) {
        map.put(i, i);
        map.remove(i);
    }
    LocalMapStats localMapStats = getMultiMapStats();
    assertEquals(100, localMapStats.getRemoveOperationCount());
}
Also used : LocalMapStats(com.hazelcast.map.LocalMapStats) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with LocalMapStats

use of com.hazelcast.map.LocalMapStats in project hazelcast by hazelcast.

the class LocalMultiMapStatsTest method testHitsGenerated.

@Test
public void testHitsGenerated() {
    MultiMap<Integer, Integer> map = getMultiMap();
    for (int i = 0; i < 100; i++) {
        map.put(i, i);
        map.get(i);
    }
    LocalMapStats localMapStats = getMultiMapStats();
    assertEquals(100, localMapStats.getHits());
}
Also used : LocalMapStats(com.hazelcast.map.LocalMapStats) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 4 with LocalMapStats

use of com.hazelcast.map.LocalMapStats in project hazelcast by hazelcast.

the class LocalMultiMapStatsTest method testPutAndHitsGenerated.

@Test
public void testPutAndHitsGenerated() {
    MultiMap<Integer, Integer> map = getMultiMap();
    for (int i = 0; i < 100; i++) {
        map.put(i, i);
        map.get(i);
    }
    LocalMapStats localMapStats = getMultiMapStats();
    assertEquals(100, localMapStats.getPutOperationCount());
    assertEquals(100, localMapStats.getHits());
}
Also used : LocalMapStats(com.hazelcast.map.LocalMapStats) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with LocalMapStats

use of com.hazelcast.map.LocalMapStats in project hazelcast by hazelcast.

the class LocalMultiMapStatsTest method testOtherOperationCount_containsKey.

@Test
public void testOtherOperationCount_containsKey() {
    MultiMap map = getMultiMap();
    for (int i = 0; i < OPERATION_COUNT; i++) {
        map.containsKey(i);
    }
    LocalMapStats stats = getMultiMapStats();
    assertEquals(OPERATION_COUNT, stats.getOtherOperationCount());
}
Also used : LocalMapStats(com.hazelcast.map.LocalMapStats) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

LocalMapStats (com.hazelcast.map.LocalMapStats)34 QuickTest (com.hazelcast.test.annotation.QuickTest)29 Test (org.junit.Test)29 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)28 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)6 MapConfig (com.hazelcast.config.MapConfig)3 HazelcastInstance (com.hazelcast.core.HazelcastInstance)3 IMap (com.hazelcast.map.IMap)3 Config (com.hazelcast.config.Config)2 LocalIndexStats (com.hazelcast.query.LocalIndexStats)2 Map (java.util.Map)2 MapStoreConfig (com.hazelcast.config.MapStoreConfig)1 NearCacheConfig (com.hazelcast.config.NearCacheConfig)1 DistributedObject (com.hazelcast.core.DistributedObject)1 MetricDescriptor (com.hazelcast.internal.metrics.MetricDescriptor)1 LocalIndexStatsImpl (com.hazelcast.internal.monitor.impl.LocalIndexStatsImpl)1 LocalMapStatsImpl (com.hazelcast.internal.monitor.impl.LocalMapStatsImpl)1 PerIndexStats (com.hazelcast.internal.monitor.impl.PerIndexStats)1 StatisticsAwareService (com.hazelcast.internal.services.StatisticsAwareService)1 BasicMapTest (com.hazelcast.map.BasicMapTest)1