use of com.hazelcast.replicatedmap.impl.record.ReplicatedQueryEventFilter in project hazelcast by hazelcast.
the class ReplicatedMapProxy method addEntryListener.
@Override
public String addEntryListener(EntryListener<K, V> listener, Predicate<K, V> predicate) {
isNotNull(listener, "listener");
EventFilter eventFilter = new ReplicatedQueryEventFilter(null, predicate);
return eventPublishingService.addEventListener(listener, eventFilter, name);
}
use of com.hazelcast.replicatedmap.impl.record.ReplicatedQueryEventFilter in project hazelcast by hazelcast.
the class ReplicatedMapProxy method addEntryListener.
@Override
public String addEntryListener(EntryListener<K, V> listener, Predicate<K, V> predicate, K key) {
isNotNull(listener, "listener");
EventFilter eventFilter = new ReplicatedQueryEventFilter(serializationService.toData(key), predicate);
return eventPublishingService.addEventListener(listener, eventFilter, name);
}
use of com.hazelcast.replicatedmap.impl.record.ReplicatedQueryEventFilter in project hazelcast by hazelcast.
the class ReplicatedMapEventPublishingService method shouldPublish.
private boolean shouldPublish(Data key, Data oldValue, Data value, EntryEventType eventType, EventFilter filter) {
QueryEntry queryEntry = null;
if (filter instanceof ReplicatedQueryEventFilter) {
Data testValue;
if (eventType == REMOVED) {
testValue = oldValue;
} else {
testValue = value;
}
InternalSerializationService serializationService = (InternalSerializationService) nodeEngine.getSerializationService();
queryEntry = new QueryEntry(serializationService, key, testValue, null);
}
return filter == null || filter.eval(queryEntry != null ? queryEntry : key);
}
use of com.hazelcast.replicatedmap.impl.record.ReplicatedQueryEventFilter in project hazelcast by hazelcast.
the class AbstractReplicatedMapAddEntryListenerMessageTask method call.
@Override
protected Object call() {
ReplicatedMapService service = getService(ReplicatedMapService.SERVICE_NAME);
ReplicatedMapEventPublishingService eventPublishingService = service.getEventPublishingService();
String registrationId;
Predicate predicate = getPredicate();
if (predicate == null) {
registrationId = eventPublishingService.addEventListener(this, new ReplicatedEntryEventFilter(getKey()), getDistributedObjectName());
} else {
registrationId = eventPublishingService.addEventListener(this, new ReplicatedQueryEventFilter(getKey(), predicate), getDistributedObjectName());
}
endpoint.addListenerDestroyAction(ReplicatedMapService.SERVICE_NAME, getDistributedObjectName(), registrationId);
return registrationId;
}
Aggregations