Search in sources :

Example 1 with EventPublisherAccumulatorProcessor

use of com.hazelcast.map.impl.querycache.publisher.EventPublisherAccumulatorProcessor 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)

Aggregations

QueryCacheContext (com.hazelcast.map.impl.querycache.QueryCacheContext)1 QueryCacheEventService (com.hazelcast.map.impl.querycache.QueryCacheEventService)1 Accumulator (com.hazelcast.map.impl.querycache.accumulator.Accumulator)1 Sequenced (com.hazelcast.map.impl.querycache.event.sequence.Sequenced)1 EventPublisherAccumulatorProcessor (com.hazelcast.map.impl.querycache.publisher.EventPublisherAccumulatorProcessor)1 PublisherAccumulatorHandler (com.hazelcast.map.impl.querycache.publisher.PublisherAccumulatorHandler)1