Search in sources :

Example 1 with PublisherRegistry

use of com.hazelcast.map.impl.querycache.publisher.PublisherRegistry 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 2 with PublisherRegistry

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

the class MapPostJoinAwareService method getAccumulatorInfoList.

private List<AccumulatorInfo> getAccumulatorInfoList() {
    List<AccumulatorInfo> infoList = new ArrayList<>();
    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 3 with PublisherRegistry

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

the class QueryCacheEventPublisher method getPartitionAccumulatorRegistries.

private Collection<PartitionAccumulatorRegistry> getPartitionAccumulatorRegistries(String mapName) {
    PublisherContext publisherContext = queryCacheContext.getPublisherContext();
    MapPublisherRegistry mapPublisherRegistry = publisherContext.getMapPublisherRegistry();
    PublisherRegistry publisherRegistry = mapPublisherRegistry.getOrNull(mapName);
    if (publisherRegistry == null) {
        return Collections.emptySet();
    }
    // this collection contains all query-caches for this map
    return publisherRegistry.getAll().values();
}
Also used : MapPublisherRegistry(com.hazelcast.map.impl.querycache.publisher.MapPublisherRegistry) 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 PublisherRegistry

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

the class PublisherCreateOperation method registerPublisherAccumulator.

private void registerPublisherAccumulator() {
    String mapName = info.getMapName();
    String cacheId = info.getCacheId();
    PublisherContext publisherContext = getPublisherContext();
    MapPublisherRegistry mapPublisherRegistry = publisherContext.getMapPublisherRegistry();
    PublisherRegistry publisherRegistry = mapPublisherRegistry.getOrCreate(mapName);
    // If InternalQueryCache#recreate is called, we forcibly
    // remove and recreate registration matching with cacheId
    publisherRegistry.remove(cacheId);
    PartitionAccumulatorRegistry partitionAccumulatorRegistry = publisherRegistry.getOrCreate(cacheId);
    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 5 with PublisherRegistry

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

the class DefaultRecordStore method hasQueryCache.

/**
 * @return {@code true} if this IMap has any query-cache, otherwise return {@code false}
 */
public boolean hasQueryCache() {
    QueryCacheContext queryCacheContext = mapServiceContext.getQueryCacheContext();
    PublisherContext publisherContext = queryCacheContext.getPublisherContext();
    MapPublisherRegistry mapPublisherRegistry = publisherContext.getMapPublisherRegistry();
    PublisherRegistry publisherRegistry = mapPublisherRegistry.getOrNull(name);
    return publisherRegistry != null;
}
Also used : MapPublisherRegistry(com.hazelcast.map.impl.querycache.publisher.MapPublisherRegistry) PublisherRegistry(com.hazelcast.map.impl.querycache.publisher.PublisherRegistry) MapPublisherRegistry(com.hazelcast.map.impl.querycache.publisher.MapPublisherRegistry) QueryCacheContext(com.hazelcast.map.impl.querycache.QueryCacheContext) PublisherContext(com.hazelcast.map.impl.querycache.publisher.PublisherContext)

Aggregations

MapPublisherRegistry (com.hazelcast.map.impl.querycache.publisher.MapPublisherRegistry)12 PublisherContext (com.hazelcast.map.impl.querycache.publisher.PublisherContext)12 PublisherRegistry (com.hazelcast.map.impl.querycache.publisher.PublisherRegistry)12 PartitionAccumulatorRegistry (com.hazelcast.map.impl.querycache.publisher.PartitionAccumulatorRegistry)7 AccumulatorInfo (com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfo)3 QueryCacheContext (com.hazelcast.map.impl.querycache.QueryCacheContext)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 Address (com.hazelcast.cluster.Address)1 MapUtil.createHashMap (com.hazelcast.internal.util.MapUtil.createHashMap)1 IMapEvent (com.hazelcast.map.IMapEvent)1 MapInterceptor (com.hazelcast.map.MapInterceptor)1 InterceptorRegistry (com.hazelcast.map.impl.InterceptorRegistry)1 ListenerAdapter (com.hazelcast.map.impl.ListenerAdapter)1 MapContainer (com.hazelcast.map.impl.MapContainer)1 MapDataSerializerHook (com.hazelcast.map.impl.MapDataSerializerHook)1 MapService (com.hazelcast.map.impl.MapService)1 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)1 AccumulatorInfoSupplier (com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfoSupplier)1 ObjectDataInput (com.hazelcast.nio.ObjectDataInput)1