use of com.hazelcast.spi.impl.eventservice.EventRegistration in project hazelcast by hazelcast.
the class AbstractCacheService method deregisterAllListener.
@Override
public void deregisterAllListener(String cacheNameWithPrefix) {
EventService eventService = getNodeEngine().getEventService();
Collection<EventRegistration> registrations = eventService.getRegistrations(SERVICE_NAME, cacheNameWithPrefix);
if (registrations != null) {
for (EventRegistration registration : registrations) {
removeFromLocalResources(registration.getId());
}
}
eventService.deregisterAllListeners(AbstractCacheService.SERVICE_NAME, cacheNameWithPrefix);
CacheContext cacheContext = cacheContexts.get(cacheNameWithPrefix);
if (cacheContext != null) {
cacheContext.resetCacheEntryListenerCount();
cacheContext.resetInvalidationListenerCount();
}
}
use of com.hazelcast.spi.impl.eventservice.EventRegistration 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.EventRegistration in project hazelcast by hazelcast.
the class ClientEndpointManagerImpl method sendClientEvent.
private void sendClientEvent(ClientEvent event) {
final Collection<EventRegistration> regs = eventService.getRegistrations(SERVICE_NAME, SERVICE_NAME);
UUID uuid = event.getUuid();
eventService.publishEvent(SERVICE_NAME, regs, event, uuid.hashCode());
}
use of com.hazelcast.spi.impl.eventservice.EventRegistration 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.EventRegistration in project hazelcast by hazelcast.
the class ListAddListenerMessageTask method processInternal.
@Override
protected CompletableFuture<UUID> processInternal() {
Data partitionKey = serializationService.toData(parameters.name);
ItemListener listener = createItemListener(endpoint, partitionKey);
EventService eventService = clientEngine.getEventService();
CollectionEventFilter filter = new CollectionEventFilter(parameters.includeValue);
if (parameters.localOnly) {
return newCompletedFuture(eventService.registerLocalListener(getServiceName(), parameters.name, filter, listener).getId());
}
return eventService.registerListenerAsync(getServiceName(), parameters.name, filter, listener).thenApplyAsync(EventRegistration::getId, CALLER_RUNS);
}
Aggregations