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();
}
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());
}
}
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();
}
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();
}
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();
}
Aggregations