use of com.hazelcast.map.impl.querycache.accumulator.Accumulator in project hazelcast by hazelcast.
the class AccumulatorSweeper method flushAccumulator.
public static void flushAccumulator(PublisherContext publisherContext, int partitionId) {
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();
Accumulator accumulator = accumulatorMap.get(partitionId);
if (accumulator == null) {
continue;
}
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);
}
}
}
use of com.hazelcast.map.impl.querycache.accumulator.Accumulator in project hazelcast by hazelcast.
the class QueryCacheUtilTest method getAccumulatorOrNull_whenNoAccumulatorsRegistered_thenReturnNull.
@Test
public void getAccumulatorOrNull_whenNoAccumulatorsRegistered_thenReturnNull() {
Accumulator accumulator = getAccumulatorOrNull(context, "myMap", "myCache", -1);
assertNull(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);
}
}
}
}
use of com.hazelcast.map.impl.querycache.accumulator.Accumulator in project hazelcast by hazelcast.
the class QueryCacheEventPublisher method hintMapEvent.
// TODO known issue: Locked keys will also be cleared from the query-cache after calling a map-wide event like clear/evictAll
public void hintMapEvent(Address caller, String mapName, EntryEventType eventType, int numberOfEntriesAffected, int partitionId) {
// this collection contains all defined query-caches on this map.
Collection<PartitionAccumulatorRegistry> partitionAccumulatorRegistries = getPartitionAccumulatorRegistries(mapName);
for (PartitionAccumulatorRegistry accumulatorRegistry : partitionAccumulatorRegistries) {
Accumulator accumulator = accumulatorRegistry.getOrCreate(partitionId);
QueryCacheEventData singleEventData = newQueryCacheEventDataBuilder(false).withPartitionId(partitionId).withEventType(eventType.getType()).build();
accumulator.accumulate(singleEventData);
}
}
Aggregations