use of org.apache.geode.internal.cache.execute.MyFunctionExecutionException in project geode by apache.
the class TestFunction method executeFunctionReexecuteException.
private synchronized void executeFunctionReexecuteException(FunctionContext context) {
retryCountForExecuteFunctionReexecuteException++;
DistributedSystem ds = InternalDistributedSystem.getAnyInstance();
LogWriter logger = ds.getLogWriter();
logger.fine("Executing executeException in TestFunction on Member : " + ds.getDistributedMember() + "with Context : " + context);
if (retryCountForExecuteFunctionReexecuteException >= 5) {
logger.fine("Tried Function Execution 5 times. Now Returning after 5 attempts");
context.getResultSender().lastResult(new Integer(retryCountForExecuteFunctionReexecuteException));
retryCountForExecuteFunctionReexecuteException = 0;
return;
}
if (context.getArguments() instanceof Boolean) {
logger.fine("MyFunctionExecutionException is intentionally thrown");
throw new FunctionInvocationTargetException(new MyFunctionExecutionException("I have been thrown from TestFunction"));
}
}
use of org.apache.geode.internal.cache.execute.MyFunctionExecutionException in project geode by apache.
the class TestFunction method executeWithThrowException.
private void executeWithThrowException(FunctionContext context) {
DistributedSystem ds = InternalDistributedSystem.getAnyInstance();
RegionFunctionContext rfContext = (RegionFunctionContext) context;
LogWriter logger = ds.getLogWriter();
logger.fine("Executing executeWithThrowException in TestFunction on Member : " + ds.getDistributedMember() + "with Context : " + context);
if (context.getArguments() instanceof Boolean) {
logger.fine("MyFunctionExecutionException Exception is intentionally thrown");
throw new MyFunctionExecutionException("I have been thrown from TestFunction");
} else if (rfContext.getArguments() instanceof Set) {
Set origKeys = (Set) rfContext.getArguments();
for (Iterator i = origKeys.iterator(); i.hasNext(); ) {
Region r = PartitionRegionHelper.getLocalDataForContext(rfContext);
Object key = i.next();
Object val = r.get(key);
if (val != null) {
throw new MyFunctionExecutionException("I have been thrown from TestFunction");
}
}
} else {
logger.fine("Result sent back :" + Boolean.FALSE);
rfContext.getResultSender().lastResult(Boolean.FALSE);
}
}
use of org.apache.geode.internal.cache.execute.MyFunctionExecutionException in project geode by apache.
the class TestFunction method executeFunctionReexecuteExceptionOnServer.
private synchronized void executeFunctionReexecuteExceptionOnServer(FunctionContext context) {
if (context.isPossibleDuplicate()) {
retryCount++;
} else {
firstExecutionCount++;
}
DistributedSystem ds = InternalDistributedSystem.getAnyInstance();
LogWriter logger = ds.getLogWriter();
logger.fine("Executing executeException in TestFunction on Member : " + ds.getDistributedMember() + "with Context : " + context);
if (retryCount >= 5) {
logger.fine("Tried Function Execution 5 times. Now Returning after 5 attempts");
context.getResultSender().sendResult(new Integer(firstExecutionCount));
context.getResultSender().lastResult(new Integer(retryCount));
firstExecutionCount = 0;
retryCount = 0;
return;
}
if (context.getArguments() instanceof Boolean) {
logger.fine("MyFunctionExecutionException Exception is intentionally thrown");
throw new InternalFunctionInvocationTargetException(new MyFunctionExecutionException("I have been thrown from TestFunction"));
}
}
use of org.apache.geode.internal.cache.execute.MyFunctionExecutionException in project geode by apache.
the class TestFunction method executeWithSendException.
private void executeWithSendException(FunctionContext context) {
DistributedSystem ds = InternalDistributedSystem.getAnyInstance();
LogWriter logger = ds.getLogWriter();
logger.fine("Executing executeWithSendException in TestFunction on Member : " + ds.getDistributedMember() + "with Context : " + context);
if (context.getArguments() instanceof Boolean) {
context.getResultSender().sendException(new MyFunctionExecutionException("I have been send from TestFunction"));
} else if (context.getArguments() instanceof String) {
String arg = (String) context.getArguments();
if (arg.equals("Multiple")) {
logger.fine("Sending Exception First time");
context.getResultSender().sendException(new MyFunctionExecutionException("I have been send from TestFunction"));
logger.fine("Sending Exception Second time");
context.getResultSender().sendException(new MyFunctionExecutionException("I have been send from TestFunction"));
}
} else if (context.getArguments() instanceof Set) {
Set args = (Set) context.getArguments();
for (int i = 0; i < args.size(); i++) {
context.getResultSender().sendResult(new Integer(i));
}
context.getResultSender().sendException(new MyFunctionExecutionException("I have been thrown from TestFunction with set"));
} else {
logger.fine("Result sent back :" + Boolean.FALSE);
context.getResultSender().lastResult(Boolean.FALSE);
}
}
use of org.apache.geode.internal.cache.execute.MyFunctionExecutionException in project geode by apache.
the class TestFunction method executeException.
private void executeException(FunctionContext context) {
DistributedSystem ds = InternalDistributedSystem.getAnyInstance();
LogWriter logger = ds.getLogWriter();
logger.fine("Executing executeException in TestFunction on Member : " + ds.getDistributedMember() + "with Context : " + context);
if (context.getArguments() instanceof Boolean) {
logger.fine("MyFunctionExecutionException Exception is intentionally thrown");
throw new MyFunctionExecutionException("I have been thrown from TestFunction");
} else if (context.getArguments() instanceof String) {
String key = (String) context.getArguments();
logger.fine("Result sent back :" + key);
context.getResultSender().lastResult(key);
} else if (context.getArguments() instanceof Set) {
Set origKeys = (Set) context.getArguments();
ArrayList vals = new ArrayList();
for (Iterator i = origKeys.iterator(); i.hasNext(); ) {
Object val = i.next();
if (val != null) {
vals.add(val);
}
}
logger.fine("Result sent back :" + vals);
context.getResultSender().lastResult(vals);
} else {
logger.fine("Result sent back :" + Boolean.FALSE);
context.getResultSender().lastResult(Boolean.FALSE);
}
}
Aggregations