Search in sources :

Example 11 with PublisherContext

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

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

the class DefaultRecordStore method hasQueryCache.

/**
     * @return {@code true} if this IMap has any query-cache, otherwise return {@code false}
     */
private 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)

Example 13 with PublisherContext

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

the class AccumulatorScannerTask method createConsumerOperation.

private Operation createConsumerOperation(int partitionId, Queue<Accumulator> accumulators) {
    PublisherContext publisherContext = context.getPublisherContext();
    NodeEngineImpl nodeEngine = (NodeEngineImpl) publisherContext.getNodeEngine();
    Operation operation = new AccumulatorConsumerOperation(accumulators, MAX_PROCESSABLE_ACCUMULATOR_COUNT);
    operation.setNodeEngine(nodeEngine).setCallerUuid(nodeEngine.getLocalMember().getUuid()).setPartitionId(partitionId).setValidateTarget(false).setService(nodeEngine.getService(MapService.SERVICE_NAME));
    return operation;
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) AccumulatorConsumerOperation(com.hazelcast.map.impl.operation.AccumulatorConsumerOperation) AccumulatorConsumerOperation(com.hazelcast.map.impl.operation.AccumulatorConsumerOperation) Operation(com.hazelcast.spi.Operation) PublisherContext(com.hazelcast.map.impl.querycache.publisher.PublisherContext)

Example 14 with PublisherContext

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

the class QueryCacheUtil method getAccumulatorRegistryOrNull.

/**
     * Returns {@code PartitionAccumulatorRegistry} of a {@code QueryCache}.
     *
     * @see PartitionAccumulatorRegistry
     */
public static PartitionAccumulatorRegistry getAccumulatorRegistryOrNull(QueryCacheContext context, String mapName, String cacheName) {
    PublisherContext publisherContext = context.getPublisherContext();
    MapPublisherRegistry mapPublisherRegistry = publisherContext.getMapPublisherRegistry();
    PublisherRegistry publisherRegistry = mapPublisherRegistry.getOrNull(mapName);
    if (publisherRegistry == null) {
        return null;
    }
    return publisherRegistry.getOrNull(cacheName);
}
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 15 with PublisherContext

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

the class PostJoinMapOperation method createQueryCaches.

private void createQueryCaches() {
    MapService mapService = getService();
    MapServiceContext mapServiceContext = mapService.getMapServiceContext();
    QueryCacheContext queryCacheContext = mapServiceContext.getQueryCacheContext();
    PublisherContext publisherContext = queryCacheContext.getPublisherContext();
    MapPublisherRegistry mapPublisherRegistry = publisherContext.getMapPublisherRegistry();
    for (AccumulatorInfo info : infoList) {
        addAccumulatorInfo(queryCacheContext, info);
        PublisherRegistry publisherRegistry = mapPublisherRegistry.getOrCreate(info.getMapName());
        publisherRegistry.getOrCreate(info.getCacheName());
        // marker listener.
        mapServiceContext.addLocalListenerAdapter(new ListenerAdapter<IMapEvent>() {

            @Override
            public void onEvent(IMapEvent event) {
            }
        }, info.getMapName());
    }
}
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) QueryCacheContext(com.hazelcast.map.impl.querycache.QueryCacheContext) AccumulatorInfo(com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfo) IMapEvent(com.hazelcast.core.IMapEvent) MapService(com.hazelcast.map.impl.MapService) PublisherContext(com.hazelcast.map.impl.querycache.publisher.PublisherContext) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Aggregations

PublisherContext (com.hazelcast.map.impl.querycache.publisher.PublisherContext)17 MapPublisherRegistry (com.hazelcast.map.impl.querycache.publisher.MapPublisherRegistry)9 PublisherRegistry (com.hazelcast.map.impl.querycache.publisher.PublisherRegistry)9 QueryCacheContext (com.hazelcast.map.impl.querycache.QueryCacheContext)4 PartitionAccumulatorRegistry (com.hazelcast.map.impl.querycache.publisher.PartitionAccumulatorRegistry)4 AccumulatorInfo (com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfo)3 AccumulatorInfoSupplier (com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfoSupplier)3 MapListenerRegistry (com.hazelcast.map.impl.querycache.publisher.MapListenerRegistry)2 QueryCacheListenerRegistry (com.hazelcast.map.impl.querycache.publisher.QueryCacheListenerRegistry)2 IMapEvent (com.hazelcast.core.IMapEvent)1 MapService (com.hazelcast.map.impl.MapService)1 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)1 AccumulatorConsumerOperation (com.hazelcast.map.impl.operation.AccumulatorConsumerOperation)1 RecordStore (com.hazelcast.map.impl.recordstore.RecordStore)1 Operation (com.hazelcast.spi.Operation)1 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)1 MigrationEndpoint (com.hazelcast.spi.partition.MigrationEndpoint)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1