Search in sources :

Example 1 with PartitionAccumulatorRegistry

use of com.hazelcast.map.impl.querycache.publisher.PartitionAccumulatorRegistry in project hazelcast by hazelcast.

the class MapPostJoinAwareService method getAccumulatorInfoList.

private List<AccumulatorInfo> getAccumulatorInfoList() {
    List<AccumulatorInfo> infoList = new ArrayList<AccumulatorInfo>();
    PublisherContext publisherContext = mapServiceContext.getQueryCacheContext().getPublisherContext();
    MapPublisherRegistry mapPublisherRegistry = publisherContext.getMapPublisherRegistry();
    Map<String, PublisherRegistry> cachesOfMaps = mapPublisherRegistry.getAll();
    Collection<PublisherRegistry> publisherRegistries = cachesOfMaps.values();
    for (PublisherRegistry publisherRegistry : publisherRegistries) {
        Collection<PartitionAccumulatorRegistry> partitionAccumulatorRegistries = publisherRegistry.getAll().values();
        for (PartitionAccumulatorRegistry accumulatorRegistry : partitionAccumulatorRegistries) {
            AccumulatorInfo info = accumulatorRegistry.getInfo();
            infoList.add(info);
        }
    }
    return infoList;
}
Also used : MapPublisherRegistry(com.hazelcast.map.impl.querycache.publisher.MapPublisherRegistry) PartitionAccumulatorRegistry(com.hazelcast.map.impl.querycache.publisher.PartitionAccumulatorRegistry) MapPublisherRegistry(com.hazelcast.map.impl.querycache.publisher.MapPublisherRegistry) PublisherRegistry(com.hazelcast.map.impl.querycache.publisher.PublisherRegistry) ArrayList(java.util.ArrayList) AccumulatorInfo(com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfo) PublisherContext(com.hazelcast.map.impl.querycache.publisher.PublisherContext)

Example 2 with PartitionAccumulatorRegistry

use of com.hazelcast.map.impl.querycache.publisher.PartitionAccumulatorRegistry in project hazelcast by hazelcast.

the class QueryCacheEventPublisher method addEventToQueryCache.

public void addEventToQueryCache(Object eventData) {
    checkInstanceOf(EventData.class, eventData, "eventData");
    String mapName = ((EventData) eventData).getMapName();
    int eventType = ((EventData) eventData).getEventType();
    // only handling EVICTED event for that key is sufficient
    if (EXPIRED.getType() == eventType) {
        return;
    }
    // this collection contains all defined query-caches on an IMap
    Collection<PartitionAccumulatorRegistry> partitionAccumulatorRegistries = getPartitionAccumulatorRegistries(mapName);
    if (isEmpty(partitionAccumulatorRegistries)) {
        return;
    }
    if (!(eventData instanceof EntryEventData)) {
        return;
    }
    EntryEventData entryEvenData = (EntryEventData) eventData;
    Data dataKey = entryEvenData.getDataKey();
    Data dataNewValue = entryEvenData.getDataNewValue();
    Data dataOldValue = entryEvenData.getDataOldValue();
    int partitionId = queryCacheContext.getPartitionId(entryEvenData.dataKey);
    for (PartitionAccumulatorRegistry registry : partitionAccumulatorRegistries) {
        DefaultQueryCacheEventData singleEventData = (DefaultQueryCacheEventData) convertQueryCacheEventDataOrNull(registry, dataKey, dataNewValue, dataOldValue, eventType, partitionId);
        if (singleEventData == null) {
            continue;
        }
        Accumulator accumulator = registry.getOrCreate(partitionId);
        accumulator.accumulate(singleEventData);
    }
}
Also used : Accumulator(com.hazelcast.map.impl.querycache.accumulator.Accumulator) PartitionAccumulatorRegistry(com.hazelcast.map.impl.querycache.publisher.PartitionAccumulatorRegistry) DefaultQueryCacheEventData(com.hazelcast.map.impl.querycache.event.DefaultQueryCacheEventData) Data(com.hazelcast.nio.serialization.Data) DefaultQueryCacheEventData(com.hazelcast.map.impl.querycache.event.DefaultQueryCacheEventData) QueryCacheEventData(com.hazelcast.map.impl.querycache.event.QueryCacheEventData) DefaultQueryCacheEventData(com.hazelcast.map.impl.querycache.event.DefaultQueryCacheEventData) QueryCacheEventData(com.hazelcast.map.impl.querycache.event.QueryCacheEventData)

Example 3 with PartitionAccumulatorRegistry

use of com.hazelcast.map.impl.querycache.publisher.PartitionAccumulatorRegistry in project hazelcast by hazelcast.

the class PublisherCreateOperation method registerPublisherAccumulator.

private void registerPublisherAccumulator() {
    String mapName = info.getMapName();
    String cacheName = info.getCacheName();
    PublisherContext publisherContext = getPublisherContext();
    MapPublisherRegistry mapPublisherRegistry = publisherContext.getMapPublisherRegistry();
    PublisherRegistry publisherRegistry = mapPublisherRegistry.getOrCreate(mapName);
    PartitionAccumulatorRegistry partitionAccumulatorRegistry = publisherRegistry.getOrCreate(cacheName);
    partitionAccumulatorRegistry.setUuid(getCallerUuid());
}
Also used : MapPublisherRegistry(com.hazelcast.map.impl.querycache.publisher.MapPublisherRegistry) PartitionAccumulatorRegistry(com.hazelcast.map.impl.querycache.publisher.PartitionAccumulatorRegistry) MapPublisherRegistry(com.hazelcast.map.impl.querycache.publisher.MapPublisherRegistry) PublisherRegistry(com.hazelcast.map.impl.querycache.publisher.PublisherRegistry) PublisherContext(com.hazelcast.map.impl.querycache.publisher.PublisherContext)

