Search in sources :

Example 1 with TransactionDataNotColocatedException

use of org.apache.geode.cache.TransactionDataNotColocatedException in project geode by apache.

the class PartitionedRegion method getDataRegionForWrite.

@Override
public LocalRegion getDataRegionForWrite(KeyInfo keyInfo) {
    BucketRegion br = null;
    final Object entryKey = keyInfo.getKey();
    try {
        final int retryAttempts = calcRetry();
        // TODO provide appropriate Operation and arg
        int bucketId = keyInfo.getBucketId();
        if (bucketId == KeyInfo.UNKNOWN_BUCKET) {
            bucketId = PartitionedRegionHelper.getHashKey(this, null, entryKey, keyInfo.getValue(), keyInfo.getCallbackArg());
            keyInfo.setBucketId(bucketId);
        }
        int count = 0;
        while (count <= retryAttempts) {
            try {
                PartitionedRegionDataStore ds = getDataStore();
                if (ds == null) {
                    throw new TransactionException(LocalizedStrings.PartitionedRegion_TX_ON_DATASTORE.toLocalizedString());
                }
                br = ds.getInitializedBucketWithKnownPrimaryForId(entryKey, bucketId);
                break;
            } catch (ForceReattemptException ignore) {
                // create a new bucket
                InternalDistributedMember member = createBucket(bucketId, 0, null);
                if (!getMyId().equals(member) && keyInfo.isCheckPrimary()) {
                    throw new PrimaryBucketException("Bucket " + bucketId + " is not primary. Current primary holder is " + member);
                }
                count++;
            }
        }
        Assert.assertTrue(br != null, "Could not create storage for Entry");
        if (keyInfo.isCheckPrimary()) {
            br.checkForPrimary();
        }
    } catch (PrimaryBucketException pbe) {
        throw new TransactionDataRebalancedException(LocalizedStrings.PartitionedRegion_TRANSACTIONAL_DATA_MOVED_DUE_TO_REBALANCING.toLocalizedString(), pbe);
    } catch (RegionDestroyedException ignore) {
        // TODO: why is this purposely not wrapping the original cause?
        throw new TransactionDataNotColocatedException(LocalizedStrings.PartitionedRegion_KEY_0_NOT_COLOCATED_WITH_TRANSACTION.toLocalizedString(entryKey));
    }
    return br;
}
Also used : TransactionException(org.apache.geode.cache.TransactionException) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) TransactionDataNotColocatedException(org.apache.geode.cache.TransactionDataNotColocatedException) TransactionDataRebalancedException(org.apache.geode.cache.TransactionDataRebalancedException)

Example 2 with TransactionDataNotColocatedException

use of org.apache.geode.cache.TransactionDataNotColocatedException in project geode by apache.

the class TXStateProxyImpl method getTransactionException.

private TransactionException getTransactionException(KeyInfo keyInfo, GemFireException e) {
    if (isRealDealLocal() && !buckets.isEmpty() && !buckets.containsKey(keyInfo.getBucketId())) {
        TransactionException ex = new TransactionDataNotColocatedException(LocalizedStrings.PartitionedRegion_KEY_0_NOT_COLOCATED_WITH_TRANSACTION.toLocalizedString(keyInfo.getKey()));
        ex.initCause(e.getCause());
        return ex;
    }
    Throwable ex = e;
    while (ex != null) {
        if (ex instanceof PrimaryBucketException) {
            return new TransactionDataRebalancedException(LocalizedStrings.PartitionedRegion_TRANSACTIONAL_DATA_MOVED_DUE_TO_REBALANCING.toLocalizedString());
        }
        ex = ex.getCause();
    }
    return (TransactionException) e;
}
Also used : TransactionException(org.apache.geode.cache.TransactionException) UnsupportedOperationInTransactionException(org.apache.geode.cache.UnsupportedOperationInTransactionException) TransactionDataNotColocatedException(org.apache.geode.cache.TransactionDataNotColocatedException) TransactionDataRebalancedException(org.apache.geode.cache.TransactionDataRebalancedException)

Example 3 with TransactionDataNotColocatedException

use of org.apache.geode.cache.TransactionDataNotColocatedException in project geode by apache.

the class DistributedTXRegionStub method destroyExistingEntry.

public void destroyExistingEntry(EntryEventImpl event, boolean cacheWrite, Object expectedOldValue) {
    // this.prStats.incPartitionMessagesSent();
    try {
        RemoteOperationResponse response = RemoteDestroyMessage.send(state.getTarget(), event.getLocalRegion(), event, expectedOldValue, DistributionManager.PARTITIONED_REGION_EXECUTOR, true, false);
        response.waitForCacheException();
    } catch (EntryNotFoundException enfe) {
        throw enfe;
    } catch (TransactionDataNotColocatedException enfe) {
        throw enfe;
    } catch (CacheException ce) {
        throw new PartitionedRegionException(LocalizedStrings.PartitionedRegion_DESTROY_OF_ENTRY_ON_0_FAILED.toLocalizedString(state.getTarget()), ce);
    } catch (RegionDestroyedException rde) {
        throw new TransactionDataNotColocatedException(LocalizedStrings.RemoteMessage_REGION_0_NOT_COLOCATED_WITH_TRANSACTION.toLocalizedString(rde.getRegionFullPath()), rde);
    } catch (RemoteOperationException roe) {
        throw new TransactionDataNodeHasDepartedException(roe);
    }
}
Also used : PartitionedRegionException(org.apache.geode.internal.cache.PartitionedRegionException) CacheException(org.apache.geode.cache.CacheException) TransactionDataNotColocatedException(org.apache.geode.cache.TransactionDataNotColocatedException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) RemoteOperationException(org.apache.geode.internal.cache.RemoteOperationException) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) RemoteOperationResponse(org.apache.geode.internal.cache.RemoteOperationMessage.RemoteOperationResponse) TransactionDataNodeHasDepartedException(org.apache.geode.cache.TransactionDataNodeHasDepartedException)

