Search in sources :

Example 11 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) QueryCacheEventData(com.hazelcast.map.impl.querycache.event.QueryCacheEventData)

Example 12 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.getQueryContext();
    queryCacheContext.setSubscriberContext(new TestClientSubscriberContext(queryCacheContext, eventCount, true));
}
Also used : ClientMapProxy(com.hazelcast.client.proxy.ClientMapProxy) QueryCacheContext(com.hazelcast.map.impl.querycache.QueryCacheContext) TestClientSubscriberContext(com.hazelcast.client.map.querycache.subscriber.TestClientSubscriberContext)

Example 13 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 cacheName = info.getCacheName();
    QueryCacheContext context = getContext();
    return QueryCacheUtil.getAccumulators(context, mapName, cacheName).keySet();
}
Also used : QueryCacheContext(com.hazelcast.map.impl.querycache.QueryCacheContext)

Example 14 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.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)

Example 15 with QueryCacheContext

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

the class MapMigrationAwareService method commitMigration.

@Override
public void commitMigration(PartitionMigrationEvent event) {
    migrateIndex(event);
    if (SOURCE == event.getMigrationEndpoint()) {
        clearMapsHavingLesserBackupCountThan(event.getPartitionId(), event.getNewReplicaIndex());
        getMetaDataGenerator().removeUuidAndSequence(event.getPartitionId());
    } else if (DESTINATION == event.getMigrationEndpoint()) {
        if (event.getNewReplicaIndex() != 0) {
            getMetaDataGenerator().regenerateUuid(event.getPartitionId());
        }
    }
    PartitionContainer partitionContainer = mapServiceContext.getPartitionContainer(event.getPartitionId());
    for (RecordStore recordStore : partitionContainer.getAllRecordStores()) {
        // in case the record store has been created without loading during migration trigger again
        // if loading has been already started this call will do nothing
        recordStore.startLoading();
    }
    mapServiceContext.reloadOwnedPartitions();
    QueryCacheContext queryCacheContext = mapServiceContext.getQueryCacheContext();
    PublisherContext publisherContext = queryCacheContext.getPublisherContext();
    if (event.getMigrationEndpoint() == MigrationEndpoint.SOURCE) {
        int partitionId = event.getPartitionId();
        flushAccumulator(publisherContext, partitionId);
        removeAccumulator(publisherContext, partitionId);
    }
}
Also used : RecordStore(com.hazelcast.map.impl.recordstore.RecordStore) QueryCacheContext(com.hazelcast.map.impl.querycache.QueryCacheContext) PublisherContext(com.hazelcast.map.impl.querycache.publisher.PublisherContext) MigrationEndpoint(com.hazelcast.spi.partition.MigrationEndpoint)

Aggregations

QueryCacheContext (com.hazelcast.map.impl.querycache.QueryCacheContext)15 Accumulator (com.hazelcast.map.impl.querycache.accumulator.Accumulator)5 PublisherContext (com.hazelcast.map.impl.querycache.publisher.PublisherContext)4 TestClientSubscriberContext (com.hazelcast.client.map.querycache.subscriber.TestClientSubscriberContext)2 ClientMapProxy (com.hazelcast.client.proxy.ClientMapProxy)2 QueryCacheEventData (com.hazelcast.map.impl.querycache.event.QueryCacheEventData)2 Sequenced (com.hazelcast.map.impl.querycache.event.sequence.Sequenced)2 MapPublisherRegistry (com.hazelcast.map.impl.querycache.publisher.MapPublisherRegistry)2 PublisherRegistry (com.hazelcast.map.impl.querycache.publisher.PublisherRegistry)2 QueryCacheRequest (com.hazelcast.map.impl.querycache.subscriber.QueryCacheRequest)2 QueryCacheRequests.newQueryCacheRequest (com.hazelcast.map.impl.querycache.subscriber.QueryCacheRequests.newQueryCacheRequest)2 ClientQueryCacheContext (com.hazelcast.client.impl.querycache.ClientQueryCacheContext)1 IMapEvent (com.hazelcast.core.IMapEvent)1 MapService (com.hazelcast.map.impl.MapService)1 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)1 QueryCacheEventService (com.hazelcast.map.impl.querycache.QueryCacheEventService)1 AccumulatorInfo (com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfo)1 EventPublisherAccumulatorProcessor (com.hazelcast.map.impl.querycache.publisher.EventPublisherAccumulatorProcessor)1 PublisherAccumulatorHandler (com.hazelcast.map.impl.querycache.publisher.PublisherAccumulatorHandler)1 InternalQueryCache (com.hazelcast.map.impl.querycache.subscriber.InternalQueryCache)1