-
1. Re: org.jgroups.blocks.RpcDispatcher and Exceptions
starksm64 Mar 11, 2005 11:11 AM (in response to starksm64)Looking more into the jgroups code it seems that a return value from an invocation to a node may be one of:
- the actual method return value
- null if the node does not respond
- an exception thrown by the method
The last two are ambiguous. There is a notion of whether or not a node replied such that the null can be filtered out, but an exception is still amibiguous. It looks like changes to the RspList, RequestCorrelator, and GroupRequest would be needed to make the notion of an exception explicit. The biggest problem is the lack of an exception in the org.jgroups.blocks.RequestHandler interface. -
2. Re: org.jgroups.blocks.RpcDispatcher and Exceptions
belaban Mar 14, 2005 6:03 AM (in response to starksm64)A Rsp has the following members (see below):
- received: if true, we did receive a result (although the result can be null, e.g. on a 'void' method)
- suspected: if true, the sender was suspected
- sender: the address of the sender
- retval: the actual return value. Can be null if a 'void' method was invoked, or no response was received. This can also be an exception if the method threw one.
We should be able to identify the outcome of the method call in all cases
public class Rsp {
/* flag that represents whether the response was received */
boolean received=false;
/* flag that represents whether the response was suspected */
boolean suspected=false;
/* The sender of this response */
Address sender=null;
/* the value from the response */
Object retval=null;
...
} -
3. Re: org.jgroups.blocks.RpcDispatcher and Exceptions
belaban Mar 14, 2005 6:05 AM (in response to starksm64)what's ambiguous about exceptions as return values ?
I could add another field "exception" to Rsp, but why not use retval ? -
4. Re: org.jgroups.blocks.RpcDispatcher and Exceptions
starksm64 Mar 14, 2005 8:30 AM (in response to starksm64)How do I know if the following method completed or threw an exception?
public Exception methodWithAmiguousReturnValue() throws Exception { ... }
-
5. Re: org.jgroups.blocks.RpcDispatcher and Exceptions
belaban Mar 14, 2005 4:36 PM (in response to starksm64)RspList rsps=dispatcher.callRemoteMethods(null, "methodWithAmiguousReturnValue", null, nulll);
for(int i=0; i < rsps.size(); i++) {
Rsp rsp=rsps.get(i);
Object retval=rsp.getValue();
if(retval != null && retval instanceof Trowable) {
// rethrow, or do something with it
}
} -
6. Re: org.jgroups.blocks.RpcDispatcher and Exceptions
starksm64 Mar 14, 2005 5:57 PM (in response to starksm64)And I still have no idea if this was a successful completion of the method or a failure during the method invocation.
-
7. Re: org.jgroups.blocks.RpcDispatcher and Exceptions
belaban Mar 15, 2005 12:02 PM (in response to starksm64)Successful invocation: Rsp.received == true
Failure during invocation: Rsp.received == true and Rsp.retval instanceof Throwable == true