Search in sources :

Example 1 with ReplicatedQueryEventFilter

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);
}
Also used : ReplicatedQueryEventFilter(com.hazelcast.replicatedmap.impl.record.ReplicatedQueryEventFilter) ReplicatedQueryEventFilter(com.hazelcast.replicatedmap.impl.record.ReplicatedQueryEventFilter) TrueEventFilter(com.hazelcast.spi.impl.eventservice.impl.TrueEventFilter) EventFilter(com.hazelcast.spi.EventFilter) ReplicatedEntryEventFilter(com.hazelcast.replicatedmap.impl.record.ReplicatedEntryEventFilter)

Example 2 with ReplicatedQueryEventFilter

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);
}
Also used : ReplicatedQueryEventFilter(com.hazelcast.replicatedmap.impl.record.ReplicatedQueryEventFilter) ReplicatedQueryEventFilter(com.hazelcast.replicatedmap.impl.record.ReplicatedQueryEventFilter) TrueEventFilter(com.hazelcast.spi.impl.eventservice.impl.TrueEventFilter) EventFilter(com.hazelcast.spi.EventFilter) ReplicatedEntryEventFilter(com.hazelcast.replicatedmap.impl.record.ReplicatedEntryEventFilter)

Example 3 with ReplicatedQueryEventFilter

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);
}
Also used : ReplicatedQueryEventFilter(com.hazelcast.replicatedmap.impl.record.ReplicatedQueryEventFilter) QueryEntry(com.hazelcast.query.impl.QueryEntry) EntryEventData(com.hazelcast.map.impl.event.EntryEventData) EventData(com.hazelcast.map.impl.event.EventData) Data(com.hazelcast.nio.serialization.Data) MapEventData(com.hazelcast.map.impl.event.MapEventData) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService)

Example 4 with ReplicatedQueryEventFilter

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;
}
Also used : ReplicatedQueryEventFilter(com.hazelcast.replicatedmap.impl.record.ReplicatedQueryEventFilter) ReplicatedEntryEventFilter(com.hazelcast.replicatedmap.impl.record.ReplicatedEntryEventFilter) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) ReplicatedMapEventPublishingService(com.hazelcast.replicatedmap.impl.ReplicatedMapEventPublishingService) Predicate(com.hazelcast.query.Predicate)

Aggregations

ReplicatedQueryEventFilter (com.hazelcast.replicatedmap.impl.record.ReplicatedQueryEventFilter)4 ReplicatedEntryEventFilter (com.hazelcast.replicatedmap.impl.record.ReplicatedEntryEventFilter)3 EventFilter (com.hazelcast.spi.EventFilter)2 TrueEventFilter (com.hazelcast.spi.impl.eventservice.impl.TrueEventFilter)2 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)1 EntryEventData (com.hazelcast.map.impl.event.EntryEventData)1 EventData (com.hazelcast.map.impl.event.EventData)1 MapEventData (com.hazelcast.map.impl.event.MapEventData)1 Data (com.hazelcast.nio.serialization.Data)1 Predicate (com.hazelcast.query.Predicate)1 QueryEntry (com.hazelcast.query.impl.QueryEntry)1 ReplicatedMapEventPublishingService (com.hazelcast.replicatedmap.impl.ReplicatedMapEventPublishingService)1 ReplicatedMapService (com.hazelcast.replicatedmap.impl.ReplicatedMapService)1