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