Search in sources :

Example 6 with LocalEntryEventData

use of com.hazelcast.map.impl.querycache.event.LocalEntryEventData in project hazelcast by hazelcast.

the class ClientQueryCacheEventService method canPassFilter.

private boolean canPassFilter(Object eventData, EventFilter filter, Extractors extractors) {
    if (filter == null || filter instanceof TrueEventFilter) {
        return true;
    }
    if (!(eventData instanceof LocalEntryEventData)) {
        return true;
    }
    LocalEntryEventData localEntryEventData = (LocalEntryEventData) eventData;
    if (localEntryEventData.getEventType() != EventLostEvent.EVENT_TYPE) {
        Object value = getValueOrOldValue(localEntryEventData);
        Data keyData = localEntryEventData.getKeyData();
        QueryEntry entry = new QueryEntry(serializationService, keyData, value, extractors);
        return filter.eval(entry);
    }
    return true;
}
Also used : QueryEntry(com.hazelcast.query.impl.QueryEntry) LocalEntryEventData(com.hazelcast.map.impl.querycache.event.LocalEntryEventData) QueryCacheEventData(com.hazelcast.map.impl.querycache.event.QueryCacheEventData) BatchEventData(com.hazelcast.map.impl.querycache.event.BatchEventData) EventData(com.hazelcast.map.impl.event.EventData) Data(com.hazelcast.internal.serialization.Data) LocalEntryEventData(com.hazelcast.map.impl.querycache.event.LocalEntryEventData) TrueEventFilter(com.hazelcast.spi.impl.eventservice.impl.TrueEventFilter)

Example 7 with LocalEntryEventData

use of com.hazelcast.map.impl.querycache.event.LocalEntryEventData in project hazelcast by hazelcast.

the class NodeQueryCacheEventService method publishLocalEvent.

// TODO needs refactoring.
private void publishLocalEvent(String cacheId, Object eventData, Extractors extractors) {
    Collection<EventRegistration> eventRegistrations = getRegistrations(cacheId);
    if (eventRegistrations.isEmpty()) {
        return;
    }
    for (EventRegistration eventRegistration : eventRegistrations) {
        Registration registration = (Registration) eventRegistration;
        Object listener = registration.getListener();
        if (!(listener instanceof QueryCacheListenerAdapter)) {
            continue;
        }
        Object eventDataToPublish = eventData;
        int orderKey = -1;
        if (eventDataToPublish instanceof LocalCacheWideEventData) {
            orderKey = cacheId.hashCode();
        } else if (eventDataToPublish instanceof LocalEntryEventData) {
            LocalEntryEventData localEntryEventData = (LocalEntryEventData) eventDataToPublish;
            if (localEntryEventData.getEventType() != EventLostEvent.EVENT_TYPE) {
                EventFilter filter = registration.getFilter();
                if (!canPassFilter(localEntryEventData, filter, extractors)) {
                    continue;
                } else {
                    boolean includeValue = isIncludeValue(filter);
                    eventDataToPublish = includeValue ? localEntryEventData : localEntryEventData.cloneWithoutValue();
                    Data keyData = localEntryEventData.getKeyData();
                    orderKey = keyData == null ? -1 : keyData.hashCode();
                }
            }
        }
        publishEventInternal(registration, eventDataToPublish, orderKey);
    }
}
Also used : EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) LocalEntryEventData(com.hazelcast.map.impl.querycache.event.LocalEntryEventData) EventRegistration(com.hazelcast.spi.impl.eventservice.EventRegistration) Registration(com.hazelcast.spi.impl.eventservice.impl.Registration) QueryCacheListenerAdapter(com.hazelcast.map.impl.querycache.QueryCacheListenerAdapter) LocalCacheWideEventData(com.hazelcast.map.impl.querycache.event.LocalCacheWideEventData) EventData(com.hazelcast.map.impl.event.EventData) Data(com.hazelcast.internal.serialization.Data) LocalEntryEventData(com.hazelcast.map.impl.querycache.event.LocalEntryEventData) EntryEventFilter(com.hazelcast.map.impl.EntryEventFilter) TrueEventFilter(com.hazelcast.spi.impl.eventservice.impl.TrueEventFilter) EventFilter(com.hazelcast.spi.impl.eventservice.EventFilter) LocalCacheWideEventData(com.hazelcast.map.impl.querycache.event.LocalCacheWideEventData)

Example 8 with LocalEntryEventData

use of com.hazelcast.map.impl.querycache.event.LocalEntryEventData in project hazelcast by hazelcast.

the class NodeQueryCacheEventService method canPassFilter.

private boolean canPassFilter(LocalEntryEventData localEntryEventData, EventFilter filter, Extractors extractors) {
    if (filter == null || filter instanceof TrueEventFilter) {
        return true;
    }
    NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
    SerializationService serializationService = nodeEngine.getSerializationService();
    Data keyData = localEntryEventData.getKeyData();
    Object value = getValueOrOldValue(localEntryEventData);
    QueryableEntry entry = new QueryEntry(serializationService, keyData, value, extractors);
    return filter.eval(entry);
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) QueryEntry(com.hazelcast.query.impl.QueryEntry) SerializationService(com.hazelcast.internal.serialization.SerializationService) LocalCacheWideEventData(com.hazelcast.map.impl.querycache.event.LocalCacheWideEventData) EventData(com.hazelcast.map.impl.event.EventData) Data(com.hazelcast.internal.serialization.Data) LocalEntryEventData(com.hazelcast.map.impl.querycache.event.LocalEntryEventData) TrueEventFilter(com.hazelcast.spi.impl.eventservice.impl.TrueEventFilter) QueryableEntry(com.hazelcast.query.impl.QueryableEntry)

Aggregations

LocalEntryEventData (com.hazelcast.map.impl.querycache.event.LocalEntryEventData)8 EventData (com.hazelcast.map.impl.event.EventData)7 LocalCacheWideEventData (com.hazelcast.map.impl.querycache.event.LocalCacheWideEventData)6 Data (com.hazelcast.internal.serialization.Data)5 TrueEventFilter (com.hazelcast.spi.impl.eventservice.impl.TrueEventFilter)5 QueryEntry (com.hazelcast.query.impl.QueryEntry)3 EntryEventFilter (com.hazelcast.map.impl.EntryEventFilter)2 QueryCacheEventService (com.hazelcast.map.impl.querycache.QueryCacheEventService)2 QueryCacheListenerAdapter (com.hazelcast.map.impl.querycache.QueryCacheListenerAdapter)2 Data (com.hazelcast.nio.serialization.Data)2 QueryableEntry (com.hazelcast.query.impl.QueryableEntry)2 Registration (com.hazelcast.spi.impl.eventservice.impl.Registration)2 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)1 SerializationService (com.hazelcast.internal.serialization.SerializationService)1 EventLostEvent (com.hazelcast.map.EventLostEvent)1 IMapEvent (com.hazelcast.map.IMapEvent)1 MapEvent (com.hazelcast.map.MapEvent)1 DataAwareEntryEvent (com.hazelcast.map.impl.DataAwareEntryEvent)1 BatchEventData (com.hazelcast.map.impl.querycache.event.BatchEventData)1 QueryCacheEventData (com.hazelcast.map.impl.querycache.event.QueryCacheEventData)1