use of org.apache.geode.distributed.internal.ReplyException in project geode by apache.
the class FunctionStreamingResultCollector method getResult.
public Object getResult(long timeout, TimeUnit unit) throws FunctionException, InterruptedException {
long timeoutInMillis = unit.toMillis(timeout);
if (this.resultCollected) {
throw new FunctionException(LocalizedStrings.ExecuteFunction_RESULTS_ALREADY_COLLECTED.toLocalizedString());
}
this.resultCollected = true;
// Should convert it from unit to milliseconds
if (this.userRC != null) {
try {
long timeBefore = System.currentTimeMillis();
boolean isNotTimedOut;
if (execution instanceof DistributedRegionFunctionExecutor || execution instanceof MultiRegionFunctionExecutor) {
isNotTimedOut = this.waitForCacheOrFunctionException(timeoutInMillis);
} else {
isNotTimedOut = this.waitForRepliesUninterruptibly(timeoutInMillis);
}
if (!isNotTimedOut) {
throw new FunctionException(LocalizedStrings.ExecuteFunction_RESULTS_NOT_COLLECTED_IN_TIME_PROVIDED.toLocalizedString());
}
long timeAfter = System.currentTimeMillis();
timeoutInMillis = timeoutInMillis - (timeAfter - timeBefore);
if (timeoutInMillis < 0)
timeoutInMillis = 0;
if (this.removedNodes != null) {
if (this.removedNodes.size() != 0) {
// end the rc and clear it
clearResults();
this.execution = this.execution.setIsReExecute();
ResultCollector newRc = null;
if (execution.isFnSerializationReqd()) {
newRc = this.execution.execute(fn);
} else {
newRc = this.execution.execute(fn.getId());
}
return newRc.getResult(timeoutInMillis, unit);
}
}
if (!this.execution.getWaitOnExceptionFlag() && this.fites.size() > 0) {
throw new FunctionException(this.fites.get(0));
}
} catch (FunctionInvocationTargetException fite) {
// function.
if (!(execution instanceof DistributedRegionFunctionExecutor || execution instanceof MultiRegionFunctionExecutor) || !fn.isHA()) {
throw new FunctionException(fite);
} else if (execution.isClientServerMode()) {
clearResults();
FunctionInvocationTargetException iFITE = new InternalFunctionInvocationTargetException(fite.getMessage());
throw new FunctionException(iFITE);
} else {
clearResults();
this.execution = this.execution.setIsReExecute();
ResultCollector newRc = null;
if (execution.isFnSerializationReqd()) {
newRc = this.execution.execute(fn);
} else {
newRc = this.execution.execute(fn.getId());
}
return newRc.getResult(timeoutInMillis, unit);
}
} catch (CacheClosedException e) {
if (!(execution instanceof DistributedRegionFunctionExecutor || execution instanceof MultiRegionFunctionExecutor) || !fn.isHA()) {
FunctionInvocationTargetException fite = new FunctionInvocationTargetException(e.getMessage());
throw new FunctionException(fite);
} else if (execution.isClientServerMode()) {
clearResults();
FunctionInvocationTargetException fite = new InternalFunctionInvocationTargetException(e.getMessage());
throw new FunctionException(fite);
} else {
clearResults();
this.execution = this.execution.setIsReExecute();
ResultCollector newRc = null;
if (execution.isFnSerializationReqd()) {
newRc = this.execution.execute(fn);
} else {
newRc = this.execution.execute(fn.getId());
}
return newRc.getResult(timeoutInMillis, unit);
}
}// }
catch (ForceReattemptException e) {
if (!(execution instanceof DistributedRegionFunctionExecutor || execution instanceof MultiRegionFunctionExecutor) || !fn.isHA()) {
FunctionInvocationTargetException fite = new FunctionInvocationTargetException(e.getMessage());
throw new FunctionException(fite);
} else if (execution.isClientServerMode()) {
clearResults();
FunctionInvocationTargetException fite = new InternalFunctionInvocationTargetException(e.getMessage());
throw new FunctionException(fite);
} else {
clearResults();
this.execution = this.execution.setIsReExecute();
ResultCollector newRc = null;
if (execution.isFnSerializationReqd()) {
newRc = this.execution.execute(fn);
} else {
newRc = this.execution.execute(fn.getId());
}
return newRc.getResult(timeoutInMillis, unit);
}
} catch (ReplyException e) {
if (!(execution.waitOnException || execution.forwardExceptions)) {
throw new FunctionException(e.getCause());
}
}
return this.userRC.getResult(timeoutInMillis, unit);
}
return null;
}
use of org.apache.geode.distributed.internal.ReplyException in project geode by apache.
the class FunctionStreamingResultCollector method stillWaitingFromNodes.
protected boolean stillWaitingFromNodes() {
if (shutdown) {
// Create the exception here, so that the call stack reflects the
// failed computation. If you set the exception in onShutdown,
// the resulting stack is not of interest.
ReplyException re = new ReplyException(new DistributedSystemDisconnectedException(LocalizedStrings.ReplyProcessor21_ABORTED_DUE_TO_SHUTDOWN.toLocalizedString()));
this.exception = re;
return false;
}
// return (numMembers()-this.numMemberDeparted) > 0;
return numMembers() > 0;
}
use of org.apache.geode.distributed.internal.ReplyException in project geode by apache.
the class FunctionStreamingResultCollector method getResult.
public Object getResult() throws FunctionException {
if (this.resultCollected) {
throw new FunctionException(LocalizedStrings.ExecuteFunction_RESULTS_ALREADY_COLLECTED.toLocalizedString());
}
this.resultCollected = true;
if (this.userRC != null) {
try {
if (execution instanceof DistributedRegionFunctionExecutor || execution instanceof MultiRegionFunctionExecutor) {
this.waitForCacheOrFunctionException(0);
} else {
waitForRepliesUninterruptibly(0);
}
if (this.removedNodes != null) {
if (this.removedNodes.size() != 0) {
// end the rc and clear it
clearResults();
this.execution = this.execution.setIsReExecute();
ResultCollector newRc = null;
if (execution.isFnSerializationReqd()) {
newRc = this.execution.execute(fn);
} else {
newRc = this.execution.execute(fn.getId());
}
return newRc.getResult();
}
}
if (!this.execution.getWaitOnExceptionFlag() && this.fites.size() > 0) {
throw new FunctionException(this.fites.get(0));
}
} catch (FunctionInvocationTargetException fite) {
if (!(execution instanceof DistributedRegionFunctionExecutor || execution instanceof MultiRegionFunctionExecutor) || !fn.isHA()) {
throw new FunctionException(fite);
} else if (execution.isClientServerMode()) {
clearResults();
FunctionInvocationTargetException iFITE = new InternalFunctionInvocationTargetException(fite.getMessage());
throw new FunctionException(iFITE);
} else {
clearResults();
this.execution = this.execution.setIsReExecute();
ResultCollector newRc = null;
if (execution.isFnSerializationReqd()) {
newRc = this.execution.execute(fn);
} else {
newRc = this.execution.execute(fn.getId());
}
return newRc.getResult();
}
} catch (CacheClosedException e) {
if (!(execution instanceof DistributedRegionFunctionExecutor || execution instanceof MultiRegionFunctionExecutor) || !fn.isHA()) {
FunctionInvocationTargetException fite = new FunctionInvocationTargetException(e.getMessage());
throw new FunctionException(fite);
} else if (execution.isClientServerMode()) {
clearResults();
FunctionInvocationTargetException fite = new InternalFunctionInvocationTargetException(e.getMessage());
throw new FunctionException(fite);
} else {
clearResults();
this.execution = this.execution.setIsReExecute();
ResultCollector newRc = null;
if (execution.isFnSerializationReqd()) {
newRc = this.execution.execute(fn);
} else {
newRc = this.execution.execute(fn.getId());
}
return newRc.getResult();
}
}// }
catch (ForceReattemptException e) {
if (!(execution instanceof DistributedRegionFunctionExecutor || execution instanceof MultiRegionFunctionExecutor) || !fn.isHA()) {
FunctionInvocationTargetException fite = new FunctionInvocationTargetException(e.getMessage());
throw new FunctionException(fite);
} else if (execution.isClientServerMode()) {
clearResults();
FunctionInvocationTargetException fite = new InternalFunctionInvocationTargetException(e.getMessage());
throw new FunctionException(fite);
} else {
clearResults();
this.execution = this.execution.setIsReExecute();
ResultCollector newRc = null;
if (execution.isFnSerializationReqd()) {
newRc = this.execution.execute(fn);
} else {
newRc = this.execution.execute(fn.getId());
}
return newRc.getResult();
}
} catch (ReplyException e) {
if (!(execution.waitOnException || execution.forwardExceptions)) {
throw new FunctionException(e.getCause());
}
}
return this.userRC.getResult();
}
return null;
}
use of org.apache.geode.distributed.internal.ReplyException in project geode by apache.
the class CheckTypeRegistryState method send.
public static void send(DM dm) {
Set recipients = dm.getOtherDistributionManagerIds();
ReplyProcessor21 replyProcessor = new ReplyProcessor21(dm, recipients);
CheckTypeRegistryState msg = new CheckTypeRegistryState(replyProcessor.getProcessorId());
msg.setRecipients(recipients);
dm.putOutgoing(msg);
try {
replyProcessor.waitForReplies();
} catch (ReplyException e) {
if (e.getCause() instanceof PdxInitializationException) {
throw new PdxInitializationException("Bad PDX configuration on member " + e.getSender() + ": " + e.getCause().getMessage(), e.getCause());
} else {
throw new InternalGemFireError("Unexpected exception", e);
}
} catch (InterruptedException e) {
throw new InternalGemFireError("Unexpected exception", e);
}
}
use of org.apache.geode.distributed.internal.ReplyException in project geode by apache.
the class CheckTypeRegistryState method process.
@Override
protected void process(DistributionManager dm) {
ReplyException e = null;
try {
InternalCache cache = GemFireCacheImpl.getInstance();
if (cache != null && !cache.isClosed()) {
TypeRegistry pdxRegistry = cache.getPdxRegistry();
if (pdxRegistry != null) {
TypeRegistration registry = pdxRegistry.getTypeRegistration();
if (registry instanceof PeerTypeRegistration) {
PeerTypeRegistration peerRegistry = (PeerTypeRegistration) registry;
peerRegistry.verifyConfiguration();
}
}
}
} catch (Exception ex) {
e = new ReplyException(ex);
} finally {
ReplyMessage rm = new ReplyMessage();
rm.setException(e);
rm.setProcessorId(processorId);
rm.setRecipient(getSender());
dm.putOutgoing(rm);
}
}
Aggregations