use of com.hazelcast.spi.impl.eventservice.EventFilter in project hazelcast by hazelcast.
the class MapServiceContextImpl method addPartitionLostListener.
@Override
public UUID 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.impl.eventservice.EventFilter in project hazelcast by hazelcast.
the class ReplicatedMapProxy method addEntryListener.
@Nonnull
@Override
public UUID addEntryListener(@Nonnull EntryListener<K, V> listener, @Nonnull Predicate<K, V> predicate, @Nullable K key) {
checkNotNull(listener, NULL_LISTENER_IS_NOT_ALLOWED);
checkNotNull(predicate, NULL_PREDICATE_IS_NOT_ALLOWED);
EventFilter eventFilter = new ReplicatedQueryEventFilter(serializationService.toData(key), predicate);
return eventPublishingService.addLocalEventListener(listener, eventFilter, name);
}
use of com.hazelcast.spi.impl.eventservice.EventFilter in project hazelcast by hazelcast.
the class ReplicatedMapProxy method addEntryListener.
@Nonnull
@Override
public UUID addEntryListener(@Nonnull EntryListener<K, V> listener, @Nullable K key) {
checkNotNull(listener, NULL_LISTENER_IS_NOT_ALLOWED);
EventFilter eventFilter = new ReplicatedEntryEventFilter(serializationService.toData(key));
return eventPublishingService.addLocalEventListener(listener, eventFilter, name);
}
use of com.hazelcast.spi.impl.eventservice.EventFilter in project hazelcast by hazelcast.
the class DefaultQueryCache method addEntryListenerInternal.
private UUID addEntryListenerInternal(MapListener listener, K key, boolean includeValue) {
checkNotNull(listener, "listener cannot be null");
Data keyData = toData(key);
EventFilter filter = new EntryEventFilter(keyData, includeValue);
QueryCacheEventService eventService = getEventService();
String mapName = delegate.getName();
return eventService.addListener(mapName, cacheId, listener, filter);
}
use of com.hazelcast.spi.impl.eventservice.EventFilter in project hazelcast by hazelcast.
the class NodeQueryCacheEventService method publishLocalEvent.
// TODO needs refactoring.
private void publishLocalEvent(String cacheId, Object eventData, Extractors extractors) {
Collection<EventRegistration> eventRegistrations = getRegistrations(cacheId);
if (eventRegistrations.isEmpty()) {
return;
}
for (EventRegistration eventRegistration : eventRegistrations) {
Registration registration = (Registration) eventRegistration;
Object listener = registration.getListener();
if (!(listener instanceof QueryCacheListenerAdapter)) {
continue;
}
Object eventDataToPublish = eventData;
int orderKey = -1;
if (eventDataToPublish instanceof LocalCacheWideEventData) {
orderKey = cacheId.hashCode();
} else if (eventDataToPublish instanceof LocalEntryEventData) {
LocalEntryEventData localEntryEventData = (LocalEntryEventData) eventDataToPublish;
if (localEntryEventData.getEventType() != EventLostEvent.EVENT_TYPE) {
EventFilter filter = registration.getFilter();
if (!canPassFilter(localEntryEventData, filter, extractors)) {
continue;
} else {
boolean includeValue = isIncludeValue(filter);
eventDataToPublish = includeValue ? localEntryEventData : localEntryEventData.cloneWithoutValue();
Data keyData = localEntryEventData.getKeyData();
orderKey = keyData == null ? -1 : keyData.hashCode();
}
}
}
publishEventInternal(registration, eventDataToPublish, orderKey);
}
}
Aggregations