final ManagedContext managedContext = getNodeEngine().getSerializationService().getManagedContext();
managedContext.initialize(entryProcessor);
}
public void run() {
final MapServiceContext mapServiceContext = mapService.getMapServiceContext();
final long start = System.currentTimeMillis();
oldValue = recordStore.getMapEntry(dataKey).getValue();
final LocalMapStatsImpl mapStats
= mapServiceContext.getLocalMapStatsProvider().getLocalMapStatsImpl(name);
final Object valueBeforeProcess = mapServiceContext.toObject(oldValue);
final MapEntrySimple entry = new MapEntrySimple(mapServiceContext.toObject(dataKey), valueBeforeProcess);
response = mapServiceContext.toData(entryProcessor.process(entry));
final Object valueAfterProcess = entry.getValue();
// no matching data by key.
if (oldValue == null && valueAfterProcess == null) {
eventType = NO_NEED_TO_FIRE_EVENT;
} else if (valueAfterProcess == null) {
recordStore.remove(dataKey);
mapStats.incrementRemoves(getLatencyFrom(start));
eventType = EntryEventType.REMOVED;
} else {
if (oldValue == null) {
mapStats.incrementPuts(getLatencyFrom(start));
eventType = EntryEventType.ADDED;
} else if (!entry.isModified()) {
// take this case as a read so no need to fire an event.
mapStats.incrementGets(getLatencyFrom(start));
eventType = NO_NEED_TO_FIRE_EVENT;
} else {
mapStats.incrementPuts(getLatencyFrom(start));
eventType = EntryEventType.UPDATED;
}
if (eventType != NO_NEED_TO_FIRE_EVENT) {
recordStore.put(new AbstractMap.SimpleImmutableEntry<Data, Object>(dataKey, entry.getValue()));
dataValue = mapServiceContext.toData(entry.getValue());
}
}
}