Example 4 with PartitionAccumulatorRegistry

use of com.hazelcast.map.impl.querycache.publisher.PartitionAccumulatorRegistry in project hazelcast by hazelcast.

the class AccumulatorScannerTask method scanAccumulators.

void scanAccumulators() {
    PublisherContext publisherContext = context.getPublisherContext();
    MapPublisherRegistry mapPublisherRegistry = publisherContext.getMapPublisherRegistry();
    Map<String, PublisherRegistry> publisherRegistryMap = mapPublisherRegistry.getAll();
    Set<Map.Entry<String, PublisherRegistry>> publishers = publisherRegistryMap.entrySet();
    for (Map.Entry<String, PublisherRegistry> entry : publishers) {
        PublisherRegistry publisherRegistry = entry.getValue();
        Map<String, PartitionAccumulatorRegistry> accumulatorRegistryMap = publisherRegistry.getAll();
        Set<Map.Entry<String, PartitionAccumulatorRegistry>> accumulators = accumulatorRegistryMap.entrySet();
        for (Map.Entry<String, PartitionAccumulatorRegistry> accumulatorRegistryEntry : accumulators) {
            PartitionAccumulatorRegistry accumulatorRegistry = accumulatorRegistryEntry.getValue();
            Map<Integer, Accumulator> accumulatorMap = accumulatorRegistry.getAll();
            for (Map.Entry<Integer, Accumulator> accumulatorEntry : accumulatorMap.entrySet()) {
                Integer partitionId = accumulatorEntry.getKey();
                Accumulator accumulator = accumulatorEntry.getValue();
                int size = accumulator.size();
                if (size > 0) {
                    consumer.consume(accumulator, partitionId);
                }
            }
        }
    }
    sendConsumerOperation();
    consumer.reset();
}
Also used : MapPublisherRegistry(com.hazelcast.map.impl.querycache.publisher.MapPublisherRegistry) PartitionAccumulatorRegistry(com.hazelcast.map.impl.querycache.publisher.PartitionAccumulatorRegistry) MapPublisherRegistry(com.hazelcast.map.impl.querycache.publisher.MapPublisherRegistry) PublisherRegistry(com.hazelcast.map.impl.querycache.publisher.PublisherRegistry) PublisherContext(com.hazelcast.map.impl.querycache.publisher.PublisherContext) HashMap(java.util.HashMap) Map(java.util.Map)

Example 5 with PartitionAccumulatorRegistry

use of com.hazelcast.map.impl.querycache.publisher.PartitionAccumulatorRegistry in project hazelcast by hazelcast.

the class AccumulatorConsumerOperation method removeAccumulator.

private void removeAccumulator(QueryCacheContext context, Accumulator accumulator) {
    PublisherContext publisherContext = context.getPublisherContext();
    MapPublisherRegistry mapPublisherRegistry = publisherContext.getMapPublisherRegistry();
    AccumulatorInfo info = accumulator.getInfo();
    String mapName = info.getMapName();
    String cacheName = info.getCacheName();
    PublisherRegistry publisherRegistry = mapPublisherRegistry.getOrNull(mapName);
    if (publisherRegistry == null) {
        return;
    }
    PartitionAccumulatorRegistry partitionAccumulatorRegistry = publisherRegistry.getOrNull(cacheName);
    if (partitionAccumulatorRegistry == null) {
        return;
    }
    partitionAccumulatorRegistry.remove(getPartitionId());
}
Also used : MapPublisherRegistry(com.hazelcast.map.impl.querycache.publisher.MapPublisherRegistry) PartitionAccumulatorRegistry(com.hazelcast.map.impl.querycache.publisher.PartitionAccumulatorRegistry) MapPublisherRegistry(com.hazelcast.map.impl.querycache.publisher.MapPublisherRegistry) PublisherRegistry(com.hazelcast.map.impl.querycache.publisher.PublisherRegistry) AccumulatorInfo(com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfo) PublisherContext(com.hazelcast.map.impl.querycache.publisher.PublisherContext)

Aggregations

PartitionAccumulatorRegistry (com.hazelcast.map.impl.querycache.publisher.PartitionAccumulatorRegistry)7 MapPublisherRegistry (com.hazelcast.map.impl.querycache.publisher.MapPublisherRegistry)4 PublisherContext (com.hazelcast.map.impl.querycache.publisher.PublisherContext)4 PublisherRegistry (com.hazelcast.map.impl.querycache.publisher.PublisherRegistry)4 AccumulatorInfo (com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfo)3 Accumulator (com.hazelcast.map.impl.querycache.accumulator.Accumulator)2 DefaultQueryCacheEventData (com.hazelcast.map.impl.querycache.event.DefaultQueryCacheEventData)2 QueryCacheEventData (com.hazelcast.map.impl.querycache.event.QueryCacheEventData)2 Data (com.hazelcast.nio.serialization.Data)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1