Search in sources :

Example 6 with LocalMapStats

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

the class LocalMapStatsTest method testPutAsync.

@Test
public void testPutAsync() throws Exception {
    IMap<Integer, Integer> map = getMap();
    for (int i = 0; i < 100; i++) {
        map.putAsync(i, i);
    }
    final LocalMapStats localMapStats = map.getLocalMapStats();
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertEquals(100, localMapStats.getPutOperationCount());
        }
    });
}
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 7 with LocalMapStats

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

the class LocalMapStatsTest method testGetAndHitsGenerated.

@Test
public void testGetAndHitsGenerated() throws Exception {
    IMap<Integer, Integer> map = getMap();
    for (int i = 0; i < 100; i++) {
        map.put(i, i);
        map.get(i);
    }
    LocalMapStats localMapStats = map.getLocalMapStats();
    assertEquals(100, localMapStats.getGetOperationCount());
    assertEquals(100, localMapStats.getHits());
}
Also used : LocalMapStats(com.hazelcast.monitor.LocalMapStats) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 8 with LocalMapStats

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

the class LocalMapStatsTest method testGetAllGenerated.

@Test
public void testGetAllGenerated() throws Exception {
    IMap<Integer, Integer> map = getMap();
    for (int i = 0; i < 200; i++) {
        map.put(i, i);
    }
    for (int i = 0; i < 100; i++) {
        Set<Integer> keys = new HashSet<Integer>();
        keys.add(i);
        keys.add(100 + i);
        map.getAll(keys);
    }
    LocalMapStats localMapStats = map.getLocalMapStats();
    assertEquals(200, localMapStats.getGetOperationCount());
}
Also used : LocalMapStats(com.hazelcast.monitor.LocalMapStats) HashSet(java.util.HashSet) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 9 with LocalMapStats

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

the class LocalMapStatsTest method testRemoveAsync.

@Test
public void testRemoveAsync() throws Exception {
    IMap<Integer, Integer> map = getMap();
    for (int i = 0; i < 100; i++) {
        map.put(i, i);
        map.removeAsync(i);
    }
    final LocalMapStats localMapStats = map.getLocalMapStats();
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertEquals(100, localMapStats.getRemoveOperationCount());
        }
    });
}
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 10 with LocalMapStats

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

the class LocalMapStatsTest method testHitsGenerated_updatedConcurrently.

@Test
public void testHitsGenerated_updatedConcurrently() throws Exception {
    final IMap<Integer, Integer> map = getMap();
    final int actionCount = 100;
    for (int i = 0; i < actionCount; i++) {
        map.put(i, i);
        map.get(i);
    }
    final LocalMapStats localMapStats = map.getLocalMapStats();
    final long initialHits = localMapStats.getHits();
    new Thread(new Runnable() {

        @Override
        public void run() {
            for (int i = 0; i < actionCount; i++) {
                map.get(i);
            }
            // causes the local stats object to update
            map.getLocalMapStats();
        }
    }).start();
    assertEquals(actionCount, initialHits);
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertEquals(actionCount * 2, 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)

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