Search in sources :

Example 11 with EventFilter

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();
}
Also used : EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) CachePartitionLostEventFilter(com.hazelcast.cache.impl.event.CachePartitionLostEventFilter) CachePartitionLostEventFilter(com.hazelcast.cache.impl.event.CachePartitionLostEventFilter) EventFilter(com.hazelcast.spi.impl.eventservice.EventFilter) InternalCachePartitionLostListenerAdapter(com.hazelcast.cache.impl.event.InternalCachePartitionLostListenerAdapter)

Example 12 with EventFilter

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);
}
Also used : CALLER_RUNS(com.hazelcast.internal.util.ConcurrencyUtil.CALLER_RUNS) InternalCompletableFuture.newCompletedFuture(com.hazelcast.spi.impl.InternalCompletableFuture.newCompletedFuture) Connection(com.hazelcast.internal.nio.Connection) CachePartitionLostEventFilter(com.hazelcast.cache.impl.event.CachePartitionLostEventFilter) EventService(com.hazelcast.spi.impl.eventservice.EventService) InternalCachePartitionLostListenerAdapter(com.hazelcast.cache.impl.event.InternalCachePartitionLostListenerAdapter) CompletableFuture(java.util.concurrent.CompletableFuture) EventFilter(com.hazelcast.spi.impl.eventservice.EventFilter) EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) UUID(java.util.UUID) Node(com.hazelcast.instance.impl.Node) AbstractAddListenerMessageTask(com.hazelcast.client.impl.protocol.task.AbstractAddListenerMessageTask) CachePartitionLostListener(com.hazelcast.cache.impl.event.CachePartitionLostListener) CacheService(com.hazelcast.cache.impl.CacheService) ICacheService(com.hazelcast.cache.impl.ICacheService) Permission(java.security.Permission) CacheAddPartitionLostListenerCodec(com.hazelcast.client.impl.protocol.codec.CacheAddPartitionLostListenerCodec) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) CachePartitionLostListener(com.hazelcast.cache.impl.event.CachePartitionLostListener) EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) EventService(com.hazelcast.spi.impl.eventservice.EventService) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) CachePartitionLostEventFilter(com.hazelcast.cache.impl.event.CachePartitionLostEventFilter) CachePartitionLostEventFilter(com.hazelcast.cache.impl.event.CachePartitionLostEventFilter) EventFilter(com.hazelcast.spi.impl.eventservice.EventFilter) InternalCachePartitionLostListenerAdapter(com.hazelcast.cache.impl.event.InternalCachePartitionLostListenerAdapter) CacheService(com.hazelcast.cache.impl.CacheService) ICacheService(com.hazelcast.cache.impl.ICacheService)

Example 13 with EventFilter

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);
}
Also used : EventFilter(com.hazelcast.spi.impl.eventservice.EventFilter)

Example 14 with EventFilter

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);
}
Also used : EventFilter(com.hazelcast.spi.impl.eventservice.EventFilter)

Example 15 with EventFilter

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();
}
Also used : ListenerAdapters.createListenerAdapter(com.hazelcast.map.impl.ListenerAdapters.createListenerAdapter) EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) EventFilter(com.hazelcast.spi.impl.eventservice.EventFilter)

Aggregations

EventFilter (com.hazelcast.spi.impl.eventservice.EventFilter)21 EntryEventFilter (com.hazelcast.map.impl.EntryEventFilter)7 EventRegistration (com.hazelcast.spi.impl.eventservice.EventRegistration)7 TrueEventFilter (com.hazelcast.spi.impl.eventservice.impl.TrueEventFilter)6 QueryEventFilter (com.hazelcast.map.impl.query.QueryEventFilter)5 ListenerAdapters.createListenerAdapter (com.hazelcast.map.impl.ListenerAdapters.createListenerAdapter)3 QueryCacheEventService (com.hazelcast.map.impl.querycache.QueryCacheEventService)3 ReplicatedEntryEventFilter (com.hazelcast.replicatedmap.impl.record.ReplicatedEntryEventFilter)3 ReplicatedQueryEventFilter (com.hazelcast.replicatedmap.impl.record.ReplicatedQueryEventFilter)3 Nonnull (javax.annotation.Nonnull)3 CachePartitionLostEventFilter (com.hazelcast.cache.impl.event.CachePartitionLostEventFilter)2 InternalCachePartitionLostListenerAdapter (com.hazelcast.cache.impl.event.InternalCachePartitionLostListenerAdapter)2 Data (com.hazelcast.internal.serialization.Data)2 MapPartitionLostEventFilter (com.hazelcast.map.impl.MapPartitionLostEventFilter)2 UUID (java.util.UUID)2 CacheService (com.hazelcast.cache.impl.CacheService)1 ICacheService (com.hazelcast.cache.impl.ICacheService)1 CachePartitionLostListener (com.hazelcast.cache.impl.event.CachePartitionLostListener)1 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)1 CacheAddPartitionLostListenerCodec (com.hazelcast.client.impl.protocol.codec.CacheAddPartitionLostListenerCodec)1