7 Replies Latest reply on Mar 15, 2005 12:02 PM by belaban

    org.jgroups.blocks.RpcDispatcher and Exceptions

    starksm64

      I'm looking into why the HAPartitionImpl extension of the RpcDispatcher.handle method is only logging checked exceptions thrown by the method invocation and I see that the RpcDispatcher has no concept of exceptions being thrown from the rpc call. I see the problem with merging exceptions, but it seems that there should be a notion of whether or not all targets of the invocation completed successfully as opposed to just dispatching the invocation.

      I would suggest that the RspList contain both normal return values, and exceptions thrown so that the invoker of the rpc call can make better decisions regarding the outcome of the rpc call.

        • 1. Re: org.jgroups.blocks.RpcDispatcher and Exceptions
          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

            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

              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

                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

                  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

                    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

                      Successful invocation: Rsp.received == true
                      Failure during invocation: Rsp.received == true and Rsp.retval instanceof Throwable == true