use of org.apache.geode.cache.execute.FunctionException in project geode by apache.
the class ServerFunctionExecutor method executeOnServer.
private ResultCollector executeOnServer(Function function, ResultCollector rc, byte hasResult) {
FunctionStats stats = FunctionStats.getFunctionStats(function.getId());
try {
validateExecution(function, null);
long start = stats.startTime();
stats.startFunctionExecution(true);
ExecuteFunctionOp.execute(this.pool, function, this, args, memberMappedArg, this.allServers, hasResult, rc, this.isFnSerializationReqd, UserAttributes.userAttributes.get(), groups);
stats.endFunctionExecution(start, true);
rc.endResults();
return rc;
} catch (FunctionException functionException) {
stats.endFunctionExecutionWithException(true);
throw functionException;
} catch (ServerConnectivityException exception) {
throw exception;
} catch (Exception exception) {
stats.endFunctionExecutionWithException(true);
throw new FunctionException(exception);
}
}
use of org.apache.geode.cache.execute.FunctionException in project geode by apache.
the class ServerToClientFunctionResultSender method lastResult.
public synchronized void lastResult(Object oneResult, DistributedMember memberID) {
this.lastResultReceived = true;
if (!isOkayToSendResult()) {
if (logger.isDebugEnabled()) {
logger.debug("ServerToClientFunctionResultSender not sending lastResult {} as the server has shutdown", oneResult);
}
return;
}
if (logger.isDebugEnabled()) {
logger.debug("ServerToClientFunctionResultSender sending last result2 {} " + oneResult);
}
try {
authorizeResult(oneResult);
if (!this.fn.hasResult()) {
throw new IllegalStateException(LocalizedStrings.ExecuteFunction_CANNOT_0_RESULTS_HASRESULT_FALSE.toLocalizedString("send"));
}
if (!headerSent) {
sendHeader();
}
if (logger.isDebugEnabled()) {
logger.debug("ServerToClientFunctionResultSender sending lastResult {}", oneResult);
}
this.setBuffer();
this.msg.setNumberOfParts(1);
this.msg.addObjPart(oneResult);
this.msg.setLastChunk(true);
this.msg.sendChunk(this.sc);
this.sc.setAsTrue(Command.RESPONDED);
FunctionStats.getFunctionStats(fn.getId()).incResultsReturned();
} catch (IOException ex) {
if (isOkayToSendResult()) {
throw new FunctionException(LocalizedStrings.ExecuteFunction_IOEXCEPTION_WHILE_SENDING_LAST_CHUNK.toLocalizedString(), ex);
}
}
}
use of org.apache.geode.cache.execute.FunctionException in project geode by apache.
the class ServerToClientFunctionResultSender65 method writeFunctionExceptionResponse.
@Override
protected void writeFunctionExceptionResponse(ChunkedMessage message, String errormessage, Throwable e) throws IOException {
if (logger.isDebugEnabled()) {
logger.debug(" ServerToClientFunctionResultSender sending Function Error Response : {}", errormessage);
}
int numParts = 0;
message.clear();
if (e instanceof FunctionException && e.getCause() instanceof InternalFunctionInvocationTargetException) {
message.setNumberOfParts(3);
message.addObjPart(e);
message.addStringPart(BaseCommand.getExceptionTrace(e));
InternalFunctionInvocationTargetException fe = (InternalFunctionInvocationTargetException) e.getCause();
message.addObjPart(fe.getFailedNodeSet());
numParts = 3;
} else {
if (e instanceof FunctionException && e.getCause() instanceof QueryInvalidException) {
// Handle this exception differently since it can contain
// non-serializable objects.
// java.io.NotSerializableException: antlr.CommonToken
// create a new FunctionException on the original one's message (not cause).
e = new FunctionException(e.getLocalizedMessage());
}
message.setNumberOfParts(2);
message.addObjPart(e);
message.addStringPart(BaseCommand.getExceptionTrace(e));
numParts = 2;
}
message.setServerConnection(this.sc);
message.setLastChunkAndNumParts(true, numParts);
// message.setLastChunk(true);
message.sendChunk(this.sc);
this.sc.setAsTrue(Command.RESPONDED);
}
use of org.apache.geode.cache.execute.FunctionException in project geode by apache.
the class ServerFunctionExecutor method executeOnServerNoAck.
private void executeOnServerNoAck(String functionId, byte hasResult, boolean isHA, boolean optimizeForWrite) {
FunctionStats stats = FunctionStats.getFunctionStats(functionId);
try {
validateExecution(null, null);
long start = stats.startTime();
stats.startFunctionExecution(false);
ExecuteFunctionNoAckOp.execute(this.pool, functionId, args, memberMappedArg, this.allServers, hasResult, this.isFnSerializationReqd, isHA, optimizeForWrite, groups);
stats.endFunctionExecution(start, false);
} catch (FunctionException functionException) {
stats.endFunctionExecutionWithException(false);
throw functionException;
} catch (ServerConnectivityException exception) {
throw exception;
} catch (Exception exception) {
stats.endFunctionExecutionWithException(false);
throw new FunctionException(exception);
}
}
use of org.apache.geode.cache.execute.FunctionException in project geode by apache.
the class ServerRegionFunctionExecutor method executeOnServer.
private ResultCollector executeOnServer(Function function, ResultCollector collector, byte hasResult) throws FunctionException {
ServerRegionProxy srp = getServerRegionProxy();
FunctionStats stats = FunctionStats.getFunctionStats(function.getId(), this.region.getSystem());
try {
validateExecution(function, null);
long start = stats.startTime();
stats.startFunctionExecution(true);
srp.executeFunction(this.region.getFullPath(), function, this, collector, hasResult, false);
stats.endFunctionExecution(start, true);
return collector;
} catch (FunctionException functionException) {
stats.endFunctionExecutionWithException(true);
throw functionException;
} catch (Exception exception) {
stats.endFunctionExecutionWithException(true);
throw new FunctionException(exception);
}
}
Aggregations