Search in sources :

Example 11 with Accumulator

use of com.hazelcast.map.impl.querycache.accumulator.Accumulator in project hazelcast by hazelcast.

the class AccumulatorSweeper method flushAllAccumulators.

public static void flushAllAccumulators(PublisherContext publisherContext) {
    QueryCacheContext context = publisherContext.getContext();
    EventPublisherAccumulatorProcessor processor = new EventPublisherAccumulatorProcessor(context.getQueryCacheEventService());
    PublisherAccumulatorHandler handler = new PublisherAccumulatorHandler(context, processor);
    MapPublisherRegistry mapPublisherRegistry = publisherContext.getMapPublisherRegistry();
    Map<String, PublisherRegistry> allPublisherRegistryMap = mapPublisherRegistry.getAll();
    for (PublisherRegistry publisherRegistry : allPublisherRegistryMap.values()) {
        Map<String, PartitionAccumulatorRegistry> accumulatorRegistryMap = publisherRegistry.getAll();
        for (PartitionAccumulatorRegistry accumulatorRegistry : accumulatorRegistryMap.values()) {
            Map<Integer, Accumulator> accumulatorMap = accumulatorRegistry.getAll();
            for (Map.Entry<Integer, Accumulator> entry : accumulatorMap.entrySet()) {
                Integer partitionId = entry.getKey();
                Accumulator accumulator = entry.getValue();
                processor.setInfo(accumulator.getInfo());
                // give 0 to delay-time in order to fetch all events in the accumulator
                accumulator.poll(handler, 0, TimeUnit.SECONDS);
                // send end event
                QueryCacheEventData eventData = createEndOfSequenceEvent(partitionId);
                processor.process(eventData);
            }
        }
    }
}
Also used : Accumulator(com.hazelcast.map.impl.querycache.accumulator.Accumulator) QueryCacheContext(com.hazelcast.map.impl.querycache.QueryCacheContext) Map(java.util.Map) ConcurrentMap(java.util.concurrent.ConcurrentMap) QueryCacheEventData(com.hazelcast.map.impl.querycache.event.QueryCacheEventData)

Example 12 with Accumulator

use of com.hazelcast.map.impl.querycache.accumulator.Accumulator in project hazelcast by hazelcast.

the class DefaultQueryCache method getOrNullSubscriberAccumulator.

private SubscriberAccumulator getOrNullSubscriberAccumulator() {
    SubscriberContext subscriberContext = context.getSubscriberContext();
    MapSubscriberRegistry mapSubscriberRegistry = subscriberContext.getMapSubscriberRegistry();
    SubscriberRegistry subscriberRegistry = mapSubscriberRegistry.getOrNull(mapName);
    if (subscriberRegistry == null) {
        return null;
    }
    Accumulator accumulator = subscriberRegistry.getOrNull(cacheId);
    if (accumulator == null) {
        return null;
    }
    return (SubscriberAccumulator) accumulator;
}
Also used : Accumulator(com.hazelcast.map.impl.querycache.accumulator.Accumulator)

Example 13 with Accumulator

use of com.hazelcast.map.impl.querycache.accumulator.Accumulator in project hazelcast by hazelcast.

the class ClientQueryCacheContext method recreateAllCaches.

public void recreateAllCaches() {
    // Since query cache is lost we are firing event lost event for each cache and for each partition
    QueryCacheFactory queryCacheFactory = subscriberContext.getQueryCacheFactory();
    Map<String, SubscriberRegistry> registryMap = subscriberContext.getMapSubscriberRegistry().getAll();
    for (SubscriberRegistry subscriberRegistry : registryMap.values()) {
        Map<String, Accumulator> accumulatorMap = subscriberRegistry.getAll();
        for (Accumulator accumulator : accumulatorMap.values()) {
            AccumulatorInfo info = accumulator.getInfo();
            String cacheId = info.getCacheId();
            InternalQueryCache queryCache = queryCacheFactory.getOrNull(cacheId);
            if (queryCache != null) {
                queryCache.recreate();
            }
        }
    }
}
Also used : QueryCacheFactory(com.hazelcast.map.impl.querycache.subscriber.QueryCacheFactory) Accumulator(com.hazelcast.map.impl.querycache.accumulator.Accumulator) SubscriberRegistry(com.hazelcast.map.impl.querycache.subscriber.SubscriberRegistry) InternalQueryCache(com.hazelcast.map.impl.querycache.subscriber.InternalQueryCache) AccumulatorInfo(com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfo)

Aggregations

Accumulator (com.hazelcast.map.impl.querycache.accumulator.Accumulator)13 QueryCacheContext (com.hazelcast.map.impl.querycache.QueryCacheContext)7 QueryCacheEventData (com.hazelcast.map.impl.querycache.event.QueryCacheEventData)4 Sequenced (com.hazelcast.map.impl.querycache.event.sequence.Sequenced)3 DefaultQueryCacheEventData (com.hazelcast.map.impl.querycache.event.DefaultQueryCacheEventData)2 PartitionAccumulatorRegistry (com.hazelcast.map.impl.querycache.publisher.PartitionAccumulatorRegistry)2 Node (com.hazelcast.instance.impl.Node)1 Data (com.hazelcast.internal.serialization.Data)1 MapService (com.hazelcast.map.impl.MapService)1 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)1 QueryCacheEventService (com.hazelcast.map.impl.querycache.QueryCacheEventService)1 AccumulatorInfo (com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfo)1 EventPublisherAccumulatorProcessor (com.hazelcast.map.impl.querycache.publisher.EventPublisherAccumulatorProcessor)1 PublisherAccumulatorHandler (com.hazelcast.map.impl.querycache.publisher.PublisherAccumulatorHandler)1 InternalQueryCache (com.hazelcast.map.impl.querycache.subscriber.InternalQueryCache)1 QueryCacheFactory (com.hazelcast.map.impl.querycache.subscriber.QueryCacheFactory)1 SubscriberRegistry (com.hazelcast.map.impl.querycache.subscriber.SubscriberRegistry)1 Accessors.getNode (com.hazelcast.test.Accessors.getNode)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1