Search in sources :

Example 21 with EntryEventType

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

the class EventLostEvent method getNextEntryEventTypeId.

/**
 * Returns next event type ID.
 *
 * @return next event type ID
 * @see EntryEventType
 */
private static int getNextEntryEventTypeId() {
    int higherTypeId = Integer.MIN_VALUE;
    int i = 0;
    EntryEventType[] values = EntryEventType.values();
    for (EntryEventType value : values) {
        int typeId = value.getType();
        if (i == 0) {
            higherTypeId = typeId;
        } else {
            if (typeId > higherTypeId) {
                higherTypeId = typeId;
            }
        }
        i++;
    }
    int eventFlagPosition = Integer.numberOfTrailingZeros(higherTypeId);
    return 1 << ++eventFlagPosition;
}
Also used : EntryEventType(com.hazelcast.core.EntryEventType)

Example 22 with EntryEventType

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

the class PutAllOperation method put.

// protected for testing purposes
protected void put(Data dataKey, Data dataValue) {
    Object oldValue = putToRecordStore(dataKey, dataValue);
    dataValue = getValueOrPostProcessedValue(dataKey, dataValue);
    mapServiceContext.interceptAfterPut(mapContainer.getInterceptorRegistry(), dataValue);
    if (hasMapListener) {
        EntryEventType eventType = (oldValue == null ? ADDED : UPDATED);
        mapEventPublisher.publishEvent(getCallerAddress(), name, eventType, dataKey, oldValue, dataValue);
    }
    if (hasWanReplication) {
        publishWanUpdate(dataKey, dataValue);
    }
    if (hasInvalidation) {
        invalidationKeys.add(dataKey);
    }
    if (hasBackups) {
        backupPairs.add(dataKey);
        backupPairs.add(dataValue);
    }
    evict(dataKey);
}
Also used : EntryEventType(com.hazelcast.core.EntryEventType)

Example 23 with EntryEventType

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

the class PartitionWideEntryBackupOperation method runWithPartitionScanForNative.

// TODO unify this method with `runWithPartitionScan`
protected void runWithPartitionScanForNative() {
    EntryOperator operator = operator(this, backupProcessor, getPredicate());
    Queue<Object> outComes = new LinkedList<>();
    recordStore.forEach((key, record) -> {
        Data dataKey = toHeapData(key);
        operator.operateOnKey(dataKey);
        EntryEventType eventType = operator.getEventType();
        if (eventType != null) {
            outComes.add(dataKey);
            outComes.add(operator.getOldValue());
            outComes.add(operator.getByPreferringDataNewValue());
            outComes.add(eventType);
            outComes.add(operator.getEntry().getNewTtl());
        }
    }, true);
    // in this case, iteration can miss some entries.
    while (!outComes.isEmpty()) {
        Data dataKey = (Data) outComes.poll();
        Object oldValue = outComes.poll();
        Object newValue = outComes.poll();
        EntryEventType eventType = (EntryEventType) outComes.poll();
        long newTtl = (long) outComes.poll();
        operator.init(dataKey, oldValue, newValue, null, eventType, null, newTtl).doPostOperateOps();
    }
}
Also used : EntryEventType(com.hazelcast.core.EntryEventType) ToHeapDataConverter.toHeapData(com.hazelcast.internal.util.ToHeapDataConverter.toHeapData) Data(com.hazelcast.internal.serialization.Data) LinkedList(java.util.LinkedList)

Example 24 with EntryEventType

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

the class InternalQueryCacheListenerAdapter method onEvent.

@Override
public void onEvent(IMapEvent event) {
    EntryEventType eventType = event.getEventType();
    if (eventType != null) {
        callListener(event, eventType.getType());
        return;
    }
    if (event instanceof EventLostEvent) {
        EventLostEvent eventLostEvent = (EventLostEvent) event;
        callListener(eventLostEvent, EventLostEvent.EVENT_TYPE);
        return;
    }
}
Also used : EntryEventType(com.hazelcast.core.EntryEventType) EventLostEvent(com.hazelcast.map.EventLostEvent)

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