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);
}
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());
}
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);
}
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());
}
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);
}
Aggregations