Search in sources :

Example 6 with QueryCacheEventService

use of com.hazelcast.map.impl.querycache.QueryCacheEventService in project hazelcast by hazelcast.

the class DefaultQueryCache method addEntryListener.

@Override
public String addEntryListener(MapListener listener, Predicate<K, V> predicate, boolean includeValue) {
    checkNotNull(listener, "listener cannot be null");
    checkNotNull(predicate, "predicate cannot be null");
    QueryCacheEventService eventService = getEventService();
    EventFilter filter = new QueryEventFilter(includeValue, null, predicate);
    String mapName = delegate.getName();
    return eventService.addListener(mapName, cacheName, listener, filter);
}
Also used : QueryCacheEventService(com.hazelcast.map.impl.querycache.QueryCacheEventService) QueryEventFilter(com.hazelcast.map.impl.query.QueryEventFilter) EntryEventFilter(com.hazelcast.map.impl.EntryEventFilter) QueryEventFilter(com.hazelcast.map.impl.query.QueryEventFilter) EventFilter(com.hazelcast.spi.EventFilter)

Example 7 with QueryCacheEventService

use of com.hazelcast.map.impl.querycache.QueryCacheEventService in project hazelcast by hazelcast.

the class EventPublisherHelper method publishCacheWideEvent.

static void publishCacheWideEvent(QueryCacheContext context, String mapName, String cacheName, int numberOfEntriesAffected, EntryEventType eventType) {
    QueryCacheEventService eventService = getQueryCacheEventService(context);
    if (!eventService.hasListener(mapName, cacheName)) {
        return;
    }
    LocalCacheWideEventData eventData = new LocalCacheWideEventData(cacheName, eventType.getType(), numberOfEntriesAffected);
    eventService.publish(mapName, cacheName, eventData, cacheName.hashCode());
}
Also used : QueryCacheEventService(com.hazelcast.map.impl.querycache.QueryCacheEventService) LocalCacheWideEventData(com.hazelcast.map.impl.querycache.event.LocalCacheWideEventData)

Example 8 with QueryCacheEventService

use of com.hazelcast.map.impl.querycache.QueryCacheEventService in project hazelcast by hazelcast.

the class EventPublisherHelper method publishEventLost.

public static void publishEventLost(QueryCacheContext context, String mapName, String cacheName, int partitionId) {
    QueryCacheEventService eventService = getQueryCacheEventService(context);
    int orderKey = cacheName.hashCode();
    eventService.publish(mapName, cacheName, createLocalEntryEventData(cacheName, null, null, null, EventLostEvent.EVENT_TYPE, partitionId, context), orderKey);
}
Also used : QueryCacheEventService(com.hazelcast.map.impl.querycache.QueryCacheEventService)

Example 9 with QueryCacheEventService

use of com.hazelcast.map.impl.querycache.QueryCacheEventService in project hazelcast by hazelcast.

the class EventPublisherHelper method publishEntryEvent.

/**
     * Publishes event upon a change on a key in {@code QueryCache}.
     *
     * @param mapName      the name of underlying map.
     * @param cacheName    the name of {@code QueryCache}
     * @param dataKey      the key in {@code Data} format.
     * @param dataNewValue the value in {@code Data} format.
     * @param oldRecord    the relevant {@code QueryCacheEntry}
     * @param context      the {@code QueryCacheContext}
     */
static void publishEntryEvent(QueryCacheContext context, String mapName, String cacheName, Data dataKey, Data dataNewValue, QueryCacheRecord oldRecord, EntryEventType eventType) {
    QueryCacheEventService eventService = getQueryCacheEventService(context);
    if (!eventService.hasListener(mapName, cacheName)) {
        return;
    }
    Object oldValue = getOldValue(oldRecord);
    LocalEntryEventData eventData = createLocalEntryEventData(cacheName, dataKey, dataNewValue, oldValue, eventType.getType(), -1, context);
    eventService.publish(mapName, cacheName, eventData, dataKey.hashCode());
}
Also used : QueryCacheEventService(com.hazelcast.map.impl.querycache.QueryCacheEventService) LocalEntryEventData(com.hazelcast.map.impl.querycache.event.LocalEntryEventData)

Example 10 with QueryCacheEventService

use of com.hazelcast.map.impl.querycache.QueryCacheEventService in project hazelcast by hazelcast.

the class DefaultQueryCache method addEntryListenerInternal.

private String addEntryListenerInternal(MapListener listener, K key, boolean includeValue) {
    checkNotNull(listener, "listener cannot be null");
    Data keyData = toData(key);
    EventFilter filter = new EntryEventFilter(includeValue, keyData);
    QueryCacheEventService eventService = getEventService();
    String mapName = delegate.getName();
    return eventService.addListener(mapName, cacheName, listener, filter);
}
Also used : QueryCacheEventService(com.hazelcast.map.impl.querycache.QueryCacheEventService) EntryEventFilter(com.hazelcast.map.impl.EntryEventFilter) Data(com.hazelcast.nio.serialization.Data) EntryEventFilter(com.hazelcast.map.impl.EntryEventFilter) QueryEventFilter(com.hazelcast.map.impl.query.QueryEventFilter) EventFilter(com.hazelcast.spi.EventFilter)

Aggregations

QueryCacheEventService (com.hazelcast.map.impl.querycache.QueryCacheEventService)10 EntryEventFilter (com.hazelcast.map.impl.EntryEventFilter)3 QueryEventFilter (com.hazelcast.map.impl.query.QueryEventFilter)3 EventFilter (com.hazelcast.spi.EventFilter)3 Sequenced (com.hazelcast.map.impl.querycache.event.sequence.Sequenced)2 PublisherAccumulatorHandler (com.hazelcast.map.impl.querycache.publisher.PublisherAccumulatorHandler)2 ListenerAdapter (com.hazelcast.map.impl.ListenerAdapter)1 QueryCacheContext (com.hazelcast.map.impl.querycache.QueryCacheContext)1 Accumulator (com.hazelcast.map.impl.querycache.accumulator.Accumulator)1 LocalCacheWideEventData (com.hazelcast.map.impl.querycache.event.LocalCacheWideEventData)1 LocalEntryEventData (com.hazelcast.map.impl.querycache.event.LocalEntryEventData)1 EventPublisherAccumulatorProcessor (com.hazelcast.map.impl.querycache.publisher.EventPublisherAccumulatorProcessor)1 MapListener (com.hazelcast.map.listener.MapListener)1 Data (com.hazelcast.nio.serialization.Data)1