use of com.hazelcast.core.EntryListener in project Openfire by igniterealtime.
the class ClusterListener method simulateCacheInserts.
private void simulateCacheInserts(Cache cache) {
EntryListener EntryListener = EntryListeners.get(cache);
if (EntryListener != null) {
if (cache instanceof CacheWrapper) {
Cache wrapped = ((CacheWrapper) cache).getWrappedCache();
if (wrapped instanceof ClusteredCache) {
ClusteredCache clusteredCache = (ClusteredCache) wrapped;
for (Map.Entry entry : (Set<Map.Entry>) cache.entrySet()) {
EntryEvent event = new EntryEvent(clusteredCache.map.getName(), cluster.getLocalMember(), EntryEventType.ADDED.getType(), entry.getKey(), null, entry.getValue());
EntryListener.entryAdded(event);
}
}
}
}
}
use of com.hazelcast.core.EntryListener in project hazelcast by hazelcast.
the class ClientMapTest method testPredicateListenerWithPortableKey.
@Test
@SuppressWarnings("deprecation")
public void testPredicateListenerWithPortableKey() throws InterruptedException {
IMap<Portable, Integer> tradeMap = createMap();
final AtomicInteger atomicInteger = new AtomicInteger(0);
final CountDownLatch countDownLatch = new CountDownLatch(1);
EntryListener listener = new EntryAdapter() {
@Override
public void entryAdded(EntryEvent event) {
atomicInteger.incrementAndGet();
countDownLatch.countDown();
}
};
NamedPortable key = new NamedPortable("a", 1);
tradeMap.addEntryListener(listener, key, true);
NamedPortable key2 = new NamedPortable("b", 2);
tradeMap.put(key2, 1);
assertFalse(countDownLatch.await(5, TimeUnit.SECONDS));
assertEquals(0, atomicInteger.get());
}
use of com.hazelcast.core.EntryListener in project hazelcast by hazelcast.
the class ClientMapTest method testEntryListener.
/**
* Issue #996
*/
@Test
@SuppressWarnings({ "deprecation", "unchecked" })
public void testEntryListener() throws InterruptedException {
CountDownLatch gateAdd = new CountDownLatch(3);
CountDownLatch gateRemove = new CountDownLatch(1);
CountDownLatch gateEvict = new CountDownLatch(1);
CountDownLatch gateUpdate = new CountDownLatch(1);
CountDownLatch gateClearAll = new CountDownLatch(1);
CountDownLatch gateEvictAll = new CountDownLatch(1);
String mapName = randomString();
IMap<Integer, Deal> serverMap = server.getMap(mapName);
serverMap.put(3, new Deal(3));
IMap<Integer, Deal> clientMap = client.getMap(mapName);
assertEquals(1, clientMap.size());
EntryListener listener = new IntegerDealEntryListener(gateAdd, gateRemove, gateEvict, gateUpdate, gateClearAll, gateEvictAll);
clientMap.addEntryListener(listener, new SqlPredicate("id=1"), 2, true);
clientMap.put(2, new Deal(1));
clientMap.put(2, new Deal(1));
clientMap.remove(2);
clientMap.put(2, new Deal(1));
clientMap.evict(2);
clientMap.clear();
clientMap.put(2, new Deal(1));
clientMap.evictAll();
assertTrue(gateAdd.await(10, TimeUnit.SECONDS));
assertTrue(gateRemove.await(10, TimeUnit.SECONDS));
assertTrue(gateEvict.await(10, TimeUnit.SECONDS));
assertTrue(gateUpdate.await(10, TimeUnit.SECONDS));
assertTrue(gateClearAll.await(10, TimeUnit.SECONDS));
assertTrue(gateEvictAll.await(10, TimeUnit.SECONDS));
}
use of com.hazelcast.core.EntryListener in project hazelcast by hazelcast.
the class MapPreconditionsTest method testAddLocalEntryListenerWithEntryListenerAndPredicate_NullListener.
@Test(expected = UnsupportedOperationException.class)
public void testAddLocalEntryListenerWithEntryListenerAndPredicate_NullListener() throws Exception {
EntryListener entryListener = null;
Predicate predicate = new TruePredicate();
map.addLocalEntryListener(entryListener, predicate, false);
}
use of com.hazelcast.core.EntryListener in project hazelcast by hazelcast.
the class MapPreconditionsTest method testAddEntryListenerWithEntryListener.
@Test(expected = NullPointerException.class)
public void testAddEntryListenerWithEntryListener() throws Exception {
EntryListener entryListener = null;
map.addEntryListener(entryListener, false);
}
Aggregations