use of org.apache.geode.cache.Operation in project geode by apache.
the class TXState method txWriteExistingEntry.
/**
* Write an existing entry. This form takes an expectedOldValue which, if not null, must be equal
* to the current value of the entry. If it is not, an EntryNotFoundException is thrown.
*
* @param event
* @param expectedOldValue
* @return the tx entry object
* @throws EntryNotFoundException
*/
private TXEntryState txWriteExistingEntry(final EntryEventImpl event, Object expectedOldValue) throws EntryNotFoundException {
assert !event.isExpiration();
final Object entryKey = event.getKey();
final LocalRegion region = event.getRegion();
final Operation op = event.getOperation();
TXEntryState tx = txReadEntry(event.getKeyInfo(), region, true, expectedOldValue, true);
assert tx != null;
if (tx.existsLocally()) {
final boolean invalidatingInvalidEntry = op.isInvalidate() && Token.isInvalid(tx.getValueInVM(entryKey));
// Ignore invalidating an invalid entry
if (!invalidatingInvalidEntry) {
tx.updateForWrite(nextModSerialNum());
}
} else if (region.isProxy() && !op.isLocal() && !tx.hasOp()) {
// Distributed operations on proxy regions need to be done
// even if the entry does not exist locally.
// But only if we don't already have a tx operation (once we have an op
// then we honor tx.existsLocally since the tx has storage unlike the proxy).
// We must not throw EntryNotFoundException in this case
tx.updateForWrite(nextModSerialNum());
} else {
throw new EntryNotFoundException(entryKey.toString());
}
return tx;
}
Aggregations