Search in sources :

Example 11 with LocalMapStats

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

the class MapStoreTest method issue614.

@Test(timeout = 120000)
public void issue614() {
    final ConcurrentMap<Long, String> STORE = new ConcurrentHashMap<Long, String>();
    STORE.put(1L, "Event1");
    STORE.put(2L, "Event2");
    STORE.put(3L, "Event3");
    STORE.put(4L, "Event4");
    STORE.put(5L, "Event5");
    STORE.put(6L, "Event6");
    Config config = getConfig();
    config.getMapConfig("map").setMapStoreConfig(new MapStoreConfig().setWriteDelaySeconds(1).setImplementation(new SimpleMapStore<Long, String>(STORE)));
    TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory(3);
    HazelcastInstance instance = nodeFactory.newHazelcastInstance(config);
    IMap map = instance.getMap("map");
    map.values();
    LocalMapStats localMapStats = map.getLocalMapStats();
    assertEquals(0, localMapStats.getDirtyEntryCount());
}
Also used : LocalMapStats(com.hazelcast.monitor.LocalMapStats) IMap(com.hazelcast.core.IMap) HazelcastInstance(com.hazelcast.core.HazelcastInstance) MapConfig(com.hazelcast.config.MapConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) Config(com.hazelcast.config.Config) GroupConfig(com.hazelcast.config.GroupConfig) AtomicLong(java.util.concurrent.atomic.AtomicLong) MapStoreConfig(com.hazelcast.config.MapStoreConfig) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 12 with LocalMapStats

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

the class BackupTest method testIssue177BackupCount.

@Test
public void testIssue177BackupCount() throws InterruptedException {
    final int nodeCount = 6;
    final TestHazelcastInstanceFactory nodeFactory = createHazelcastInstanceFactory();
    final Config config = getConfig();
    config.setProperty(GroupProperty.PARTITION_BACKUP_SYNC_INTERVAL.getName(), "1");
    config.getMapConfig(mapName).setBackupCount(1).setStatisticsEnabled(true);
    final Random rand = new Random();
    final AtomicReferenceArray<HazelcastInstance> instances = new AtomicReferenceArray<HazelcastInstance>(nodeCount);
    final int count = 10000;
    final int totalCount = count * (nodeCount - 1);
    final CountDownLatch latch = new CountDownLatch(nodeCount);
    for (int i = 0; i < nodeCount; i++) {
        final int index = i;
        new Thread() {

            public void run() {
                sleepMillis(index * rand.nextInt(1000));
                HazelcastInstance instance = nodeFactory.newHazelcastInstance(config);
                instances.set(index, instance);
                if (index != 0) {
                    // do not run on master node,
                    // let partition assignment be made during put ops.
                    IMap<Object, Object> map = instance.getMap(mapName);
                    for (int j = 0; j < count; j++) {
                        map.put(getName() + "-" + j, "value");
                    }
                }
                latch.countDown();
            }
        }.start();
    }
    assertTrue(latch.await(5, TimeUnit.MINUTES));
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            long totalOwned = 0L;
            long totalBackup = 0L;
            for (int i = 0; i < instances.length(); i++) {
                HazelcastInstance hz = instances.get(i);
                LocalMapStats stats = hz.getMap(mapName).getLocalMapStats();
                totalOwned += stats.getOwnedEntryCount();
                totalBackup += stats.getBackupEntryCount();
            }
            assertEquals("Owned entry count is wrong! ", totalCount, totalOwned);
            assertEquals("Backup entry count is wrong! ", totalCount, totalBackup);
        }
    });
}
Also used : LocalMapStats(com.hazelcast.monitor.LocalMapStats) Config(com.hazelcast.config.Config) CountDownLatch(java.util.concurrent.CountDownLatch) IMap(com.hazelcast.core.IMap) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Random(java.util.Random) AtomicReferenceArray(java.util.concurrent.atomic.AtomicReferenceArray) AssertTask(com.hazelcast.test.AssertTask) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 13 with LocalMapStats

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

the class LocalMapStatsTest method testPutStats_afterPutAll.

@Test
public void testPutStats_afterPutAll() {
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
    final HazelcastInstance[] instances = factory.newInstances(getConfig());
    Map<Integer, Integer> map = new HashMap<Integer, Integer>();
    for (int i = 1; i <= 5000; i++) map.put(i, i);
    IMap<Integer, Integer> iMap = instances[0].getMap("example");
    iMap.putAll(map);
    final LocalMapStats localMapStats = iMap.getLocalMapStats();
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertEquals(5000, localMapStats.getPutOperationCount());
        }
    });
}
Also used : LocalMapStats(com.hazelcast.monitor.LocalMapStats) HazelcastInstance(com.hazelcast.core.HazelcastInstance) HashMap(java.util.HashMap) AssertTask(com.hazelcast.test.AssertTask) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 14 with LocalMapStats

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

the class LocalMapStatsTest method testHitsGenerated.

@Test
public void testHitsGenerated() 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.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 15 with LocalMapStats

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

the class LocalMapStatsTest method testRemove.

@Test
public void testRemove() throws Exception {
    IMap<Integer, Integer> map = getMap();
    for (int i = 0; i < 100; i++) {
        map.put(i, i);
        map.remove(i);
    }
    LocalMapStats localMapStats = map.getLocalMapStats();
    assertEquals(100, localMapStats.getRemoveOperationCount());
}
Also used : 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