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