use of com.hazelcast.map.listener.EntryUpdatedListener in project hazelcast by hazelcast.
the class QueryCacheCoalescingTest method testCoalescingModeWorks.
@Test
public void testCoalescingModeWorks() {
String mapName = randomString();
String cacheName = randomString();
Config config = getConfig(mapName, cacheName);
HazelcastInstance node = createHazelcastInstance(config);
IMap<Integer, Integer> map = getMap(node, mapName);
final CountDownLatch updateEventCount = new CountDownLatch(1);
final QueryCache<Integer, Integer> cache = map.getQueryCache(cacheName, TRUE_PREDICATE, true);
cache.addEntryListener(new EntryUpdatedListener() {
@Override
public void entryUpdated(EntryEvent event) {
updateEventCount.countDown();
}
}, false);
for (int i = 0; i < 100; i++) {
map.put(i, i);
}
// update same key to control whether coalescing kicks in.
for (int i = 0; i < 500; i++) {
map.put(0, i);
}
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(100, cache.size());
}
});
assertOpenEventually(updateEventCount);
}
Aggregations