Search in sources :

Example 1 with QueryCacheEventService

use of com.hazelcast.map.impl.querycache.QueryCacheEventService in project hazelcast by hazelcast.

the class AccumulatorConsumerOperation method run.

@Override
public void run() throws Exception {
    QueryCacheContext context = getQueryCacheContext();
    QueryCacheEventService queryCacheEventService = context.getQueryCacheEventService();
    EventPublisherAccumulatorProcessor processor = new EventPublisherAccumulatorProcessor(queryCacheEventService);
    AccumulatorHandler<Sequenced> handler = new PublisherAccumulatorHandler(context, processor);
    int processed = 0;
    do {
        Accumulator accumulator = accumulators.poll();
        if (accumulator == null) {
            break;
        }
        if (isLocal()) {
            // consume the accumulator if only this node is the owner
            // of accumulators partition
            publishAccumulator(processor, handler, accumulator);
        } else {
            // if the accumulator is not local, it should be a leftover
            // stayed after partition migrations and remove that accumulator
            removeAccumulator(context, accumulator);
        }
        processed++;
    } while (processed <= maxProcessableAccumulatorCount);
}
Also used : Accumulator(com.hazelcast.map.impl.querycache.accumulator.Accumulator) QueryCacheEventService(com.hazelcast.map.impl.querycache.QueryCacheEventService) EventPublisherAccumulatorProcessor(com.hazelcast.map.impl.querycache.publisher.EventPublisherAccumulatorProcessor) Sequenced(com.hazelcast.map.impl.querycache.event.sequence.Sequenced) PublisherAccumulatorHandler(com.hazelcast.map.impl.querycache.publisher.PublisherAccumulatorHandler) QueryCacheContext(com.hazelcast.map.impl.querycache.QueryCacheContext)

Example 2 with QueryCacheEventService

use of com.hazelcast.map.impl.querycache.QueryCacheEventService in project hazelcast by hazelcast.

the class AbstractQueryCacheEndToEndConstructor method addListener.

private String addListener(QueryCacheRequest request) {
    MapListener listener = request.getListener();
    if (listener == null) {
        return null;
    }
    QueryCacheEventService eventService = subscriberContext.getEventService();
    return eventService.addListener(request.getMapName(), request.getCacheName(), listener);
}
Also used : QueryCacheEventService(com.hazelcast.map.impl.querycache.QueryCacheEventService) MapListener(com.hazelcast.map.listener.MapListener)

Example 3 with QueryCacheEventService

use of com.hazelcast.map.impl.querycache.QueryCacheEventService in project hazelcast by hazelcast.

the class AbstractQueryCacheEndToEndConstructor method createSubscriberAccumulator.

@Override
public final void createSubscriberAccumulator(AccumulatorInfo info) {
    QueryCacheEventService eventService = context.getQueryCacheEventService();
    ListenerAdapter listener = new SubscriberListener(context, info);
    eventService.listenPublisher(info.getMapName(), info.getCacheName(), listener);
}
Also used : ListenerAdapter(com.hazelcast.map.impl.ListenerAdapter) QueryCacheEventService(com.hazelcast.map.impl.querycache.QueryCacheEventService)

Example 4 with QueryCacheEventService

use of com.hazelcast.map.impl.querycache.QueryCacheEventService in project hazelcast by hazelcast.

the class BasicAccumulator method createAccumulatorHandler.

@SuppressWarnings("unchecked")
private AccumulatorHandler<E> createAccumulatorHandler(QueryCacheContext context, AccumulatorInfo info) {
    QueryCacheEventService queryCacheEventService = context.getQueryCacheEventService();
    AccumulatorProcessor<Sequenced> processor = createAccumulatorProcessor(info, queryCacheEventService);
    return (AccumulatorHandler<E>) new PublisherAccumulatorHandler(context, processor);
}
Also used : QueryCacheEventService(com.hazelcast.map.impl.querycache.QueryCacheEventService) Sequenced(com.hazelcast.map.impl.querycache.event.sequence.Sequenced) PublisherAccumulatorHandler(com.hazelcast.map.impl.querycache.publisher.PublisherAccumulatorHandler) PublisherAccumulatorHandler(com.hazelcast.map.impl.querycache.publisher.PublisherAccumulatorHandler)

Example 5 with QueryCacheEventService

use of com.hazelcast.map.impl.querycache.QueryCacheEventService in project hazelcast by hazelcast.

the class DefaultQueryCache method addEntryListener.

@Override
public String addEntryListener(MapListener listener, Predicate<K, V> predicate, K key, boolean includeValue) {
    checkNotNull(listener, "listener cannot be null");
    checkNotNull(predicate, "predicate cannot be null");
    checkNotNull(key, "key cannot be null");
    QueryCacheEventService eventService = getEventService();
    EventFilter filter = new QueryEventFilter(includeValue, toData(key), predicate);
    String mapName = delegate.getName();
    return eventService.addListener(mapName, cacheName, listener, filter);
}
Also used : QueryCacheEventService(com.hazelcast.map.impl.querycache.QueryCacheEventService) QueryEventFilter(com.hazelcast.map.impl.query.QueryEventFilter) EntryEventFilter(com.hazelcast.map.impl.EntryEventFilter) QueryEventFilter(com.hazelcast.map.impl.query.QueryEventFilter) EventFilter(com.hazelcast.spi.EventFilter)

Aggregations

QueryCacheEventService (com.hazelcast.map.impl.querycache.QueryCacheEventService)10 EntryEventFilter (com.hazelcast.map.impl.EntryEventFilter)3 QueryEventFilter (com.hazelcast.map.impl.query.QueryEventFilter)3 EventFilter (com.hazelcast.spi.EventFilter)3 Sequenced (com.hazelcast.map.impl.querycache.event.sequence.Sequenced)2 PublisherAccumulatorHandler (com.hazelcast.map.impl.querycache.publisher.PublisherAccumulatorHandler)2 ListenerAdapter (com.hazelcast.map.impl.ListenerAdapter)1 QueryCacheContext (com.hazelcast.map.impl.querycache.QueryCacheContext)1 Accumulator (com.hazelcast.map.impl.querycache.accumulator.Accumulator)1 LocalCacheWideEventData (com.hazelcast.map.impl.querycache.event.LocalCacheWideEventData)1 LocalEntryEventData (com.hazelcast.map.impl.querycache.event.LocalEntryEventData)1 EventPublisherAccumulatorProcessor (com.hazelcast.map.impl.querycache.publisher.EventPublisherAccumulatorProcessor)1 MapListener (com.hazelcast.map.listener.MapListener)1 Data (com.hazelcast.nio.serialization.Data)1