Search in sources :

Example 1 with BatchEventData

use of com.hazelcast.map.impl.querycache.event.BatchEventData 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 + "]");
}
Also used : BatchEventData(com.hazelcast.map.impl.querycache.event.BatchEventData) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) 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 2 with BatchEventData

use of com.hazelcast.map.impl.querycache.event.BatchEventData 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);
    }
}
Also used : BatchEventData(com.hazelcast.map.impl.querycache.event.BatchEventData) ArrayList(java.util.ArrayList) List(java.util.List) MapUtil.createHashMap(com.hazelcast.internal.util.MapUtil.createHashMap) Map(java.util.Map) QueryCacheEventData(com.hazelcast.map.impl.querycache.event.QueryCacheEventData)

Example 3 with BatchEventData

use of com.hazelcast.map.impl.querycache.event.BatchEventData 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)

Aggregations

BatchEventData (com.hazelcast.map.impl.querycache.event.BatchEventData)3 QueryCacheEventData (com.hazelcast.map.impl.querycache.event.QueryCacheEventData)3 BatchIMapEvent (com.hazelcast.map.impl.querycache.event.BatchIMapEvent)2 SingleIMapEvent (com.hazelcast.map.impl.querycache.event.SingleIMapEvent)2 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)1 MapUtil.createHashMap (com.hazelcast.internal.util.MapUtil.createHashMap)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1