Example 4 with TransactionDataNotColocatedException

use of org.apache.geode.cache.TransactionDataNotColocatedException in project geode by apache.

the class DistributedTXRegionStub method putEntry.

public boolean putEntry(EntryEventImpl event, boolean ifNew, boolean ifOld, Object expectedOldValue, boolean requireOldValue, long lastModified, boolean overwriteDestroyed) {
    boolean retVal = false;
    final LocalRegion r = event.getLocalRegion();
    try {
        RemotePutResponse response = RemotePutMessage.txSend(state.getTarget(), r, event, lastModified, ifNew, ifOld, expectedOldValue, requireOldValue);
        PutResult result = response.waitForResult();
        event.setOldValue(result.oldValue, true);
        retVal = result.returnValue;
    } catch (TransactionDataNotColocatedException enfe) {
        throw enfe;
    } catch (CacheException ce) {
        throw new PartitionedRegionException(LocalizedStrings.PartitionedRegion_DESTROY_OF_ENTRY_ON_0_FAILED.toLocalizedString(state.getTarget()), ce);
    } catch (RegionDestroyedException rde) {
        throw new TransactionDataNotColocatedException(LocalizedStrings.RemoteMessage_REGION_0_NOT_COLOCATED_WITH_TRANSACTION.toLocalizedString(rde.getRegionFullPath()), rde);
    } catch (RemoteOperationException roe) {
        throw new TransactionDataNodeHasDepartedException(roe);
    }
    return retVal;
}
Also used : PartitionedRegionException(org.apache.geode.internal.cache.PartitionedRegionException) CacheException(org.apache.geode.cache.CacheException) TransactionDataNotColocatedException(org.apache.geode.cache.TransactionDataNotColocatedException) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) RemoteOperationException(org.apache.geode.internal.cache.RemoteOperationException) RemotePutResponse(org.apache.geode.internal.cache.RemotePutMessage.RemotePutResponse) LocalRegion(org.apache.geode.internal.cache.LocalRegion) PutResult(org.apache.geode.internal.cache.RemotePutMessage.PutResult) TransactionDataNodeHasDepartedException(org.apache.geode.cache.TransactionDataNodeHasDepartedException)

Example 5 with TransactionDataNotColocatedException

use of org.apache.geode.cache.TransactionDataNotColocatedException in project geode by apache.

the class DistributedTXRegionStub method findObject.

public Object findObject(KeyInfo keyInfo, boolean isCreate, boolean generateCallbacks, Object value, boolean preferCD, ClientProxyMembershipID requestingClient, EntryEventImpl clientEvent) {
    Object retVal = null;
    final Object key = keyInfo.getKey();
    final Object callbackArgument = keyInfo.getCallbackArg();
    try {
        RemoteGetMessage.RemoteGetResponse response = RemoteGetMessage.send((InternalDistributedMember) state.getTarget(), region, key, callbackArgument, requestingClient);
        retVal = response.waitForResponse(preferCD);
    } catch (RegionDestroyedException rde) {
        throw new TransactionDataNotColocatedException(LocalizedStrings.RemoteMessage_REGION_0_NOT_COLOCATED_WITH_TRANSACTION.toLocalizedString(rde.getRegionFullPath()), rde);
    } catch (RemoteOperationException roe) {
        throw new TransactionDataNodeHasDepartedException(roe);
    }
    return retVal;
}
Also used : RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) TransactionDataNotColocatedException(org.apache.geode.cache.TransactionDataNotColocatedException) RemoteOperationException(org.apache.geode.internal.cache.RemoteOperationException) RemoteGetMessage(org.apache.geode.internal.cache.RemoteGetMessage) TransactionDataNodeHasDepartedException(org.apache.geode.cache.TransactionDataNodeHasDepartedException)

Aggregations

TransactionDataNotColocatedException (org.apache.geode.cache.TransactionDataNotColocatedException)27 TransactionDataRebalancedException (org.apache.geode.cache.TransactionDataRebalancedException)13 EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)11 CacheException (org.apache.geode.cache.CacheException)10 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)10 TransactionException (org.apache.geode.cache.TransactionException)10 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)9 ArrayList (java.util.ArrayList)8 CustId (org.apache.geode.internal.cache.execute.data.CustId)7 CommitConflictException (org.apache.geode.cache.CommitConflictException)6 Region (org.apache.geode.cache.Region)6 TransactionDataNodeHasDepartedException (org.apache.geode.cache.TransactionDataNodeHasDepartedException)6 RemoteOperationException (org.apache.geode.internal.cache.RemoteOperationException)6 Customer (org.apache.geode.internal.cache.execute.data.Customer)6 Collection (java.util.Collection)5 CancelException (org.apache.geode.CancelException)5 UnsupportedOperationInTransactionException (org.apache.geode.cache.UnsupportedOperationInTransactionException)5 NamingException (javax.naming.NamingException)4 RollbackException (javax.transaction.RollbackException)4 CacheLoaderException (org.apache.geode.cache.CacheLoaderException)4