Search in sources :

Example 1 with IMapEvent

use of com.hazelcast.map.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) IMapEvent(com.hazelcast.map.IMapEvent) MapEvent(com.hazelcast.map.MapEvent) EventLostEvent(com.hazelcast.map.EventLostEvent) Data(com.hazelcast.internal.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 2 with IMapEvent

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

Example 3 with IMapEvent

use of com.hazelcast.map.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.getCacheId());
        // marker listener.
        mapServiceContext.addLocalListenerAdapter((ListenerAdapter<IMapEvent>) event -> {
        }, info.getMapName());
    }
}
Also used : MapDataSerializerHook(com.hazelcast.map.impl.MapDataSerializerHook) Address(com.hazelcast.cluster.Address) IdentifiedDataSerializable(com.hazelcast.nio.serialization.IdentifiedDataSerializable) MapPublisherRegistry(com.hazelcast.map.impl.querycache.publisher.MapPublisherRegistry) IMapEvent(com.hazelcast.map.IMapEvent) MapUtil.createHashMap(com.hazelcast.internal.util.MapUtil.createHashMap) ArrayList(java.util.ArrayList) AccumulatorInfo(com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfo) Operation(com.hazelcast.spi.impl.operationservice.Operation) Map(java.util.Map) ObjectDataInput(com.hazelcast.nio.ObjectDataInput) LinkedList(java.util.LinkedList) MapContainer(com.hazelcast.map.impl.MapContainer) PublisherContext(com.hazelcast.map.impl.querycache.publisher.PublisherContext) MapInterceptor(com.hazelcast.map.MapInterceptor) TargetAware(com.hazelcast.spi.impl.operationservice.TargetAware) IOException(java.io.IOException) MapService(com.hazelcast.map.impl.MapService) QueryCacheContext(com.hazelcast.map.impl.querycache.QueryCacheContext) MapServiceContext(com.hazelcast.map.impl.MapServiceContext) AbstractMap(java.util.AbstractMap) List(java.util.List) AccumulatorInfoSupplier(com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfoSupplier) ObjectDataOutput(com.hazelcast.nio.ObjectDataOutput) PublisherRegistry(com.hazelcast.map.impl.querycache.publisher.PublisherRegistry) ListenerAdapter(com.hazelcast.map.impl.ListenerAdapter) Collections(java.util.Collections) InterceptorRegistry(com.hazelcast.map.impl.InterceptorRegistry) 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.map.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.map.IMapEvent)3 Address (com.hazelcast.cluster.Address)1 Data (com.hazelcast.internal.serialization.Data)1 MapUtil.createHashMap (com.hazelcast.internal.util.MapUtil.createHashMap)1 EventLostEvent (com.hazelcast.map.EventLostEvent)1 MapEvent (com.hazelcast.map.MapEvent)1 MapInterceptor (com.hazelcast.map.MapInterceptor)1 DataAwareEntryEvent (com.hazelcast.map.impl.DataAwareEntryEvent)1 InterceptorRegistry (com.hazelcast.map.impl.InterceptorRegistry)1 ListenerAdapter (com.hazelcast.map.impl.ListenerAdapter)1 MapContainer (com.hazelcast.map.impl.MapContainer)1 MapDataSerializerHook (com.hazelcast.map.impl.MapDataSerializerHook)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 AccumulatorInfoSupplier (com.hazelcast.map.impl.querycache.accumulator.AccumulatorInfoSupplier)1 BatchIMapEvent (com.hazelcast.map.impl.querycache.event.BatchIMapEvent)1 LocalCacheWideEventData (com.hazelcast.map.impl.querycache.event.LocalCacheWideEventData)1