Search in sources :

Example 6 with EventFilter

use of com.hazelcast.spi.EventFilter in project hazelcast by hazelcast.

the class AbstractQueryCacheConfigurator method setEntryListener.

protected void setEntryListener(String mapName, String cacheName, QueryCacheConfig config) {
    for (EntryListenerConfig listenerConfig : config.getEntryListenerConfigs()) {
        MapListener listener = getListener(listenerConfig);
        if (listener != null) {
            EventFilter filter = new EntryEventFilter(listenerConfig.isIncludeValue(), null);
            eventService.addListener(mapName, cacheName, listener, filter);
        }
    }
}
Also used : MapListener(com.hazelcast.map.listener.MapListener) EntryEventFilter(com.hazelcast.map.impl.EntryEventFilter) EntryListenerConfig(com.hazelcast.config.EntryListenerConfig) EntryEventFilter(com.hazelcast.map.impl.EntryEventFilter) EventFilter(com.hazelcast.spi.EventFilter)

Example 7 with EventFilter

use of com.hazelcast.spi.EventFilter in project hazelcast by hazelcast.

the class DefaultQueryCache method addEntryListener.

@Override
public String addEntryListener(MapListener listener, Predicate<K, V> predicate, K key, boolean includeValue) {
    checkNotNull(listener, "listener cannot be null");
    checkNotNull(predicate, "predicate cannot be null");
    checkNotNull(key, "key cannot be null");
    QueryCacheEventService eventService = getEventService();
    EventFilter filter = new QueryEventFilter(includeValue, toData(key), predicate);
    String mapName = delegate.getName();
    return eventService.addListener(mapName, cacheName, listener, filter);
}
Also used : QueryCacheEventService(com.hazelcast.map.impl.querycache.QueryCacheEventService) QueryEventFilter(com.hazelcast.map.impl.query.QueryEventFilter) EntryEventFilter(com.hazelcast.map.impl.EntryEventFilter) QueryEventFilter(com.hazelcast.map.impl.query.QueryEventFilter) EventFilter(com.hazelcast.spi.EventFilter)

Example 8 with EventFilter

use of com.hazelcast.spi.EventFilter in project hazelcast by hazelcast.

the class DefaultQueryCache method addEntryListener.

@Override
public String addEntryListener(MapListener listener, Predicate<K, V> predicate, boolean includeValue) {
    checkNotNull(listener, "listener cannot be null");
    checkNotNull(predicate, "predicate cannot be null");
    QueryCacheEventService eventService = getEventService();
    EventFilter filter = new QueryEventFilter(includeValue, null, predicate);
    String mapName = delegate.getName();
    return eventService.addListener(mapName, cacheName, listener, filter);
}
Also used : QueryCacheEventService(com.hazelcast.map.impl.querycache.QueryCacheEventService) QueryEventFilter(com.hazelcast.map.impl.query.QueryEventFilter) EntryEventFilter(com.hazelcast.map.impl.EntryEventFilter) QueryEventFilter(com.hazelcast.map.impl.query.QueryEventFilter) EventFilter(com.hazelcast.spi.EventFilter)

Example 9 with EventFilter

use of com.hazelcast.spi.EventFilter in project hazelcast by hazelcast.

the class ReplicatedMapProxy method addEntryListener.

@Override
public String addEntryListener(EntryListener<K, V> listener, Predicate<K, V> predicate) {
    isNotNull(listener, "listener");
    EventFilter eventFilter = new ReplicatedQueryEventFilter(null, predicate);
    return eventPublishingService.addEventListener(listener, eventFilter, name);
}
Also used : ReplicatedQueryEventFilter(com.hazelcast.replicatedmap.impl.record.ReplicatedQueryEventFilter) ReplicatedQueryEventFilter(com.hazelcast.replicatedmap.impl.record.ReplicatedQueryEventFilter) TrueEventFilter(com.hazelcast.spi.impl.eventservice.impl.TrueEventFilter) EventFilter(com.hazelcast.spi.EventFilter) ReplicatedEntryEventFilter(com.hazelcast.replicatedmap.impl.record.ReplicatedEntryEventFilter)

Example 10 with EventFilter

use of com.hazelcast.spi.EventFilter in project hazelcast by hazelcast.

the class MapService method onRegister.

@Override
public void onRegister(Object service, String serviceName, String topic, EventRegistration registration) {
    EventFilter filter = registration.getFilter();
    if (!(filter instanceof EventListenerFilter) || !filter.eval(INVALIDATION.getType())) {
        return;
    }
    MapContainer mapContainer = mapServiceContext.getMapContainer(topic);
    mapContainer.increaseInvalidationListenerCount();
}
Also used : EventFilter(com.hazelcast.spi.EventFilter)

Aggregations

EventFilter (com.hazelcast.spi.EventFilter)20 TrueEventFilter (com.hazelcast.spi.impl.eventservice.impl.TrueEventFilter)8 EntryEventFilter (com.hazelcast.map.impl.EntryEventFilter)7 EventRegistration (com.hazelcast.spi.EventRegistration)7 QueryEventFilter (com.hazelcast.map.impl.query.QueryEventFilter)5 QueryCacheEventService (com.hazelcast.map.impl.querycache.QueryCacheEventService)3 ReplicatedEntryEventFilter (com.hazelcast.replicatedmap.impl.record.ReplicatedEntryEventFilter)3 ReplicatedQueryEventFilter (com.hazelcast.replicatedmap.impl.record.ReplicatedQueryEventFilter)3 CachePartitionLostEventFilter (com.hazelcast.cache.impl.event.CachePartitionLostEventFilter)2 InternalCachePartitionLostListenerAdapter (com.hazelcast.cache.impl.event.InternalCachePartitionLostListenerAdapter)2 ClientEndpoint (com.hazelcast.client.ClientEndpoint)2 ListenerAdapters.createListenerAdapter (com.hazelcast.map.impl.ListenerAdapters.createListenerAdapter)2 MapPartitionLostEventFilter (com.hazelcast.map.impl.MapPartitionLostEventFilter)2 Data (com.hazelcast.nio.serialization.Data)2 CacheService (com.hazelcast.cache.impl.CacheService)1 ICacheService (com.hazelcast.cache.impl.ICacheService)1 CachePartitionLostEvent (com.hazelcast.cache.impl.event.CachePartitionLostEvent)1 CachePartitionLostListener (com.hazelcast.cache.impl.event.CachePartitionLostListener)1 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)1 EntryListenerConfig (com.hazelcast.config.EntryListenerConfig)1