org.jgroups.blocks

## Class RpcDispatcher

- java.lang.Object
- - org.jgroups.blocks.MessageDispatcher
  - - org.jgroups.blocks.RpcDispatcher

- All Implemented Interfaces:
    RequestHandler, ChannelListener
  Direct Known Subclasses:
    MuxRpcDispatcher

      public class RpcDispatcher
      extends MessageDispatcher
      implements ChannelListener

  This class allows a programmer to invoke remote methods in all (or single) group members and optionally wait for the return value(s). An application will typically create a channel and layer the RpcDispatcher building block on top of it, which allows it to dispatch remote methods (client role) and at the same time be called by other members (server role). This class is derived from MessageDispatcher. Is the equivalent of RpcProtocol on the application rather than protocol level.
  Author:
    Bela Ban

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `RpcDispatcher.Marshaller`
    `static interface` | `RpcDispatcher.Marshaller2`
    `static class` | `RpcDispatcher.MarshallerAdapter` Used to provide a Marshaller2 interface to a Marshaller.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.util.List<ChannelListener>` | `additionalChannelListeners`
    `protected MethodLookup` | `method_lookup`
    `protected RpcDispatcher.Marshaller2` | `req_marshaller` Marshaller to marshall requests at the caller and unmarshal requests at the receiver(s)
    `protected RpcDispatcher.Marshaller2` | `rsp_marshaller` Marshaller to marshal responses at the receiver(s) and unmarshal responses at the caller
    `protected java.lang.Object` | `server_obj`

    - ### Fields inherited from class org.jgroups.blocks.MessageDispatcher

      `adapter, channel, corr, handler, hardware_multicast_supported, id, local_addr, log, members, membership_listener, msg_listener, prot_adapter, req_handler, transport_adapter`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RpcDispatcher()`
    `RpcDispatcher(Channel channel, MessageListener l, MembershipListener l2, java.lang.Object server_obj)`
    `RpcDispatcher(Channel channel, MessageListener l, MembershipListener l2, java.lang.Object server_obj, boolean deadlock_detection)` Deprecated.
    `RpcDispatcher(Channel channel, MessageListener l, MembershipListener l2, java.lang.Object server_obj, boolean deadlock_detection, boolean concurrent_processing)` Deprecated.
    `RpcDispatcher(PullPushAdapter adapter, java.io.Serializable id, MessageListener l, MembershipListener l2, java.lang.Object server_obj)` Deprecated.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `addChannelListener(ChannelListener l)` Add a new channel listener to be notified on the channel's state change.
    `java.lang.Object` | `callRemoteMethod(Address dest, MethodCall call)` Deprecated.
    `java.lang.Object` | `callRemoteMethod(Address dest, MethodCall method_call, int mode, long timeout)` Deprecated.
    `java.lang.Object` | `callRemoteMethod(Address dest, MethodCall method_call, int mode, long timeout, boolean oob)` Deprecated.
    `java.lang.Object` | `callRemoteMethod(Address dest, MethodCall call, RequestOptions options)`
    `java.lang.Object` | `callRemoteMethod(Address dest, java.lang.String method_name, java.lang.Object[] args, java.lang.Class[] types, int mode, long timeout)` Deprecated.
    `java.lang.Object` | `callRemoteMethod(Address dest, java.lang.String method_name, java.lang.Object[] args, java.lang.Class[] types, RequestOptions options)`
    `java.lang.Object` | `callRemoteMethod(Address dest, java.lang.String method_name, java.lang.Object[] args, java.lang.String[] signature, int mode, long timeout)` Deprecated.
    `RspList` | `callRemoteMethods(java.util.Collection<Address> dests, MethodCall method_call, RequestOptions options)` Invokes a method in all members contained in dests (or all members if dests is null).
    `RspList` | `callRemoteMethods(java.util.Collection<Address> dests, java.lang.String method_name, java.lang.Object[] args, java.lang.Class[] types, RequestOptions options)`
    `RspList` | `callRemoteMethods(java.util.Vector<Address> dests, MethodCall method_call, int mode, long timeout)` Deprecated.
    `RspList` | `callRemoteMethods(java.util.Vector<Address> dests, java.lang.String method_name, java.lang.Object[] args, java.lang.Class[] types, int mode, long timeout)` Deprecated.
    `RspList` | `callRemoteMethods(java.util.Vector<Address> dests, java.lang.String method_name, java.lang.Object[] args, java.lang.Class[] types, int mode, long timeout, boolean use_anycasting)` Deprecated.
    `RspList` | `callRemoteMethods(java.util.Vector<Address> dests, java.lang.String method_name, java.lang.Object[] args, java.lang.Class[] types, int mode, long timeout, boolean use_anycasting, RspFilter filter)` Deprecated.
    `RspList` | `callRemoteMethods(java.util.Vector<Address> dests, java.lang.String method_name, java.lang.Object[] args, java.lang.String[] signature, int mode, long timeout)` Deprecated.
    `RspList` | `callRemoteMethods(java.util.Vector<Address> dests, java.lang.String method_name, java.lang.Object[] args, java.lang.String[] signature, int mode, long timeout, boolean use_anycasting)` Deprecated.
    `NotifyingFuture<RspList>` | `callRemoteMethodsWithFuture(java.util.Collection<Address> dests, MethodCall method_call, RequestOptions options)`
    `NotifyingFuture<RspList>` | `callRemoteMethodsWithFuture(java.util.Vector<Address> dests, MethodCall method_call)` Deprecated.
    `NotifyingFuture<RspList>` | `callRemoteMethodsWithFuture(java.util.Vector<Address> dests, MethodCall method_call, int mode, long timeout, boolean use_anycasting, boolean oob, RspFilter filter)` Deprecated.
    `<T> NotifyingFuture<T>` | `callRemoteMethodWithFuture(Address dest, MethodCall call)` Deprecated.
    `<T> NotifyingFuture<T>` | `callRemoteMethodWithFuture(Address dest, MethodCall method_call, int mode, long timeout, boolean oob)` Deprecated.
    `<T> NotifyingFuture<T>` | `callRemoteMethodWithFuture(Address dest, MethodCall call, RequestOptions options)`
    `void` | `channelClosed(Channel channel)`
    `void` | `channelConnected(Channel channel)`
    `void` | `channelDisconnected(Channel channel)`
    `void` | `channelReconnected(Address new_addr)`
    `void` | `channelShunned()`
    `protected void` | `correlatorStarted()`
    `RpcDispatcher.Marshaller` | `getMarshaller()`
    `MethodLookup` | `getMethodLookup()`
    `static java.lang.String` | `getName()`
    `RpcDispatcher.Marshaller` | `getRequestMarshaller()`
    `RpcDispatcher.Marshaller` | `getResponseMarshaller()`
    `java.lang.Object` | `getServerObject()`
    `java.lang.Object` | `handle(Message req)` Message contains MethodCall.
    `boolean` | `removeChannelListener(ChannelListener l)`
    `void` | `setMarshaller(RpcDispatcher.Marshaller m)`
    `void` | `setMethodLookup(MethodLookup method_lookup)`
    `void` | `setRequestMarshaller(RpcDispatcher.Marshaller m)`
    `void` | `setResponseMarshaller(RpcDispatcher.Marshaller m)`
    `void` | `setServerObject(java.lang.Object server_obj)`

    - ### Methods inherited from class org.jgroups.blocks.MessageDispatcher

      `cast, castMessage, castMessage, castMessage, castMessage, castMessageWithFuture, castMessageWithFuture, createRequestCorrelator, done, getChannel, getConcurrentProcessing, getDeadlockDetection, getMembers, getMessageListener, getProtocolAdapter, installUpHandler, send, sendMessage, sendMessage, sendMessageWithFuture, sendMessageWithFuture, setChannel, setConcurrentProcessing, setDeadlockDetection, setMembershipListener, setMessageListener, setRequestHandler, start, stop`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### server_obj

          protected java.lang.Object server_obj

    - #### req_marshaller

          protected RpcDispatcher.Marshaller2 req_marshaller

      Marshaller to marshall requests at the caller and unmarshal requests at the receiver(s)

    - #### rsp_marshaller

          protected RpcDispatcher.Marshaller2 rsp_marshaller

      Marshaller to marshal responses at the receiver(s) and unmarshal responses at the caller

    - #### additionalChannelListeners

          protected final java.util.List<ChannelListener> additionalChannelListeners

    - #### method_lookup

          protected MethodLookup method_lookup

  - ### Constructor Detail

    - #### RpcDispatcher

          public RpcDispatcher()

    - #### RpcDispatcher

          public RpcDispatcher(Channel channel,
                       MessageListener l,
                       MembershipListener l2,
                       java.lang.Object server_obj)

    - #### RpcDispatcher

          @Deprecated
          public RpcDispatcher(Channel channel,
                                  MessageListener l,
                                  MembershipListener l2,
                                  java.lang.Object server_obj,
                                  boolean deadlock_detection)

      Deprecated.

    - #### RpcDispatcher

          @Deprecated
          public RpcDispatcher(Channel channel,
                                  MessageListener l,
                                  MembershipListener l2,
                                  java.lang.Object server_obj,
                                  boolean deadlock_detection,
                                  boolean concurrent_processing)

      Deprecated.

    - #### RpcDispatcher

          @Deprecated
          public RpcDispatcher(PullPushAdapter adapter,
                                  java.io.Serializable id,
                                  MessageListener l,
                                  MembershipListener l2,
                                  java.lang.Object server_obj)

      Deprecated.

  - ### Method Detail

    - #### getName

          public static java.lang.String getName()

    - #### getRequestMarshaller

          public RpcDispatcher.Marshaller getRequestMarshaller()

    - #### setRequestMarshaller

          public void setRequestMarshaller(RpcDispatcher.Marshaller m)

    - #### getResponseMarshaller

          public RpcDispatcher.Marshaller getResponseMarshaller()

    - #### setResponseMarshaller

          public void setResponseMarshaller(RpcDispatcher.Marshaller m)

    - #### getMarshaller

          public RpcDispatcher.Marshaller getMarshaller()

    - #### setMarshaller

          public void setMarshaller(RpcDispatcher.Marshaller m)

    - #### getServerObject

          public java.lang.Object getServerObject()

    - #### setServerObject

          public void setServerObject(java.lang.Object server_obj)

    - #### getMethodLookup

          public MethodLookup getMethodLookup()

    - #### setMethodLookup

          public void setMethodLookup(MethodLookup method_lookup)

    - #### callRemoteMethods

          @Deprecated
          public RspList callRemoteMethods(java.util.Vector<Address> dests,
                                             java.lang.String method_name,
                                             java.lang.Object[] args,
                                             java.lang.Class[] types,
                                             int mode,
                                             long timeout)

      Deprecated.

    - #### callRemoteMethods

          @Deprecated
          public RspList callRemoteMethods(java.util.Vector<Address> dests,
                                             java.lang.String method_name,
                                             java.lang.Object[] args,
                                             java.lang.Class[] types,
                                             int mode,
                                             long timeout,
                                             boolean use_anycasting)

      Deprecated.

    - #### callRemoteMethods

          @Deprecated
          public RspList callRemoteMethods(java.util.Vector<Address> dests,
                                             java.lang.String method_name,
                                             java.lang.Object[] args,
                                             java.lang.Class[] types,
                                             int mode,
                                             long timeout,
                                             boolean use_anycasting,
                                             RspFilter filter)

      Deprecated.

    - #### callRemoteMethods

          public RspList callRemoteMethods(java.util.Collection<Address> dests,
                                  java.lang.String method_name,
                                  java.lang.Object[] args,
                                  java.lang.Class[] types,
                                  RequestOptions options)

    - #### callRemoteMethods

          @Deprecated
          public RspList callRemoteMethods(java.util.Vector<Address> dests,
                                             java.lang.String method_name,
                                             java.lang.Object[] args,
                                             java.lang.String[] signature,
                                             int mode,
                                             long timeout)

      Deprecated.

    - #### callRemoteMethods

          @Deprecated
          public RspList callRemoteMethods(java.util.Vector<Address> dests,
                                             java.lang.String method_name,
                                             java.lang.Object[] args,
                                             java.lang.String[] signature,
                                             int mode,
                                             long timeout,
                                             boolean use_anycasting)

      Deprecated.

    - #### callRemoteMethods

          @Deprecated
          public RspList callRemoteMethods(java.util.Vector<Address> dests,
                                             MethodCall method_call,
                                             int mode,
                                             long timeout)

      Deprecated.

    - #### callRemoteMethods

          public RspList callRemoteMethods(java.util.Collection<Address> dests,
                                  MethodCall method_call,
                                  RequestOptions options)

      Invokes a method in all members contained in dests (or all members if dests is null).
      Parameters:
        `dests` - A list of addresses. If null, the method will be invoked on all cluster members
        `method_call` - The method (plus args) to be invoked
        `options` - A collection of call options, e.g. sync versus async, timeout etc
      Returns:
        RspList A list of return values and flags (suspected, not received) per member
      Since:
        2.9

    - #### callRemoteMethodsWithFuture

          @Deprecated
          public NotifyingFuture<RspList> callRemoteMethodsWithFuture(java.util.Vector<Address> dests,
                                                                        MethodCall method_call,
                                                                        int mode,
                                                                        long timeout,
                                                                        boolean use_anycasting,
                                                                        boolean oob,
                                                                        RspFilter filter)

      Deprecated.

    - #### callRemoteMethodsWithFuture

          @Deprecated
          public NotifyingFuture<RspList> callRemoteMethodsWithFuture(java.util.Vector<Address> dests,
                                                                        MethodCall method_call)

      Deprecated.

    - #### callRemoteMethodsWithFuture

          public NotifyingFuture<RspList> callRemoteMethodsWithFuture(java.util.Collection<Address> dests,
                                                             MethodCall method_call,
                                                             RequestOptions options)

    - #### callRemoteMethod

          @Deprecated
          public java.lang.Object callRemoteMethod(Address dest,
                                                     java.lang.String method_name,
                                                     java.lang.Object[] args,
                                                     java.lang.Class[] types,
                                                     int mode,
                                                     long timeout)
                                            throws java.lang.Throwable

      Deprecated.
      Throws:
        `java.lang.Throwable`

    - #### callRemoteMethod

          public java.lang.Object callRemoteMethod(Address dest,
                                          java.lang.String method_name,
                                          java.lang.Object[] args,
                                          java.lang.Class[] types,
                                          RequestOptions options)
                                            throws java.lang.Throwable

      Throws:
        `java.lang.Throwable`

    - #### callRemoteMethod

          @Deprecated
          public java.lang.Object callRemoteMethod(Address dest,
                                                     java.lang.String method_name,
                                                     java.lang.Object[] args,
                                                     java.lang.String[] signature,
                                                     int mode,
                                                     long timeout)
                                            throws java.lang.Throwable

      Deprecated.
      Throws:
        `java.lang.Throwable`

    - #### callRemoteMethod

          @Deprecated
          public java.lang.Object callRemoteMethod(Address dest,
                                                     MethodCall method_call,
                                                     int mode,
                                                     long timeout)
                                            throws java.lang.Throwable

      Deprecated.
      Throws:
        `java.lang.Throwable`

    - #### callRemoteMethod

          @Deprecated
          public java.lang.Object callRemoteMethod(Address dest,
                                                     MethodCall method_call,
                                                     int mode,
                                                     long timeout,
                                                     boolean oob)
                                            throws java.lang.Throwable

      Deprecated.
      Throws:
        `java.lang.Throwable`

    - #### callRemoteMethod

          @Deprecated
          public java.lang.Object callRemoteMethod(Address dest,
                                                     MethodCall call)
                                            throws java.lang.Throwable

      Deprecated.
      Throws:
        `java.lang.Throwable`

    - #### callRemoteMethod

          public java.lang.Object callRemoteMethod(Address dest,
                                          MethodCall call,
                                          RequestOptions options)
                                            throws java.lang.Throwable

      Throws:
        `java.lang.Throwable`

    - #### callRemoteMethodWithFuture

          @Deprecated
          public <T> NotifyingFuture<T> callRemoteMethodWithFuture(Address dest,
                                                                     MethodCall method_call,
                                                                     int mode,
                                                                     long timeout,
                                                                     boolean oob)
                                                        throws java.lang.Throwable

      Deprecated.
      Throws:
        `java.lang.Throwable`

    - #### callRemoteMethodWithFuture

          @Deprecated
          public <T> NotifyingFuture<T> callRemoteMethodWithFuture(Address dest,
                                                                     MethodCall call)
                                                        throws java.lang.Throwable

      Deprecated.
      Throws:
        `java.lang.Throwable`

    - #### callRemoteMethodWithFuture

          public <T> NotifyingFuture<T> callRemoteMethodWithFuture(Address dest,
                                                          MethodCall call,
                                                          RequestOptions options)
                                                        throws java.lang.Throwable

      Throws:
        `java.lang.Throwable`

    - #### correlatorStarted

          protected void correlatorStarted()

      Overrides:
        `correlatorStarted` in class `MessageDispatcher`

    - #### handle

          public java.lang.Object handle(Message req)

      Message contains MethodCall. Execute it against *this* object and return result. Use MethodCall.invoke() to do this. Return result.
      Specified by:
        `handle` in interface `RequestHandler`
      Overrides:
        `handle` in class `MessageDispatcher`

    - #### addChannelListener

          public boolean addChannelListener(ChannelListener l)

      Add a new channel listener to be notified on the channel's state change.
      Returns:
        true if the listener was added or false if the listener was already in the list.

    - #### removeChannelListener

          public boolean removeChannelListener(ChannelListener l)

      Returns:
        true if the channel was removed indeed.

    - #### channelConnected

          public void channelConnected(Channel channel)

      Specified by:
        `channelConnected` in interface `ChannelListener`

    - #### channelDisconnected

          public void channelDisconnected(Channel channel)

      Specified by:
        `channelDisconnected` in interface `ChannelListener`

    - #### channelClosed

          public void channelClosed(Channel channel)

      Specified by:
        `channelClosed` in interface `ChannelListener`

    - #### channelShunned

          public void channelShunned()

      Specified by:
        `channelShunned` in interface `ChannelListener`

    - #### channelReconnected

          public void channelReconnected(Address new_addr)

      Specified by:
        `channelReconnected` in interface `ChannelListener`

Copyright © 1998-2009 Bela Ban / Red Hat. All Rights Reserved.