Search in sources :

Example 1 with IMapEvent

use of com.hazelcast.core.IMapEvent in project hazelcast by hazelcast.

the class MapEventPublishingService method dispatchLocalEventData.

/**
     * Dispatches an event-data to {@link com.hazelcast.map.QueryCache QueryCache} listeners on this local
     * node.
     *
     * @param eventData {@link EventData} to be dispatched
     * @param listener  the listener which the event will be dispatched from
     */
private void dispatchLocalEventData(EventData eventData, ListenerAdapter listener) {
    IMapEvent event = createIMapEvent(eventData, null, nodeEngine.getLocalMember(), serializationService);
    listener.onEvent(event);
}
Also used : EventPublisherHelper.createIMapEvent(com.hazelcast.map.impl.querycache.subscriber.EventPublisherHelper.createIMapEvent) BatchIMapEvent(com.hazelcast.map.impl.querycache.event.BatchIMapEvent) SingleIMapEvent(com.hazelcast.map.impl.querycache.event.SingleIMapEvent) IMapEvent(com.hazelcast.core.IMapEvent)

Example 2 with IMapEvent

use of com.hazelcast.core.IMapEvent in project hazelcast by hazelcast.

the class EventPublisherHelper method createIMapEvent.

public static IMapEvent createIMapEvent(EventData eventData, EventFilter filter, Member member, SerializationService serializationService) {
    String source = eventData.getSource();
    int eventType = eventData.getEventType();
    if (eventType == EventLostEvent.EVENT_TYPE) {
        LocalEntryEventData localEventData = (LocalEntryEventData) eventData;
        int partitionId = localEventData.getPartitionId();
        return new EventLostEvent(source, null, partitionId);
    }
    if (eventType == EntryEventType.CLEAR_ALL.getType() || eventType == EntryEventType.EVICT_ALL.getType()) {
        LocalCacheWideEventData localCacheWideEventData = (LocalCacheWideEventData) eventData;
        int numberOfEntriesAffected = localCacheWideEventData.getNumberOfEntriesAffected();
        return new MapEvent(source, null, eventType, numberOfEntriesAffected);
    }
    LocalEntryEventData localEntryEventData = (LocalEntryEventData) eventData;
    Data dataKey = localEntryEventData.getKeyData();
    Data dataNewValue = localEntryEventData.getValueData();
    Data dataOldValue = localEntryEventData.getOldValueData();
    boolean includeValue = isIncludeValue(filter);
    return new DataAwareEntryEvent(member, eventType, source, dataKey, (includeValue ? dataNewValue : null), (includeValue ? dataOldValue : null), null, serializationService);
}
Also used : LocalEntryEventData(com.hazelcast.map.impl.querycache.event.LocalEntryEventData) MapEvent(com.hazelcast.core.MapEvent) IMapEvent(com.hazelcast.core.IMapEvent) EventLostEvent(com.hazelcast.map.EventLostEvent) Data(com.hazelcast.nio.serialization.Data) LocalCacheWideEventData(com.hazelcast.map.impl.querycache.event.LocalCacheWideEventData) LocalEntryEventData(com.hazelcast.map.impl.querycache.event.LocalEntryEventData) EventData(com.hazelcast.map.impl.event.EventData) DataAwareEntryEvent(com.hazelcast.map.impl.DataAwareEntryEvent) LocalCacheWideEventData(com.hazelcast.map.impl.querycache.event.LocalCacheWideEventData)

Example 3 with IMapEvent

use of com.hazelcast.core.IMapEvent 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)

Aggregations

IMapEvent (com.hazelcast.core.IMapEvent)3 MapEvent (com.hazelcast.core.MapEvent)1 EventLostEvent (com.hazelcast.map.EventLostEvent)1 DataAwareEntryEvent (com.hazelcast.map.impl.DataAwareEntryEvent)1 MapService (com.hazelcast.map.impl.MapService)1 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)1 EventData (com.hazelcast.map.impl.event.EventData)1 QueryCacheContext (com.hazelcast.map.impl.querycache.QueryCacheContext)1 AccumulatorInfo (com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfo)1 BatchIMapEvent (com.hazelcast.map.impl.querycache.event.BatchIMapEvent)1 LocalCacheWideEventData (com.hazelcast.map.impl.querycache.event.LocalCacheWideEventData)1 LocalEntryEventData (com.hazelcast.map.impl.querycache.event.LocalEntryEventData)1 SingleIMapEvent (com.hazelcast.map.impl.querycache.event.SingleIMapEvent)1 MapPublisherRegistry (com.hazelcast.map.impl.querycache.publisher.MapPublisherRegistry)1 PublisherContext (com.hazelcast.map.impl.querycache.publisher.PublisherContext)1 PublisherRegistry (com.hazelcast.map.impl.querycache.publisher.PublisherRegistry)1 EventPublisherHelper.createIMapEvent (com.hazelcast.map.impl.querycache.subscriber.EventPublisherHelper.createIMapEvent)1 Data (com.hazelcast.nio.serialization.Data)1