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));
}
}
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);
}
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));
}
}
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);
}
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;
}
Aggregations