Search in sources :

Example 26 with TransactionException

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

the class PartitionedTXRegionStub method destroyExistingEntry.

public void destroyExistingEntry(EntryEventImpl event, boolean cacheWrite, Object expectedOldValue) {
    PartitionedRegion pr = (PartitionedRegion) event.getLocalRegion();
    try {
        pr.destroyRemotely(state.getTarget(), event.getKeyInfo().getBucketId(), event, expectedOldValue);
    } catch (TransactionException e) {
        RuntimeException re = getTransactionException(event.getKeyInfo(), e);
        re.initCause(e.getCause());
        throw re;
    } catch (PrimaryBucketException e) {
        RuntimeException re = getTransactionException(event.getKeyInfo(), e);
        re.initCause(e);
        throw re;
    } catch (ForceReattemptException e) {
        RuntimeException re;
        if (isBucketNotFoundException(e)) {
            re = new TransactionDataRebalancedException(LocalizedStrings.PartitionedRegion_TRANSACTIONAL_DATA_MOVED_DUE_TO_REBALANCING.toLocalizedString());
        } else {
            re = new TransactionDataNodeHasDepartedException(LocalizedStrings.PartitionedRegion_TRANSACTION_DATA_NODE_0_HAS_DEPARTED_TO_PROCEED_ROLLBACK_THIS_TRANSACTION_AND_BEGIN_A_NEW_ONE.toLocalizedString(state.getTarget()));
        }
        re.initCause(e);
        waitToRetry();
        throw re;
    }
    trackBucketForTx(event.getKeyInfo());
}
Also used : TransactionException(org.apache.geode.cache.TransactionException) ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) PrimaryBucketException(org.apache.geode.internal.cache.PrimaryBucketException) TransactionDataRebalancedException(org.apache.geode.cache.TransactionDataRebalancedException) TransactionDataNodeHasDepartedException(org.apache.geode.cache.TransactionDataNodeHasDepartedException)

Example 27 with TransactionException

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

the class PartitionedTXRegionStub method findObject.

public Object findObject(KeyInfo keyInfo, boolean isCreate, boolean generateCallbacks, Object value, boolean peferCD, ClientProxyMembershipID requestingClient, EntryEventImpl clientEvent) {
    Object retVal = null;
    final Object key = keyInfo.getKey();
    final Object callbackArgument = keyInfo.getCallbackArg();
    PartitionedRegion pr = (PartitionedRegion) region;
    try {
        retVal = pr.getRemotely((InternalDistributedMember) state.getTarget(), keyInfo.getBucketId(), key, callbackArgument, peferCD, requestingClient, clientEvent, false);
    } catch (TransactionException e) {
        RuntimeException re = getTransactionException(keyInfo, e);
        re.initCause(e.getCause());
        throw re;
    } catch (PrimaryBucketException e) {
        RuntimeException re = getTransactionException(keyInfo, e);
        re.initCause(e);
        throw re;
    } catch (ForceReattemptException e) {
        if (isBucketNotFoundException(e)) {
            RuntimeException re = getTransactionException(keyInfo, e);
            re.initCause(e);
            throw re;
        }
        waitToRetry();
        RuntimeException re = getTransactionException(keyInfo, e);
        re.initCause(e);
        throw re;
    }
    trackBucketForTx(keyInfo);
    return retVal;
}
Also used : TransactionException(org.apache.geode.cache.TransactionException) ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) PrimaryBucketException(org.apache.geode.internal.cache.PrimaryBucketException)

Example 28 with TransactionException

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

the class PartitionedTXRegionStub method invalidateExistingEntry.

public void invalidateExistingEntry(EntryEventImpl event, boolean invokeCallbacks, boolean forceNewEntry) {
    PartitionedRegion pr = (PartitionedRegion) event.getLocalRegion();
    try {
        pr.invalidateRemotely(state.getTarget(), event.getKeyInfo().getBucketId(), event);
    } catch (TransactionException e) {
        RuntimeException re = getTransactionException(event.getKeyInfo(), e);
        re.initCause(e.getCause());
        throw re;
    } catch (PrimaryBucketException e) {
        RuntimeException re = getTransactionException(event.getKeyInfo(), e);
        re.initCause(e);
        throw re;
    } catch (ForceReattemptException e) {
        RuntimeException re;
        if (isBucketNotFoundException(e)) {
            re = new TransactionDataRebalancedException(LocalizedStrings.PartitionedRegion_TRANSACTIONAL_DATA_MOVED_DUE_TO_REBALANCING.toLocalizedString());
        } else {
            re = new TransactionDataNodeHasDepartedException(LocalizedStrings.PartitionedRegion_TRANSACTION_DATA_NODE_0_HAS_DEPARTED_TO_PROCEED_ROLLBACK_THIS_TRANSACTION_AND_BEGIN_A_NEW_ONE.toLocalizedString(state.getTarget()));
        }
        re.initCause(e);
        waitToRetry();
        throw re;
    }
    trackBucketForTx(event.getKeyInfo());
}
Also used : TransactionException(org.apache.geode.cache.TransactionException) ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) PrimaryBucketException(org.apache.geode.internal.cache.PrimaryBucketException) TransactionDataRebalancedException(org.apache.geode.cache.TransactionDataRebalancedException) TransactionDataNodeHasDepartedException(org.apache.geode.cache.TransactionDataNodeHasDepartedException)

Example 29 with TransactionException

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

the class MemberFunctionExecutor method validateExecution.

