Search in sources :

Example 1 with EntryAddedListener

use of com.hazelcast.map.listener.EntryAddedListener in project hazelcast by hazelcast.

the class EntryEventDataCacheTest method createInvalidationEventRejectingFilter.

private static EventListenerFilter createInvalidationEventRejectingFilter() {
    ListenerAdapter listenerAdapter = createListenerAdapter(new EntryAddedListener() {

        @Override
        public void entryAdded(EntryEvent event) {
        }
    });
    int flags = setAndGetListenerFlags(listenerAdapter);
    return new EventListenerFilter(flags, TrueEventFilter.INSTANCE);
}
Also used : ListenerAdapters.createListenerAdapter(com.hazelcast.map.impl.ListenerAdapters.createListenerAdapter) ListenerAdapter(com.hazelcast.map.impl.ListenerAdapter) EntryEvent(com.hazelcast.core.EntryEvent) EntryAddedListener(com.hazelcast.map.listener.EntryAddedListener) EventListenerFilter(com.hazelcast.map.impl.EventListenerFilter)

Example 2 with EntryAddedListener

use of com.hazelcast.map.listener.EntryAddedListener in project hazelcast by hazelcast.

the class QueryCacheIMapEventHandlingTest method testEvent_EXPIRED.

@Test
public void testEvent_EXPIRED() throws Exception {
    int key = 1;
    int value = 1;
    final CountDownLatch latch = new CountDownLatch(1);
    queryCache.addEntryListener(new EntryAddedListener() {

        @Override
        public void entryAdded(EntryEvent event) {
            latch.countDown();
        }
    }, true);
    map.put(key, value, 1, SECONDS);
    latch.await();
    sleepSeconds(1);
    // map#get creates EXPIRED event
    map.get(key);
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertEquals(0, queryCache.size());
        }
    });
}
Also used : EntryEvent(com.hazelcast.core.EntryEvent) AssertTask(com.hazelcast.test.AssertTask) CountDownLatch(java.util.concurrent.CountDownLatch) EntryAddedListener(com.hazelcast.map.listener.EntryAddedListener) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 3 with EntryAddedListener

use of com.hazelcast.map.listener.EntryAddedListener in project hazelcast by hazelcast.

the class ClientQueryCacheEventHandlingTest method testEvent_EXPIRED.

@Test
public void testEvent_EXPIRED() throws Exception {
    int key = 1;
    int value = 1;
    final CountDownLatch latch = new CountDownLatch(1);
    queryCache.addEntryListener(new EntryAddedListener() {

        @Override
        public void entryAdded(EntryEvent event) {
            latch.countDown();
        }
    }, true);
    map.put(key, value, 1, SECONDS);
    latch.await();
    sleepSeconds(1);
    // map#get creates EXPIRED event
    map.get(key);
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertEquals(0, queryCache.size());
        }
    });
}
Also used : EntryEvent(com.hazelcast.core.EntryEvent) AssertTask(com.hazelcast.test.AssertTask) CountDownLatch(java.util.concurrent.CountDownLatch) EntryAddedListener(com.hazelcast.map.listener.EntryAddedListener) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

EntryEvent (com.hazelcast.core.EntryEvent)3 EntryAddedListener (com.hazelcast.map.listener.EntryAddedListener)3 AssertTask (com.hazelcast.test.AssertTask)2 ParallelTest (com.hazelcast.test.annotation.ParallelTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 Test (org.junit.Test)2 EventListenerFilter (com.hazelcast.map.impl.EventListenerFilter)1 ListenerAdapter (com.hazelcast.map.impl.ListenerAdapter)1 ListenerAdapters.createListenerAdapter (com.hazelcast.map.impl.ListenerAdapters.createListenerAdapter)1