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());
}
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;
}
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());
}
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);
}
}
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);
}
}
}
Aggregations