use of com.hazelcast.spi.impl.eventservice.EventRegistration in project hazelcast by hazelcast.
the class MapServiceContextImpl method addLocalPartitionLostListener.
@Override
public UUID 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();
}
use of com.hazelcast.spi.impl.eventservice.EventRegistration in project hazelcast by hazelcast.
the class MapServiceContextImpl method addListenerInternalAsync.
private CompletableFuture<UUID> addListenerInternalAsync(Object listener, EventFilter filter, String mapName) {
ListenerAdapter listenerAdaptor = createListenerAdapter(listener);
filter = adoptEventFilter(filter, listenerAdaptor);
return eventService.registerListenerAsync(SERVICE_NAME, mapName, filter, listenerAdaptor).thenApplyAsync(EventRegistration::getId, CALLER_RUNS);
}
use of com.hazelcast.spi.impl.eventservice.EventRegistration in project hazelcast by hazelcast.
the class MapServiceContextImpl method addLocalListenerAdapter.
@Override
public UUID addLocalListenerAdapter(ListenerAdapter adapter, String mapName) {
EventService eventService = getNodeEngine().getEventService();
EventRegistration registration = eventService.registerLocalListener(MapService.SERVICE_NAME, mapName, adapter);
return registration.getId();
}
use of com.hazelcast.spi.impl.eventservice.EventRegistration 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.EventRegistration in project hazelcast by hazelcast.
the class MapEventPublisherImpl method publishEvent.
/**
* Publish the event to the specified listener {@code registrations} if
* the event passes the filters specified by the {@link FilteringStrategy}.
* <p>
* The method uses the hashcode of the {@code dataKey} to order the
* events in the event subsystem. This means that all events for the same
* key will be ordered. Events with different keys need not be ordered.
*
* @param registrations the listener registrations to which we are publishing
* @param caller the address of the caller that caused the event
* @param mapName the map name
* @param eventType the event type
* @param dataKey the key of the event map entry
* @param oldValue the old value of the map entry
* @param newValue the new value of the map entry
* @param mergingValue the value used when performing a merge
* operation in case of a {@link EntryEventType#MERGED} event.
* This value together with the old value produced the new value.
*/
private void publishEvent(Collection<EventRegistration> registrations, Address caller, String mapName, EntryEventType eventType, Data dataKey, Object oldValue, Object newValue, Object mergingValue) {
EntryEventDataCache eventDataCache = filteringStrategy.getEntryEventDataCache();
int orderKey = pickOrderKey(dataKey);
for (EventRegistration registration : registrations) {
publishEventQuietly(caller, mapName, eventType, dataKey, oldValue, newValue, mergingValue, eventDataCache, orderKey, registration);
}
// if events were generated, execute the post-publish hook on each one
if (!eventDataCache.isEmpty()) {
postPublishEvent(eventDataCache.eventDataIncludingValues(), eventDataCache.eventDataExcludingValues());
}
}
Aggregations