use of org.apache.geode.cache.execute.FunctionException in project geode by apache.
the class QueryUsingFunctionContextDUnitTest method testNonColocatedRegionQueries.
@Test
public void testNonColocatedRegionQueries() {
IgnoredException.addIgnoredException("UnsupportedOperationException");
client.invoke(new CacheSerializableRunnable("Test query on non-colocated regions on server") {
@Override
public void run2() throws CacheException {
Set filter = new HashSet();
filter.add(0);
for (int i = 0; i < nonColocatedQueries.length; i++) {
function = new TestQueryFunction("queryFunction-1");
QueryUsingFunctionContextDUnitTest test = new QueryUsingFunctionContextDUnitTest();
try {
ArrayList queryResults2 = test.runQueryOnClientUsingFunc(function, PartitionedRegionName1, filter, nonColocatedQueries[i]);
fail("Function call did not fail for query with function context");
} catch (FunctionException e) {
if (!(e.getCause() instanceof UnsupportedOperationException)) {
Assert.fail("Should have received an UnsupportedOperationException but received", e);
}
}
}
}
});
}
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);
}
}
Aggregations