Search in sources :

Example 16 with LocalMapStats

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

the class LocalMapStatsTest method testGetAsyncAndHitsGenerated.

@Test
public void testGetAsyncAndHitsGenerated() throws Exception {
    final IMap<Integer, Integer> map = getMap();
    for (int i = 0; i < 100; i++) {
        map.put(i, i);
        map.getAsync(i).get();
    }
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            final LocalMapStats localMapStats = map.getLocalMapStats();
            assertEquals(100, localMapStats.getGetOperationCount());
            assertEquals(100, localMapStats.getHits());
        }
    });
}
Also used : LocalMapStats(com.hazelcast.monitor.LocalMapStats) AssertTask(com.hazelcast.test.AssertTask) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 17 with LocalMapStats

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

the class NearCacheTest method testNullValueNearCache.

// issue 1570
@Test
public void testNullValueNearCache() {
    int clusterSize = 2;
    String mapName = "testNullValueNearCache";
    Config config = getConfig();
    config.getMapConfig(mapName).setNearCacheConfig(newNearCacheConfig());
    HazelcastInstance instance = createHazelcastInstanceFactory(clusterSize).newInstances(config)[0];
    IMap<String, String> map = instance.getMap(mapName);
    for (int i = 0; i < MAX_CACHE_SIZE; i++) {
        assertNull(map.get("key" + i));
    }
    for (int i = 0; i < MAX_CACHE_SIZE; i++) {
        assertNull(map.get("key" + i));
    }
    LocalMapStats stats = map.getLocalMapStats();
    assertTrue(format("Near Cache operation count should be < %d but was %d", MAX_CACHE_SIZE * 2, stats.getGetOperationCount()), stats.getGetOperationCount() < MAX_CACHE_SIZE * 2);
}
Also used : LocalMapStats(com.hazelcast.monitor.LocalMapStats) HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) EvictionConfig(com.hazelcast.config.EvictionConfig) Config(com.hazelcast.config.Config) NearCacheConfig(com.hazelcast.config.NearCacheConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 18 with LocalMapStats

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

the class MapCreationDelayWithMapStoreTest method testMapCreation__notAffectedByUnresponsiveLoader.

@Test(timeout = 120000)
public void testMapCreation__notAffectedByUnresponsiveLoader() throws Exception {
    final UnresponsiveLoader<Integer, Integer> unresponsiveLoader = new UnresponsiveLoader<Integer, Integer>();
    final IMap<Integer, Integer> map = TestMapUsingMapStoreBuilder.<Integer, Integer>create().withMapStore(unresponsiveLoader).withNodeCount(1).withNodeFactory(createHazelcastInstanceFactory(1)).withPartitionCount(1).build();
    final LocalMapStats stats = map.getLocalMapStats();
    final long ownedEntryCount = stats.getOwnedEntryCount();
    assertEquals(0, ownedEntryCount);
}
Also used : LocalMapStats(com.hazelcast.monitor.LocalMapStats) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 19 with LocalMapStats

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

the class ClientMapBasicTest method testMapStatistics_withClientOperations.

@Test
public void testMapStatistics_withClientOperations() {
    String mapName = randomString();
    LocalMapStats stats1 = member1.getMap(mapName).getLocalMapStats();
    LocalMapStats stats2 = member2.getMap(mapName).getLocalMapStats();
    IMap<Integer, Integer> map = client.getMap(mapName);
    int operationCount = 1123;
    for (int i = 0; i < operationCount; i++) {
        map.put(i, i);
        map.get(i);
        map.remove(i);
    }
    assertEquals("put count", operationCount, stats1.getPutOperationCount() + stats2.getPutOperationCount());
    assertEquals("get count", operationCount, stats1.getGetOperationCount() + stats2.getGetOperationCount());
    assertEquals("remove count", operationCount, stats1.getRemoveOperationCount() + stats2.getRemoveOperationCount());
    assertTrue("put latency", 0 < stats1.getTotalPutLatency() + stats2.getTotalPutLatency());
    assertTrue("get latency", 0 < stats1.getTotalGetLatency() + stats2.getTotalGetLatency());
    assertTrue("remove latency", 0 < stats1.getTotalRemoveLatency() + stats2.getTotalRemoveLatency());
}
Also used : LocalMapStats(com.hazelcast.monitor.LocalMapStats) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 20 with LocalMapStats

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

the class ClientMapTest method testMapStatistics.

@Test
public void testMapStatistics() throws Exception {
    String name = randomString();
    IMap<Integer, Integer> map = client.getMap(name);
    int operationCount = 1000;
    for (int i = 0; i < operationCount; i++) {
        map.put(i, i);
        map.get(i);
        map.remove(i);
    }
    LocalMapStats localMapStats = server.getMap(name).getLocalMapStats();
    assertEquals("put count", operationCount, localMapStats.getPutOperationCount());
    assertEquals("get count", operationCount, localMapStats.getGetOperationCount());
    assertEquals("remove count", operationCount, localMapStats.getRemoveOperationCount());
    assertTrue("put latency", 0 < localMapStats.getTotalPutLatency());
    assertTrue("get latency", 0 < localMapStats.getTotalGetLatency());
    assertTrue("remove latency", 0 < localMapStats.getTotalRemoveLatency());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) LocalMapStats(com.hazelcast.monitor.LocalMapStats) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

LocalMapStats (com.hazelcast.monitor.LocalMapStats)22 QuickTest (com.hazelcast.test.annotation.QuickTest)20 Test (org.junit.Test)20 ParallelTest (com.hazelcast.test.annotation.ParallelTest)19 AssertTask (com.hazelcast.test.AssertTask)7 HazelcastInstance (com.hazelcast.core.HazelcastInstance)5 IMap (com.hazelcast.core.IMap)5 Config (com.hazelcast.config.Config)4 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)4 MapConfig (com.hazelcast.config.MapConfig)3 HashMap (java.util.HashMap)2 EvictionConfig (com.hazelcast.config.EvictionConfig)1 GroupConfig (com.hazelcast.config.GroupConfig)1 MapStoreConfig (com.hazelcast.config.MapStoreConfig)1 MaxSizeConfig (com.hazelcast.config.MaxSizeConfig)1 NearCacheConfig (com.hazelcast.config.NearCacheConfig)1 MapService (com.hazelcast.map.impl.MapService)1 NearCacheStats (com.hazelcast.monitor.NearCacheStats)1 LocalMapStatsImpl (com.hazelcast.monitor.impl.LocalMapStatsImpl)1 StatisticsAwareService (com.hazelcast.spi.StatisticsAwareService)1