Search in sources :

Example 6 with EntryEventType

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

the class SubscriberAccumulatorHandler method handle.

@Override
public void handle(QueryCacheEventData eventData, boolean ignored) {
    eventData.setSerializationService(serializationService);
    Data keyData = eventData.getDataKey();
    Data valueData = includeValue ? eventData.getDataNewValue() : null;
    int eventType = eventData.getEventType();
    EntryEventType entryEventType = EntryEventType.getByType(eventType);
    if (entryEventType == null) {
        throwException(format("No matching EntryEventType found for event type id `%d`", eventType));
    }
    switch(entryEventType) {
        case ADDED:
        case UPDATED:
        case MERGED:
        case LOADED:
            queryCache.set(keyData, valueData, entryEventType);
            break;
        case REMOVED:
        case EVICTED:
        case EXPIRED:
            queryCache.delete(keyData, entryEventType);
            break;
        case CLEAR_ALL:
            handleMapWideEvent(eventData, entryEventType, clearAllRemovedCountHolders);
            break;
        case EVICT_ALL:
            handleMapWideEvent(eventData, entryEventType, evictAllRemovedCountHolders);
            break;
        default:
            throwException(format("Unexpected EntryEventType was found: `%s`", entryEventType));
    }
}
Also used : EntryEventType(com.hazelcast.core.EntryEventType) QueryCacheEventData(com.hazelcast.map.impl.querycache.event.QueryCacheEventData) Data(com.hazelcast.internal.serialization.Data)

Example 7 with EntryEventType

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

the class ReplicatedMapEventPublishingService method fireEntryListenerEvent.

public void fireEntryListenerEvent(Data key, Data oldValue, Data value, String name, Address caller) {
    EntryEventType eventType = value == null ? REMOVED : oldValue == null ? ADDED : UPDATED;
    fireEntryListenerEvent(key, oldValue, value, eventType, name, caller);
}
Also used : EntryEventType(com.hazelcast.core.EntryEventType)

Example 8 with EntryEventType

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

the class AbstractMultipleEntryBackupOperation method readInternal.

@Override
protected void readInternal(ObjectDataInput in) throws IOException {
    super.readInternal(in);
    int size = in.readInt();
    for (int i = 0; i < size; i++) {
        Data key = in.readData();
        Data value = in.readData();
        EntryEventType entryEventType = EntryEventType.getByType(in.readInt());
        wanEventList.add(new WanEventWrapper(key, value, entryEventType));
    }
}
Also used : EntryEventType(com.hazelcast.core.EntryEventType) Data(com.hazelcast.nio.serialization.Data)

Example 9 with EntryEventType

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

the class AbstractMultipleEntryOperation method doPostOps.

protected void doPostOps(Data key, Object oldValue, Map.Entry entry) {
    final EntryEventType eventType = pickEventTypeOrNull(entry, oldValue);
    if (eventType == null) {
        return;
    }
    Object newValue = entry.getValue();
    invalidateNearCache(key);
    mapServiceContext.interceptAfterPut(name, newValue);
    if (isPostProcessing(recordStore)) {
        Record record = recordStore.getRecord(key);
        newValue = record == null ? null : record.getValue();
    }
    if (mapContainer.isWanReplicationEnabled()) {
        newValue = toData(newValue);
        publishWanReplicationEvent(key, (Data) newValue, eventType);
    }
    publishEntryEvent(key, newValue, oldValue, eventType);
}
Also used : EntryEventType(com.hazelcast.core.EntryEventType) Record(com.hazelcast.map.impl.record.Record)

Example 10 with EntryEventType

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

the class EntryListenerAdaptors method createListenerAdapters.

/**
     * Creates a {@link com.hazelcast.map.impl.ListenerAdapter} array
     * for all event types of {@link com.hazelcast.core.EntryEventType}.
     *
     * @param listener a {@link EntryListener} instance.
     * @return an array of {@link com.hazelcast.map.impl.ListenerAdapter}
     */
public static ListenerAdapter[] createListenerAdapters(EntryListener listener) {
    // We only care about these reference event types for backward compatibility.
    EntryEventType[] values = new EntryEventType[] { ADDED, REMOVED, EVICTED, UPDATED, EVICT_ALL, CLEAR_ALL };
    ListenerAdapter[] listenerAdapters = new ListenerAdapter[values.length];
    for (EntryEventType eventType : values) {
        listenerAdapters[eventType.ordinal()] = createListenerAdapter(eventType, listener);
    }
    return listenerAdapters;
}
Also used : EntryEventType(com.hazelcast.core.EntryEventType)

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