use of com.hazelcast.map.impl.querycache.event.QueryCacheEventData in project hazelcast by hazelcast.
the class MapAddListenerMessageTask method getEventData.
private ClientMessage getEventData(IMapEvent iMapEvent) {
if (iMapEvent instanceof SingleIMapEvent) {
QueryCacheEventData eventData = ((SingleIMapEvent) iMapEvent).getEventData();
ClientMessage clientMessage = ContinuousQueryAddListenerCodec.encodeQueryCacheSingleEvent(eventData);
int partitionId = eventData.getPartitionId();
clientMessage.setPartitionId(partitionId);
return clientMessage;
}
if (iMapEvent instanceof BatchIMapEvent) {
BatchIMapEvent batchIMapEvent = (BatchIMapEvent) iMapEvent;
BatchEventData batchEventData = batchIMapEvent.getBatchEventData();
int partitionId = batchEventData.getPartitionId();
ClientMessage clientMessage = ContinuousQueryAddListenerCodec.encodeQueryCacheBatchEvent(batchEventData.getEvents(), batchEventData.getSource(), partitionId);
clientMessage.setPartitionId(partitionId);
return clientMessage;
}
throw new IllegalArgumentException("Unexpected event type found = [" + iMapEvent + "]");
}
use of com.hazelcast.map.impl.querycache.event.QueryCacheEventData in project hazelcast by hazelcast.
the class PublisherCreateOperation method replayEventsOnResultSet.
/**
* Replay the events on returned result-set which are generated during `runInitialQuery` call.
*/
private void replayEventsOnResultSet(final QueryResult queryResult) throws Exception {
Collection<Object> resultCollection = readAccumulators();
for (Object result : resultCollection) {
if (result == null) {
continue;
}
Object toObject = mapServiceContext.toObject(result);
List<QueryCacheEventData> eventDataList = (List<QueryCacheEventData>) toObject;
for (QueryCacheEventData eventData : eventDataList) {
QueryResultRow entry = createQueryResultEntry(eventData);
add(queryResult, entry);
}
}
}
use of com.hazelcast.map.impl.querycache.event.QueryCacheEventData in project hazelcast by hazelcast.
the class PublisherCreateOperation method createQueryResultEntry.
private QueryResultRow createQueryResultEntry(QueryCacheEventData eventData) {
Data dataKey = eventData.getDataKey();
Data dataNewValue = eventData.getDataNewValue();
return new QueryResultRow(dataKey, dataNewValue);
}
use of com.hazelcast.map.impl.querycache.event.QueryCacheEventData in project hazelcast by hazelcast.
the class SubscriberAccumulatorHandler method handle.
@Override
public void handle(QueryCacheEventData eventData, boolean ignored) {
eventData.setSerializationService(serializationService);
Data keyData = eventData.getDataKey();
Data valueData = includeValue ? eventData.getDataNewValue() : null;
int eventType = eventData.getEventType();
EntryEventType entryEventType = EntryEventType.getByType(eventType);
switch(entryEventType) {
case ADDED:
case UPDATED:
case MERGED:
queryCache.setInternal(keyData, valueData, false, entryEventType);
break;
case REMOVED:
case EVICTED:
queryCache.deleteInternal(keyData, false, entryEventType);
break;
// TODO if we want strongly consistent clear & evict, removal can be made based on sequence and partition-id.
case CLEAR_ALL:
case EVICT_ALL:
queryCache.clearInternal(entryEventType);
break;
default:
throw new IllegalArgumentException("Not a known type EntryEventType." + entryEventType);
}
}
use of com.hazelcast.map.impl.querycache.event.QueryCacheEventData in project hazelcast by hazelcast.
the class PublisherAccumulatorHandler method sendToSubscriber.
private void sendToSubscriber(Map<Integer, List<QueryCacheEventData>> map) {
Set<Map.Entry<Integer, List<QueryCacheEventData>>> entries = map.entrySet();
for (Map.Entry<Integer, List<QueryCacheEventData>> entry : entries) {
Integer partitionId = entry.getKey();
List<QueryCacheEventData> eventData = entry.getValue();
String thisNodesAddress = getThisNodesAddress();
BatchEventData batchEventData = new BatchEventData(eventData, thisNodesAddress, partitionId);
processor.process(batchEventData);
}
}
Aggregations