use of org.apache.geode.internal.cache.ForceReattemptException in project geode by apache.
the class PartitionedTXRegionStub method getEntry.
public Entry getEntry(KeyInfo keyInfo, boolean allowTombstones) {
PartitionedRegion pr = (PartitionedRegion) region;
try {
Entry e = pr.getEntryRemotely((InternalDistributedMember) state.getTarget(), keyInfo.getBucketId(), keyInfo.getKey(), false, allowTombstones);
trackBucketForTx(keyInfo);
return e;
} catch (EntryNotFoundException enfe) {
return null;
} 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) {
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;
}
}
use of org.apache.geode.internal.cache.ForceReattemptException in project geode by apache.
the class PartitionedRegionFunctionResultSender method sendResult.
public void sendResult(Object oneResult) {
if (!this.function.hasResult()) {
throw new IllegalStateException(LocalizedStrings.ExecuteFunction_CANNOT_0_RESULTS_HASRESULT_FALSE.toLocalizedString("send"));
}
if (this.serverSender != null) {
logger.debug("PartitionedRegionFunctionResultSender sending result from local node to client {}", oneResult);
clientSend(oneResult, dm.getDistributionManagerId());
} else {
// P2P
if (this.msg != null) {
try {
logger.debug("PartitionedRegionFunctionResultSender sending result from remote node {}", oneResult);
this.msg.sendReplyForOneResult(dm, pr, time, oneResult, false, enableOrderedResultStreming);
} catch (ForceReattemptException e) {
throw new FunctionException(e);
} catch (InterruptedException e) {
throw new FunctionException(e);
}
} else {
logger.debug("PartitionedRegionFunctionResultSender adding result to ResultCollector on local node {}", oneResult);
this.rc.addResult(dm.getDistributionManagerId(), oneResult);
FunctionStats.getFunctionStats(function.getId(), this.dm.getSystem()).incResultsReceived();
}
// incrementing result sent stats.
FunctionStats.getFunctionStats(function.getId(), this.dm.getSystem()).incResultsReturned();
}
}
use of org.apache.geode.internal.cache.ForceReattemptException in project geode by apache.
the class PartitionedRegionFunctionResultSender method lastResult.
// this must be getting called directly from function
public void lastResult(Object oneResult) {
if (!this.function.hasResult()) {
throw new IllegalStateException(LocalizedStrings.ExecuteFunction_CANNOT_0_RESULTS_HASRESULT_FALSE.toLocalizedString("send"));
}
if (this.serverSender != null) {
// Client-Server
if (this.localLastResultRecieved) {
return;
}
if (onlyLocal) {
checkForBucketMovement(oneResult);
if (bme != null) {
clientSend(oneResult, dm.getDistributionManagerId());
lastClientSend(dm.getDistributionManagerId(), bme);
} else {
lastClientSend(dm.getDistributionManagerId(), oneResult);
}
this.rc.endResults();
this.localLastResultRecieved = true;
} else {
// call a synchronized method as local node is also waiting to send lastResult
lastResult(oneResult, rc, false, true, dm.getDistributionManagerId());
}
} else {
if (this.msg != null) {
checkForBucketMovement(oneResult);
try {
if (this.bme != null) {
this.msg.sendReplyForOneResult(dm, pr, time, oneResult, false, enableOrderedResultStreming);
throw bme;
} else {
this.msg.sendReplyForOneResult(dm, pr, time, oneResult, true, enableOrderedResultStreming);
}
} catch (ForceReattemptException e) {
throw new FunctionException(e);
} catch (InterruptedException e) {
throw new FunctionException(e);
}
} else {
if (this.localLastResultRecieved) {
return;
}
if (onlyLocal) {
checkForBucketMovement(oneResult);
if (bme != null) {
this.rc.addResult(dm.getDistributionManagerId(), oneResult);
this.rc.addResult(dm.getDistributionManagerId(), bme);
} else {
this.rc.addResult(dm.getDistributionManagerId(), oneResult);
}
// exception thrown will do end result
this.rc.endResults();
this.localLastResultRecieved = true;
} else {
// call a synchronized method as local node is also waiting to send lastResult
lastResult(oneResult, rc, false, true, dm.getDistributionManagerId());
}
FunctionStats.getFunctionStats(function.getId(), this.dm.getSystem()).incResultsReceived();
}
// incrementing result sent stats.
// Bug : remote node as well as local node calls this method to send
// the result When the remote nodes are added to the local result collector at that
// time the stats for the result sent is again incremented : Once the PR team comes with the
// concept of the Streaming FunctionOperation
// for the partitioned Region then it will be simple to fix this problem.
FunctionStats.getFunctionStats(function.getId(), this.dm.getSystem()).incResultsReturned();
}
}
use of org.apache.geode.internal.cache.ForceReattemptException in project geode by apache.
the class BucketSizeMessage method send.
/**
* Sends a BucketSize message to determine the number of bytes the bucket consumes
*
* @param recipient the member that the contains keys/value message is sent to
* @param r the PartitionedRegion that contains the bucket
* @param bucketId the identity of the bucket whose size should be returned.
* @return the processor used to read the returned size
* @throws ForceReattemptException if the peer is no longer available
*/
public static BucketSizeResponse send(InternalDistributedMember recipient, PartitionedRegion r, int bucketId) throws ForceReattemptException {
Assert.assertTrue(recipient != null, "BucketSizeMessage NULL reply message");
BucketSizeResponse p = new BucketSizeResponse(r.getSystem(), Collections.singleton(recipient));
BucketSizeMessage m = new BucketSizeMessage(recipient, r.getPRId(), p, bucketId);
Set failures = r.getDistributionManager().putOutgoing(m);
if (failures != null && failures.size() > 0) {
throw new ForceReattemptException(LocalizedStrings.BucketSizeMessage_FAILED_SENDING_0.toLocalizedString(m));
}
return p;
}
use of org.apache.geode.internal.cache.ForceReattemptException in project geode by apache.
the class MemberFunctionResultSender method sendResult.
public void sendResult(Object oneResult) {
if (!this.function.hasResult()) {
throw new IllegalStateException(LocalizedStrings.ExecuteFunction_CANNOT_0_RESULTS_HASRESULT_FALSE.toLocalizedString("send"));
}
if (this.serverSender != null) {
// Client-Server
if (logger.isDebugEnabled()) {
logger.debug("MemberFunctionResultSender sending result from local node to client {}", oneResult);
}
this.serverSender.sendResult(oneResult);
} else {
// P2P
if (this.msg != null) {
try {
this.msg.sendReplyForOneResult(dm, oneResult, false, enableOrderedResultStreming);
} catch (QueryException e) {
throw new FunctionException(e);
} catch (ForceReattemptException e) {
throw new FunctionException(e);
} catch (InterruptedException e) {
throw new FunctionException(e);
}
} else {
this.rc.addResult(this.dm.getDistributionManagerId(), oneResult);
FunctionStats.getFunctionStats(function.getId(), this.dm.getSystem()).incResultsReceived();
}
// incrementing result sent stats.
FunctionStats.getFunctionStats(function.getId(), this.dm.getSystem()).incResultsReturned();
}
}
Aggregations