Search in sources :

Example 1 with EntryEventType

use of com.hazelcast.core.EntryEventType in project hazelcast by hazelcast.

the class QueryCacheEventPublisher method convertQueryCacheEventDataOrNull.

private QueryCacheEventData convertQueryCacheEventDataOrNull(PartitionAccumulatorRegistry registry, Data dataKey, Data dataNewValue, Data dataOldValue, int eventTypeId, int partitionId) {
    EventFilter eventFilter = registry.getEventFilter();
    EntryEventType eventType = EntryEventType.getByType(eventTypeId);
    // filtering strategy
    if (filteringStrategy instanceof DefaultEntryEventFilteringStrategy) {
        eventType = getCQCEventTypeOrNull(eventType, eventFilter, dataKey, dataNewValue, dataOldValue);
    } else {
        int producedEventTypeId = filteringStrategy.doFilter(eventFilter, dataKey, dataOldValue, dataNewValue, eventType, null);
        if (producedEventTypeId == FilteringStrategy.FILTER_DOES_NOT_MATCH) {
            eventType = null;
        } else {
            eventType = EntryEventType.getByType(producedEventTypeId);
        }
    }
    if (eventType == null) {
        return null;
    }
    boolean includeValue = isIncludeValue(eventFilter);
    return newQueryCacheEventDataBuilder(includeValue).withPartitionId(partitionId).withDataKey(dataKey).withDataNewValue(dataNewValue).withEventType(eventType.getType()).withDataOldValue(dataOldValue).withSerializationService((serializationService)).build();
}
Also used : EntryEventType(com.hazelcast.core.EntryEventType) EventFilter(com.hazelcast.spi.EventFilter)

Example 2 with EntryEventType

use of com.hazelcast.core.EntryEventType in project hazelcast by hazelcast.

the class PutFromLoadAllOperation method publishEntryEvent.

private void publishEntryEvent(Data key, Object previousValue, Object newValue) {
    final EntryEventType eventType = previousValue == null ? EntryEventType.ADDED : EntryEventType.UPDATED;
    mapEventPublisher.publishEvent(getCallerAddress(), name, eventType, key, previousValue, newValue);
}
Also used : EntryEventType(com.hazelcast.core.EntryEventType)

Example 3 with EntryEventType

use of com.hazelcast.core.EntryEventType in project hazelcast by hazelcast.

the class MapListenerFlagOperator method setAndGetListenerFlags.

/**
 * Sets and gets flags of implemented listener interfaces of a {@link com.hazelcast.map.listener.MapListener MapListener}.
 */
public static int setAndGetListenerFlags(ListenerAdapter listenerAdapter) {
    InternalMapListenerAdapter internalMapListenerAdapter = (InternalMapListenerAdapter) listenerAdapter;
    ListenerAdapter[] listenerAdapters = internalMapListenerAdapter.getListenerAdapters();
    EntryEventType[] values = EntryEventType.values();
    int listenerFlags = 0;
    for (EntryEventType eventType : values) {
        ListenerAdapter definedAdapter = listenerAdapters[eventType.ordinal()];
        if (definedAdapter != null) {
            listenerFlags = listenerFlags | eventType.getType();
        }
    }
    return listenerFlags;
}
Also used : EntryEventType(com.hazelcast.core.EntryEventType)

Example 4 with EntryEventType

use of com.hazelcast.core.EntryEventType in project hazelcast by hazelcast.

the class QueryCacheEventPublisher method convertQueryCacheEventDataOrNull.

private QueryCacheEventData convertQueryCacheEventDataOrNull(PartitionAccumulatorRegistry registry, Data dataKey, Data dataNewValue, Data dataOldValue, int eventTypeId, int partitionId, String mapName) {
    EventFilter eventFilter = registry.getEventFilter();
    EntryEventType eventType = EntryEventType.getByType(eventTypeId);
    // filtering strategy
    if (filteringStrategy instanceof DefaultEntryEventFilteringStrategy) {
        eventType = getCQCEventTypeOrNull(eventType, eventFilter, dataKey, dataNewValue, dataOldValue, mapName);
    } else {
        int producedEventTypeId = filteringStrategy.doFilter(eventFilter, dataKey, dataOldValue, dataNewValue, eventType, mapName);
        if (producedEventTypeId == FilteringStrategy.FILTER_DOES_NOT_MATCH) {
            eventType = null;
        } else {
            eventType = EntryEventType.getByType(producedEventTypeId);
        }
    }
    if (eventType == null) {
        return null;
    }
    boolean includeValue = isIncludeValue(eventFilter);
    return newQueryCacheEventDataBuilder(includeValue).withPartitionId(partitionId).withDataKey(dataKey).withDataNewValue(dataNewValue).withEventType(eventType.getType()).withDataOldValue(dataOldValue).withSerializationService((serializationService)).build();
}
Also used : EntryEventType(com.hazelcast.core.EntryEventType) EventFilter(com.hazelcast.spi.impl.eventservice.EventFilter)

Example 5 with EntryEventType

use of com.hazelcast.core.EntryEventType in project hazelcast by hazelcast.

the class DefaultRecordStore method putFromLoadInternal.

private Object putFromLoadInternal(Data key, Object newValue, long ttl, long maxIdle, boolean backup, Address callerAddress) {
    checkKeyAndValue(key, newValue);
    if (shouldEvict()) {
        return null;
    }
    long now = getNow();
    Object oldValue = putInternal(key, newValue, ttl, maxIdle, UNSET, now, false, false, false, false, false, true, null, false, false, null, null, false, backup);
    if (!backup && mapEventPublisher.hasEventListener(name)) {
        Record record = getRecord(key);
        EntryEventType entryEventType = oldValue == null ? LOADED : UPDATED;
        mapEventPublisher.publishEvent(callerAddress, name, entryEventType, key, oldValue, record.getValue());
    }
    return oldValue;
}
Also used : EntryEventType(com.hazelcast.core.EntryEventType) Record(com.hazelcast.map.impl.record.Record)

Aggregations

EntryEventType (com.hazelcast.core.EntryEventType)24 Data (com.hazelcast.internal.serialization.Data)3 EntryEvent (com.hazelcast.core.EntryEvent)2 ToHeapDataConverter.toHeapData (com.hazelcast.internal.util.ToHeapDataConverter.toHeapData)2 EntryEventData (com.hazelcast.map.impl.event.EntryEventData)2 Record (com.hazelcast.map.impl.record.Record)2 LinkedList (java.util.LinkedList)2 Map (java.util.Map)2 CacheEventData (com.hazelcast.cache.impl.CacheEventData)1 CacheEventSet (com.hazelcast.cache.impl.CacheEventSet)1 Member (com.hazelcast.cluster.Member)1 CollectionEvent (com.hazelcast.collection.impl.collection.CollectionEvent)1 QueueEvent (com.hazelcast.collection.impl.queue.QueueEvent)1 ReplicatedMapConfig (com.hazelcast.config.ReplicatedMapConfig)1 EntryListener (com.hazelcast.core.EntryListener)1 LocalReplicatedMapStatsImpl (com.hazelcast.internal.monitor.impl.LocalReplicatedMapStatsImpl)1 ConstructorFunction (com.hazelcast.internal.util.ConstructorFunction)1 EventLostEvent (com.hazelcast.map.EventLostEvent)1 MapEvent (com.hazelcast.map.MapEvent)1 DataAwareEntryEvent (com.hazelcast.map.impl.DataAwareEntryEvent)1