Search in sources :

Example 11 with QueryCacheEventData

use of com.hazelcast.map.impl.querycache.event.QueryCacheEventData in project hazelcast by hazelcast.

the class SubscriberListener method onEvent.

@Override
public void onEvent(IMapEvent iMapEvent) {
    if (iMapEvent instanceof SingleIMapEvent) {
        QueryCacheEventData eventData = ((SingleIMapEvent) iMapEvent).getEventData();
        eventData.setSerializationService(serializationService);
        accumulator.accumulate(eventData);
        return;
    }
    if (iMapEvent instanceof BatchIMapEvent) {
        BatchIMapEvent batchIMapEvent = (BatchIMapEvent) iMapEvent;
        BatchEventData batchEventData = batchIMapEvent.getBatchEventData();
        Collection<QueryCacheEventData> events = batchEventData.getEvents();
        for (QueryCacheEventData eventData : events) {
            eventData.setSerializationService(serializationService);
            accumulator.accumulate(eventData);
        }
        return;
    }
}
Also used : BatchEventData(com.hazelcast.map.impl.querycache.event.BatchEventData) BatchIMapEvent(com.hazelcast.map.impl.querycache.event.BatchIMapEvent) SingleIMapEvent(com.hazelcast.map.impl.querycache.event.SingleIMapEvent) QueryCacheEventData(com.hazelcast.map.impl.querycache.event.QueryCacheEventData)

Example 12 with QueryCacheEventData

use of com.hazelcast.map.impl.querycache.event.QueryCacheEventData in project hazelcast by hazelcast.

the class QueryCacheEventPublisher method hintMapEvent.

// TODO known issue: Locked keys will also be cleared from the query-cache after calling a map-wide event like clear/evictAll
public void hintMapEvent(Address caller, String mapName, EntryEventType eventType, int numberOfEntriesAffected, int partitionId) {
    // this collection contains all defined query-caches on this map.
    Collection<PartitionAccumulatorRegistry> partitionAccumulatorRegistries = getPartitionAccumulatorRegistries(mapName);
    for (PartitionAccumulatorRegistry accumulatorRegistry : partitionAccumulatorRegistries) {
        Accumulator accumulator = accumulatorRegistry.getOrCreate(partitionId);
        QueryCacheEventData singleEventData = newQueryCacheEventDataBuilder(false).withPartitionId(partitionId).withEventType(eventType.getType()).build();
        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) QueryCacheEventData(com.hazelcast.map.impl.querycache.event.QueryCacheEventData)

Aggregations

QueryCacheEventData (com.hazelcast.map.impl.querycache.event.QueryCacheEventData)12 BatchEventData (com.hazelcast.map.impl.querycache.event.BatchEventData)4 Accumulator (com.hazelcast.map.impl.querycache.accumulator.Accumulator)3 Data (com.hazelcast.nio.serialization.Data)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 QueryResultRow (com.hazelcast.map.impl.query.QueryResultRow)2 QueryCacheContext (com.hazelcast.map.impl.querycache.QueryCacheContext)2 BatchIMapEvent (com.hazelcast.map.impl.querycache.event.BatchIMapEvent)2 SingleIMapEvent (com.hazelcast.map.impl.querycache.event.SingleIMapEvent)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ClientEndpoint (com.hazelcast.client.ClientEndpoint)1 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)1 EntryEventType (com.hazelcast.core.EntryEventType)1 DefaultQueryCacheEventData (com.hazelcast.map.impl.querycache.event.DefaultQueryCacheEventData)1 PartitionAccumulatorRegistry (com.hazelcast.map.impl.querycache.publisher.PartitionAccumulatorRegistry)1