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());
}
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);
}
});
}
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());
}
});
}
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());
}
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());
}
Aggregations