Search in sources :

Example 26 with Operation

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;
}
Also used : EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) ServerRegionOperation(org.apache.geode.internal.cache.tx.TransactionalOperation.ServerRegionOperation) Operation(org.apache.geode.cache.Operation)

Aggregations

Operation (org.apache.geode.cache.Operation)26 Released (org.apache.geode.internal.offheap.annotations.Released)6 EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)4 ServerRegionProxy (org.apache.geode.cache.client.internal.ServerRegionProxy)3 StoredObject (org.apache.geode.internal.offheap.StoredObject)3 Retained (org.apache.geode.internal.offheap.annotations.Retained)3 IOException (java.io.IOException)2 ByteBuffer (java.nio.ByteBuffer)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 CancelException (org.apache.geode.CancelException)2 CacheLoader (org.apache.geode.cache.CacheLoader)2 CacheWriterException (org.apache.geode.cache.CacheWriterException)2 LoaderHelper (org.apache.geode.cache.LoaderHelper)2 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)2 Portfolio (org.apache.geode.cache.query.data.Portfolio)2 EventID (org.apache.geode.internal.cache.EventID)2 EventIDHolder (org.apache.geode.internal.cache.EventIDHolder)2 LocalRegion (org.apache.geode.internal.cache.LocalRegion)2 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)2