use of com.hazelcast.map.impl.querycache.event.DefaultQueryCacheEventData in project hazelcast by hazelcast.
the class QueryCacheEventPublisher method addEventToQueryCache.
public void addEventToQueryCache(Object eventData) {
checkInstanceOf(EventData.class, eventData, "eventData");
String mapName = ((EventData) eventData).getMapName();
int eventType = ((EventData) eventData).getEventType();
// only handling EVICTED event for that key is sufficient
if (EXPIRED.getType() == eventType) {
return;
}
// this collection contains all defined query-caches on an IMap
Collection<PartitionAccumulatorRegistry> partitionAccumulatorRegistries = getPartitionAccumulatorRegistries(mapName);
if (isEmpty(partitionAccumulatorRegistries)) {
return;
}
if (!(eventData instanceof EntryEventData)) {
return;
}
EntryEventData entryEvenData = (EntryEventData) eventData;
Data dataKey = entryEvenData.getDataKey();
Data dataNewValue = entryEvenData.getDataNewValue();
Data dataOldValue = entryEvenData.getDataOldValue();
int partitionId = queryCacheContext.getPartitionId(entryEvenData.dataKey);
for (PartitionAccumulatorRegistry registry : partitionAccumulatorRegistries) {
DefaultQueryCacheEventData singleEventData = (DefaultQueryCacheEventData) convertQueryCacheEventDataOrNull(registry, dataKey, dataNewValue, dataOldValue, eventType, partitionId);
if (singleEventData == null) {
continue;
}
Accumulator accumulator = registry.getOrCreate(partitionId);
accumulator.accumulate(singleEventData);
}
}
Aggregations