use of com.hazelcast.spi.impl.eventservice.EventFilter in project hazelcast by hazelcast.
the class CacheProxy method addPartitionLostListener.
@Override
public UUID addPartitionLostListener(CachePartitionLostListener listener) {
checkNotNull(listener, "CachePartitionLostListener can't be null");
EventFilter filter = new CachePartitionLostEventFilter();
listener = injectDependencies(listener);
InternalCachePartitionLostListenerAdapter listenerAdapter = new InternalCachePartitionLostListenerAdapter(listener);
EventRegistration registration = getService().getNodeEngine().getEventService().registerListener(AbstractCacheService.SERVICE_NAME, name, filter, listenerAdapter);
return registration.getId();
}
use of com.hazelcast.spi.impl.eventservice.EventFilter in project hazelcast by hazelcast.
the class CacheAddPartitionLostListenerMessageTask method processInternal.
@Override
protected CompletableFuture<UUID> processInternal() {
CachePartitionLostListener listener = event -> {
if (endpoint.isAlive()) {
ClientMessage eventMessage = CacheAddPartitionLostListenerCodec.encodeCachePartitionLostEvent(event.getPartitionId(), event.getMember().getUuid());
sendClientMessage(null, eventMessage);
}
};
InternalCachePartitionLostListenerAdapter listenerAdapter = new InternalCachePartitionLostListenerAdapter(listener);
EventFilter filter = new CachePartitionLostEventFilter();
CacheService service = getService(CacheService.SERVICE_NAME);
EventService eventService = service.getNodeEngine().getEventService();
if (parameters.localOnly) {
return newCompletedFuture(eventService.registerLocalListener(ICacheService.SERVICE_NAME, parameters.name, filter, listenerAdapter).getId());
}
return eventService.registerListenerAsync(ICacheService.SERVICE_NAME, parameters.name, filter, listenerAdapter).thenApplyAsync(EventRegistration::getId, CALLER_RUNS);
}
use of com.hazelcast.spi.impl.eventservice.EventFilter in project hazelcast by hazelcast.
the class MapService method onDeregister.
@Override
public void onDeregister(Object service, String serviceName, String mapName, EventRegistration registration) {
EventFilter filter = registration.getFilter();
if (!(filter instanceof EventListenerFilter) || !filter.eval(INVALIDATION.getType())) {
return;
}
mapServiceContext.getEventListenerCounter().decCounter(mapName);
}
use of com.hazelcast.spi.impl.eventservice.EventFilter in project hazelcast by hazelcast.
the class MapService method onRegister.
@Override
public void onRegister(Object service, String serviceName, String mapName, EventRegistration registration) {
EventFilter filter = registration.getFilter();
if (!(filter instanceof EventListenerFilter) || !filter.eval(INVALIDATION.getType())) {
return;
}
mapServiceContext.getEventListenerCounter().incCounter(mapName);
}
use of com.hazelcast.spi.impl.eventservice.EventFilter 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();
}
Aggregations