use of org.apache.geode.LogWriter 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.LogWriter 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.LogWriter 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);
}
}
use of org.apache.geode.LogWriter in project geode by apache.
the class TestFunction method execute1.
public void execute1(FunctionContext context) {
DistributedSystem ds = InternalDistributedSystem.getAnyInstance();
LogWriter logger = ds.getLogWriter();
logger.info("Executing executeException in TestFunction on Member : " + ds.getDistributedMember() + "with Context : " + context);
context.getResultSender().lastResult((Serializable) context.getArguments());
}
use of org.apache.geode.LogWriter in project geode by apache.
the class TestFunction method execute2.
public void execute2(FunctionContext context) {
DistributedSystem ds = InternalDistributedSystem.getAnyInstance();
LogWriter logger = ds.getLogWriter();
try {
synchronized (this) {
this.wait(20000000);
}
} catch (InterruptedException e) {
}
context.getResultSender().lastResult(Boolean.TRUE);
}
Aggregations