use of org.apache.geode.cache.execute.FunctionException in project geode by apache.
the class ServerToClientFunctionResultSender65 method lastResult.
@Override
public synchronized void lastResult(Object oneResult, DistributedMember memberID) {
this.lastResultReceived = true;
if (!isOkayToSendResult()) {
if (logger.isDebugEnabled()) {
logger.debug(" ServerToClientFunctionResultSender65 not sending lastResult {} as the server has shutdown", oneResult);
}
return;
}
try {
if (logger.isDebugEnabled()) {
logger.debug("ServerToClientFunctionResultSender sending last result2 {} " + oneResult);
}
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(" ServerToClientFunctionResultSender65 sending lastResult {}", oneResult);
}
List<Object> result = new ArrayList<Object>();
result.add(oneResult);
result.add(memberID);
this.setBuffer();
this.msg.setServerConnection(this.sc);
if (oneResult instanceof InternalFunctionException) {
this.msg.setNumberOfParts(2);
this.msg.setLastChunkAndNumParts(true, 2);
} else {
this.msg.setNumberOfParts(1);
this.msg.setLastChunkAndNumParts(true, 1);
}
this.msg.addObjPart(result);
if (oneResult instanceof InternalFunctionException) {
List<Object> result2 = new ArrayList<Object>();
result2.add(BaseCommand.getExceptionTrace((Throwable) oneResult));
result2.add(memberID);
this.msg.addObjPart(result2);
}
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 sendResult.
@Override
public synchronized void sendResult(Object oneResult, DistributedMember memberID) {
if (!isOkayToSendResult()) {
if (logger.isDebugEnabled()) {
logger.debug(" ServerToClientFunctionResultSender65 not sending result {} as the server has shutdown", oneResult);
}
return;
}
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(" ServerToClientFunctionResultSender65 sending result {}", oneResult);
}
List<Object> result = new ArrayList<Object>();
result.add(oneResult);
result.add(memberID);
this.setBuffer();
this.msg.setNumberOfParts(1);
this.msg.addObjPart(result);
this.msg.sendChunk(this.sc);
FunctionStats.getFunctionStats(fn.getId()).incResultsReturned();
} catch (IOException ex) {
if (isOkayToSendResult()) {
throw new FunctionException(LocalizedStrings.ExecuteFunction_IOEXCEPTION_WHILE_SENDING_RESULT_CHUNK.toLocalizedString(), ex);
}
}
}
use of org.apache.geode.cache.execute.FunctionException in project geode by apache.
the class ServerToClientFunctionResultSender65 method sendResult.
@Override
public synchronized void sendResult(Object oneResult) {
if (!isOkayToSendResult()) {
if (logger.isDebugEnabled()) {
logger.debug(" ServerToClientFunctionResultSender65 not sending result {} as the server has shutdown", oneResult);
}
return;
}
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(" ServerToClientFunctionResultSender65 sending result {}", oneResult);
}
DistributedMember memberID = InternalDistributedSystem.getAnyInstance().getDistributionManager().getId();
List<Object> result = new ArrayList<Object>();
result.add(oneResult);
result.add(memberID);
this.setBuffer();
this.msg.setNumberOfParts(1);
this.msg.addObjPart(result);
this.msg.sendChunk(this.sc);
FunctionStats.getFunctionStats(fn.getId()).incResultsReturned();
} catch (IOException ex) {
if (isOkayToSendResult()) {
throw new FunctionException(LocalizedStrings.ExecuteFunction_IOEXCEPTION_WHILE_SENDING_RESULT_CHUNK.toLocalizedString(), ex);
}
}
}
use of org.apache.geode.cache.execute.FunctionException in project geode by apache.
the class ServerRegionFunctionExecutor method executeOnServer.
private ResultCollector executeOnServer(String functionId, ResultCollector collector, byte hasResult, boolean isHA, boolean optimizeForWrite) throws FunctionException {
ServerRegionProxy srp = getServerRegionProxy();
FunctionStats stats = FunctionStats.getFunctionStats(functionId, this.region.getSystem());
try {
validateExecution(null, null);
long start = stats.startTime();
stats.startFunctionExecution(true);
srp.executeFunction(this.region.getFullPath(), functionId, this, collector, hasResult, isHA, optimizeForWrite, 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);
}
}
use of org.apache.geode.cache.execute.FunctionException in project geode by apache.
the class ServerToClientFunctionResultSender method lastResult.
public synchronized void lastResult(Object oneResult) {
this.lastResultReceived = true;
if (!isOkayToSendResult()) {
if (logger.isDebugEnabled()) {
logger.debug("ServerToClientFunctionResultSender not sending lastResult {} as the server has shutdown", oneResult);
}
return;
}
if (this.lastResultReceived) {
return;
}
if (logger.isDebugEnabled()) {
logger.debug("ServerToClientFunctionResultSender sending last result1 {} " + 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);
}
}
}
Aggregations