Search in sources :

Example 11 with EventFilter

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

the class CacheProxy method addPartitionLostListener.

@Override
public String addPartitionLostListener(CachePartitionLostListener listener) {
    checkNotNull(listener, "CachePartitionLostListener can't be null");
    EventFilter filter = new CachePartitionLostEventFilter();
    InternalCachePartitionLostListenerAdapter listenerAdapter = new InternalCachePartitionLostListenerAdapter(listener);
    injectDependencies(listener);
    EventRegistration registration = getService().getNodeEngine().getEventService().registerListener(AbstractCacheService.SERVICE_NAME, name, filter, listenerAdapter);
    return registration.getId();
}
Also used : EventRegistration(com.hazelcast.spi.EventRegistration) CachePartitionLostEventFilter(com.hazelcast.cache.impl.event.CachePartitionLostEventFilter) CachePartitionLostEventFilter(com.hazelcast.cache.impl.event.CachePartitionLostEventFilter) EventFilter(com.hazelcast.spi.EventFilter) InternalCachePartitionLostListenerAdapter(com.hazelcast.cache.impl.event.InternalCachePartitionLostListenerAdapter)

Example 12 with EventFilter

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

the class MapEventPublisherImpl method publishEvent.

private void publishEvent(Collection<EventRegistration> registrations, Address caller, String mapName, EntryEventType eventType, Data dataKey, Object oldValue, Object value, Object mergingValue) {
    EntryEventDataCache eventDataCache = filteringStrategy.getEntryEventDataCache();
    int orderKey = pickOrderKey(dataKey);
    for (EventRegistration registration : registrations) {
        EventFilter filter = registration.getFilter();
        // a filtering strategy determines whether the event must be published on the specific
        // event registration and may alter the type of event to be published
        int eventTypeForPublishing = filteringStrategy.doFilter(filter, dataKey, oldValue, value, eventType, mapName);
        if (eventTypeForPublishing == FILTER_DOES_NOT_MATCH) {
            continue;
        }
        EntryEventData eventDataToBePublished = eventDataCache.getOrCreateEventData(mapName, caller, dataKey, value, oldValue, mergingValue, eventTypeForPublishing, isIncludeValue(filter));
        eventService.publishEvent(SERVICE_NAME, registration, eventDataToBePublished, orderKey);
    }
    // if events were generated, execute the post-publish hook on each one
    if (!eventDataCache.isEmpty()) {
        postPublishEvent(eventDataCache.eventDataIncludingValues(), eventDataCache.eventDataExcludingValues());
    }
}
Also used : EventRegistration(com.hazelcast.spi.EventRegistration) EntryEventFilter(com.hazelcast.map.impl.EntryEventFilter) TrueEventFilter(com.hazelcast.spi.impl.eventservice.impl.TrueEventFilter) MapPartitionLostEventFilter(com.hazelcast.map.impl.MapPartitionLostEventFilter) QueryEventFilter(com.hazelcast.map.impl.query.QueryEventFilter) EventFilter(com.hazelcast.spi.EventFilter)

Example 13 with EventFilter

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

the class MapService method onDeregister.

@Override
public void onDeregister(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.decreaseInvalidationListenerCount();
}
Also used : EventFilter(com.hazelcast.spi.EventFilter)

Example 14 with EventFilter

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

the class MapServiceContextImpl method addPartitionLostListener.

@Override
public String addPartitionLostListener(MapPartitionLostListener listener, String mapName) {
    ListenerAdapter listenerAdapter = new InternalMapPartitionLostListenerAdapter(listener);
    EventFilter filter = new MapPartitionLostEventFilter();
    EventRegistration registration = eventService.registerListener(SERVICE_NAME, mapName, filter, listenerAdapter);
    return registration.getId();
}
Also used : ListenerAdapters.createListenerAdapter(com.hazelcast.map.impl.ListenerAdapters.createListenerAdapter) EventRegistration(com.hazelcast.spi.EventRegistration) EventFilter(com.hazelcast.spi.EventFilter) TrueEventFilter(com.hazelcast.spi.impl.eventservice.impl.TrueEventFilter)

Example 15 with EventFilter

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

the class MapServiceContextImpl method addLocalPartitionLostListener.

@Override
public String addLocalPartitionLostListener(MapPartitionLostListener listener, String mapName) {
    ListenerAdapter listenerAdapter = new InternalMapPartitionLostListenerAdapter(listener);
    EventFilter filter = new MapPartitionLostEventFilter();
    EventRegistration registration = eventService.registerLocalListener(SERVICE_NAME, mapName, filter, listenerAdapter);
    return registration.getId();
}
Also used : ListenerAdapters.createListenerAdapter(com.hazelcast.map.impl.ListenerAdapters.createListenerAdapter) EventRegistration(com.hazelcast.spi.EventRegistration) EventFilter(com.hazelcast.spi.EventFilter) TrueEventFilter(com.hazelcast.spi.impl.eventservice.impl.TrueEventFilter)

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