Search in sources :

Example 21 with QueryCacheContext

use of com.hazelcast.map.impl.querycache.QueryCacheContext 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 22 with QueryCacheContext

use of com.hazelcast.map.impl.querycache.QueryCacheContext in project hazelcast by hazelcast.

the class MapClientAwareService method clientDisconnected.

@Override
public void clientDisconnected(UUID clientUuid) {
    QueryCacheContext queryCacheContext = mapServiceContext.getQueryCacheContext();
    PublisherContext publisherContext = queryCacheContext.getPublisherContext();
    publisherContext.handleDisconnectedSubscriber(clientUuid);
}
Also used : QueryCacheContext(com.hazelcast.map.impl.querycache.QueryCacheContext) PublisherContext(com.hazelcast.map.impl.querycache.publisher.PublisherContext)

Example 23 with QueryCacheContext

use of com.hazelcast.map.impl.querycache.QueryCacheContext 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.getCacheId());
        // marker listener.
        mapServiceContext.addLocalListenerAdapter((ListenerAdapter<IMapEvent>) event -> {
        }, info.getMapName());
    }
}
Also used : MapDataSerializerHook(com.hazelcast.map.impl.MapDataSerializerHook) Address(com.hazelcast.cluster.Address) IdentifiedDataSerializable(com.hazelcast.nio.serialization.IdentifiedDataSerializable) MapPublisherRegistry(com.hazelcast.map.impl.querycache.publisher.MapPublisherRegistry) IMapEvent(com.hazelcast.map.IMapEvent) MapUtil.createHashMap(com.hazelcast.internal.util.MapUtil.createHashMap) ArrayList(java.util.ArrayList) AccumulatorInfo(com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfo) Operation(com.hazelcast.spi.impl.operationservice.Operation) Map(java.util.Map) ObjectDataInput(com.hazelcast.nio.ObjectDataInput) LinkedList(java.util.LinkedList) MapContainer(com.hazelcast.map.impl.MapContainer) PublisherContext(com.hazelcast.map.impl.querycache.publisher.PublisherContext) MapInterceptor(com.hazelcast.map.MapInterceptor) TargetAware(com.hazelcast.spi.impl.operationservice.TargetAware) IOException(java.io.IOException) MapService(com.hazelcast.map.impl.MapService) QueryCacheContext(com.hazelcast.map.impl.querycache.QueryCacheContext) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) AbstractMap(java.util.AbstractMap) List(java.util.List) AccumulatorInfoSupplier(com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfoSupplier) ObjectDataOutput(com.hazelcast.nio.ObjectDataOutput) PublisherRegistry(com.hazelcast.map.impl.querycache.publisher.PublisherRegistry) ListenerAdapter(com.hazelcast.map.impl.ListenerAdapter) Collections(java.util.Collections) InterceptorRegistry(com.hazelcast.map.impl.InterceptorRegistry) 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.map.IMapEvent) MapService(com.hazelcast.map.impl.MapService) PublisherContext(com.hazelcast.map.impl.querycache.publisher.PublisherContext) MapServiceContext(com.hazelcast.map.impl.MapServiceContext)

Example 24 with QueryCacheContext

use of com.hazelcast.map.impl.querycache.QueryCacheContext in project hazelcast by hazelcast.

the class PublisherCreateOperation method getPartitionIdsOfAccumulators.

private Collection<Integer> getPartitionIdsOfAccumulators() {
    String mapName = info.getMapName();
    String cacheId = info.getCacheId();
    QueryCacheContext context = getContext();
    return QueryCacheUtil.getAccumulators(context, mapName, cacheId).keySet();
}
Also used : QueryCacheContext(com.hazelcast.map.impl.querycache.QueryCacheContext)

Example 25 with QueryCacheContext

use of com.hazelcast.map.impl.querycache.QueryCacheContext in project hazelcast by hazelcast.

the class ClientQueryCacheEventLostListenerTest method setTestSequencer.

private void setTestSequencer(IMap map, int eventCount) {
    ClientMapProxy proxy = (ClientMapProxy) map;
    QueryCacheContext queryCacheContext = proxy.getQueryCacheContext();
    queryCacheContext.setSubscriberContext(new TestClientSubscriberContext(queryCacheContext, eventCount, true));
}
Also used : ClientMapProxy(com.hazelcast.client.impl.proxy.ClientMapProxy) QueryCacheContext(com.hazelcast.map.impl.querycache.QueryCacheContext) TestClientSubscriberContext(com.hazelcast.client.map.impl.querycache.subscriber.TestClientSubscriberContext)

Aggregations

QueryCacheContext (com.hazelcast.map.impl.querycache.QueryCacheContext)27 Accumulator (com.hazelcast.map.impl.querycache.accumulator.Accumulator)7 MapService (com.hazelcast.map.impl.MapService)5 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)5 PublisherContext (com.hazelcast.map.impl.querycache.publisher.PublisherContext)5 Sequenced (com.hazelcast.map.impl.querycache.event.sequence.Sequenced)4 QueryCacheEventService (com.hazelcast.map.impl.querycache.QueryCacheEventService)3 QueryCacheEventData (com.hazelcast.map.impl.querycache.event.QueryCacheEventData)3 ClientMapProxy (com.hazelcast.client.impl.proxy.ClientMapProxy)2 TestClientSubscriberContext (com.hazelcast.client.map.impl.querycache.subscriber.TestClientSubscriberContext)2 TestClientSubscriberContext (com.hazelcast.client.map.querycache.subscriber.TestClientSubscriberContext)2 ClientMapProxy (com.hazelcast.client.proxy.ClientMapProxy)2 Node (com.hazelcast.instance.impl.Node)2 AccumulatorInfo (com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfo)2 AccumulatorInfoSupplier (com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfoSupplier)2 EventPublisherAccumulatorProcessor (com.hazelcast.map.impl.querycache.publisher.EventPublisherAccumulatorProcessor)2 MapPublisherRegistry (com.hazelcast.map.impl.querycache.publisher.MapPublisherRegistry)2 PublisherAccumulatorHandler (com.hazelcast.map.impl.querycache.publisher.PublisherAccumulatorHandler)2 PublisherRegistry (com.hazelcast.map.impl.querycache.publisher.PublisherRegistry)2 QueryCacheEndToEndProvider (com.hazelcast.map.impl.querycache.subscriber.QueryCacheEndToEndProvider)2