@Override
public void validateExecution(final Function function, final Set dest) {
    final InternalCache cache = GemFireCacheImpl.getInstance();
    if (cache != null && cache.getTxManager().getTXState() != null) {
        if (dest.size() > 1) {
            throw new TransactionException(LocalizedStrings.PartitionedRegion_TX_FUNCTION_ON_MORE_THAN_ONE_NODE.toLocalizedString());
        } else {
            assert dest.size() == 1;
            DistributedMember funcTarget = (DistributedMember) dest.iterator().next();
            DistributedMember target = cache.getTxManager().getTXState().getTarget();
            if (target == null) {
                cache.getTxManager().getTXState().setTarget(funcTarget);
            } else if (!target.equals(funcTarget)) {
                throw new TransactionDataNotColocatedException(LocalizedStrings.PartitionedRegion_TX_FUNCTION_EXECUTION_NOT_COLOCATED.toLocalizedString());
            }
        }
    }
    if (function.optimizeForWrite() && cache != null && cache.getInternalResourceManager().getHeapMonitor().containsHeapCriticalMembers(dest) && !MemoryThresholds.isLowMemoryExceptionDisabled()) {
        Set<InternalDistributedMember> hcm = cache.getResourceAdvisor().adviseCritialMembers();
        Set<DistributedMember> sm = SetUtils.intersection(hcm, dest);
        throw new LowMemoryException(LocalizedStrings.ResourceManager_LOW_MEMORY_FOR_0_FUNCEXEC_MEMBERS_1.toLocalizedString(new Object[] { function.getId(), sm }), sm);
    }
}
Also used : TransactionException(org.apache.geode.cache.TransactionException) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) TransactionDataNotColocatedException(org.apache.geode.cache.TransactionDataNotColocatedException) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) DistributedMember(org.apache.geode.distributed.DistributedMember) InternalCache(org.apache.geode.internal.cache.InternalCache) LowMemoryException(org.apache.geode.cache.LowMemoryException)

Example 30 with TransactionException

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

the class DistributedRegionFunctionExecutor method validateExecution.

/*
   * (non-Javadoc)
   * 
   * @see
   * org.apache.geode.internal.cache.execute.AbstractExecution#validateExecution(org.apache.geode.
   * cache.execute.Function, java.util.Set)
   */
@Override
public void validateExecution(Function function, Set targetMembers) {
    InternalCache cache = region.getGemFireCache();
    if (cache != null && cache.getTxManager().getTXState() != null) {
        if (targetMembers.size() > 1) {
            throw new TransactionException(LocalizedStrings.PartitionedRegion_TX_FUNCTION_ON_MORE_THAN_ONE_NODE.toLocalizedString());
        } else {
            assert targetMembers.size() == 1;
            DistributedMember funcTarget = (DistributedMember) targetMembers.iterator().next();
            DistributedMember target = cache.getTxManager().getTXState().getTarget();
            if (target == null) {
                cache.getTxManager().getTXState().setTarget(funcTarget);
            } else if (!target.equals(funcTarget)) {
                throw new TransactionDataNotColocatedException(LocalizedStrings.PartitionedRegion_TX_FUNCTION_EXECUTION_NOT_COLOCATED_0_1.toLocalizedString(target, funcTarget));
            }
        }
    }
    if (!MemoryThresholds.isLowMemoryExceptionDisabled() && function.optimizeForWrite()) {
        try {
            region.checkIfAboveThreshold(null);
        } catch (LowMemoryException ignore) {
            Set<DistributedMember> htrm = region.getMemoryThresholdReachedMembers();
            throw new LowMemoryException(LocalizedStrings.ResourceManager_LOW_MEMORY_FOR_0_FUNCEXEC_MEMBERS_1.toLocalizedString(function.getId(), htrm), htrm);
        }
    }
}
Also used : TransactionException(org.apache.geode.cache.TransactionException) Set(java.util.Set) TransactionDataNotColocatedException(org.apache.geode.cache.TransactionDataNotColocatedException) DistributedMember(org.apache.geode.distributed.DistributedMember) InternalCache(org.apache.geode.internal.cache.InternalCache) LowMemoryException(org.apache.geode.cache.LowMemoryException)

Aggregations

TransactionException (org.apache.geode.cache.TransactionException)31 TransactionDataRebalancedException (org.apache.geode.cache.TransactionDataRebalancedException)12 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)11 TransactionDataNotColocatedException (org.apache.geode.cache.TransactionDataNotColocatedException)9 ForceReattemptException (org.apache.geode.internal.cache.ForceReattemptException)9 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)9 PrimaryBucketException (org.apache.geode.internal.cache.PrimaryBucketException)9 EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)7 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)7 LowMemoryException (org.apache.geode.cache.LowMemoryException)6 DistributedMember (org.apache.geode.distributed.DistributedMember)6 InternalCache (org.apache.geode.internal.cache.InternalCache)6 CacheLoaderException (org.apache.geode.cache.CacheLoaderException)5 CacheWriterException (org.apache.geode.cache.CacheWriterException)5 UnsupportedOperationInTransactionException (org.apache.geode.cache.UnsupportedOperationInTransactionException)5 IOException (java.io.IOException)4 RollbackException (javax.transaction.RollbackException)4 CancelException (org.apache.geode.CancelException)4 CacheClosedException (org.apache.geode.cache.CacheClosedException)4 CommitConflictException (org.apache.geode.cache.CommitConflictException)4