org.javagroups.blocks
Class RpcDispatcher

java.lang.Object
  |
  +--org.javagroups.blocks.MessageDispatcher
        |
        +--org.javagroups.blocks.RpcDispatcher
All Implemented Interfaces:
ChannelListener, RequestHandler

public class RpcDispatcher
extends MessageDispatcher
implements ChannelListener

Dispatches and receives remote group method calls. Is the equivalent of RpcProtocol on the application rather than protocol level.

Author:
Bela Ban

Field Summary
protected  java.lang.Object server_obj
           
 
Fields inherited from class org.javagroups.blocks.MessageDispatcher
adapter, channel, corr, deadlock_detection, id, local_addr, members, membership_listener, msg_listener, prot_adapter, req_handler, transport_adapter
 
Constructor Summary
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)
           
RpcDispatcher(PullPushAdapter adapter, java.io.Serializable id, MessageListener l, MembershipListener l2, java.lang.Object server_obj)
           
 
Method Summary
 java.lang.Object callRemoteMethod(Address dest, MethodCall method_call, int mode, long timeout)
           
 java.lang.Object callRemoteMethod(Address dest, java.lang.String method_name, int mode, long timeout)
          Deprecated. use callRemoteMethod(Address,MethodCall, int, long);
 java.lang.Object callRemoteMethod(Address dest, java.lang.String method_name, java.lang.Object arg1, int mode, long timeout)
          Deprecated. use callRemoteMethod(Address,MethodCall, int, long);
 java.lang.Object callRemoteMethod(Address dest, java.lang.String method_name, java.lang.Object arg1, java.lang.Object arg2, int mode, long timeout)
          Deprecated. use callRemoteMethod(Address,MethodCall, int, long);
 java.lang.Object callRemoteMethod(Address dest, java.lang.String method_name, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, int mode, long timeout)
          Deprecated. use callRemoteMethod(Address,MethodCall, int, long);
 void callRemoteMethods(java.util.Vector dests, long req_id, MethodCall method_call, RspCollector coll)
          Calls the remote methods in a number of receivers and returns the results asynchronously via the RspCollector interface.
 RspList callRemoteMethods(java.util.Vector dests, MethodCall method_call, int mode, long timeout)
           
 RspList callRemoteMethods(java.util.Vector dests, java.lang.String method_name, int mode, long timeout)
          Deprecated. use callRemoteMethods(Vector,MethodCall, int, long);
 RspList callRemoteMethods(java.util.Vector dests, java.lang.String method_name, java.lang.Object arg1, int mode, long timeout)
          Deprecated. use callRemoteMethods(Vector,MethodCall, int, long);
 RspList callRemoteMethods(java.util.Vector dests, java.lang.String method_name, java.lang.Object arg1, java.lang.Object arg2, int mode, long timeout)
          Deprecated. use callRemoteMethods(Vector,MethodCall, int, long);
 RspList callRemoteMethods(java.util.Vector dests, java.lang.String method_name, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, int mode, long timeout)
          Deprecated. use callRemoteMethods(Vector,MethodCall, int, long);
 RspList castMessage(java.util.Vector dests, Message msg, int mode, long timeout)
          Cast a message to all members, and wait for mode responses.
 void channelClosed(Channel channel)
           
 void channelConnected(Channel channel)
           
 void channelDisconnected(Channel channel)
           
 void channelReconnected(Address new_addr)
           
 void channelShunned()
           
 java.lang.String getName()
           
 java.lang.Object handle(Message req)
          Message contains MethodCall.
 java.lang.Object sendMessage(Message msg, int mode, long timeout)
          Sends a message to a single member (destination = msg.dest) and returns the response.
 
Methods inherited from class org.javagroups.blocks.MessageDispatcher
castMessage, done, finalize, send, setMembershipListener, setMessageListener, setRequestHandler, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

server_obj

protected java.lang.Object server_obj
Constructor Detail

RpcDispatcher

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

RpcDispatcher

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

RpcDispatcher

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

getName

public java.lang.String getName()

castMessage

public RspList castMessage(java.util.Vector dests,
                           Message msg,
                           int mode,
                           long timeout)
Description copied from class: MessageDispatcher
Cast a message to all members, and wait for mode responses. The responses are returned in a response list, where each response is associated with its sender.

Uses GroupRequest.

Overrides:
castMessage in class MessageDispatcher
Following copied from class: org.javagroups.blocks.MessageDispatcher
Parameters:
dests - The members to which then message is to be sent. If it is null, then the message is sent to all members
msg - The message to be sent to n members
mode - Defined in GroupRequest. The number of responses to wait for:
  1. GET_FIRST: return the first response received.
  2. GET_ALL: wait for all responses (minus the ones from suspected members)
  3. GET_MAJORITY: wait for a majority of all responses (relative to the grp size)
  4. GET_ABS_MAJORITY: wait for majority (absolute, computed once)
  5. GET_N: wait for n responses (may block if n > group size)
  6. GET_NONE: wait for no responses, return immediately (non-blocking)
timeout - If 0: wait forever. Otherwise, wait for mode responses or timeout time.
Returns:
RspList A list of responses. Each response is an Object and associated to its sender.

sendMessage

public java.lang.Object sendMessage(Message msg,
                                    int mode,
                                    long timeout)
                             throws TimeoutException,
                                    SuspectedException
Description copied from class: MessageDispatcher
Sends a message to a single member (destination = msg.dest) and returns the response. The message's destination must be non-zero !
Overrides:
sendMessage in class MessageDispatcher

callRemoteMethods

public RspList callRemoteMethods(java.util.Vector dests,
                                 java.lang.String method_name,
                                 int mode,
                                 long timeout)
Deprecated. use callRemoteMethods(Vector,MethodCall, int, long);

See Also:
callRemoteMethod(Address,MethodCall, int, long)

callRemoteMethods

public RspList callRemoteMethods(java.util.Vector dests,
                                 java.lang.String method_name,
                                 java.lang.Object arg1,
                                 int mode,
                                 long timeout)
Deprecated. use callRemoteMethods(Vector,MethodCall, int, long);

See Also:
callRemoteMethod(Address,MethodCall, int, long)

callRemoteMethods

public RspList callRemoteMethods(java.util.Vector dests,
                                 java.lang.String method_name,
                                 java.lang.Object arg1,
                                 java.lang.Object arg2,
                                 int mode,
                                 long timeout)
Deprecated. use callRemoteMethods(Vector,MethodCall, int, long);

See Also:
callRemoteMethod(Address,MethodCall, int, long)

callRemoteMethods

public RspList callRemoteMethods(java.util.Vector dests,
                                 java.lang.String method_name,
                                 java.lang.Object arg1,
                                 java.lang.Object arg2,
                                 java.lang.Object arg3,
                                 int mode,
                                 long timeout)
Deprecated. use callRemoteMethods(Vector,MethodCall, int, long);

See Also:
callRemoteMethod(Address,MethodCall, int, long)

callRemoteMethods

public RspList callRemoteMethods(java.util.Vector dests,
                                 MethodCall method_call,
                                 int mode,
                                 long timeout)

callRemoteMethods

public void callRemoteMethods(java.util.Vector dests,
                              long req_id,
                              MethodCall method_call,
                              RspCollector coll)
Calls the remote methods in a number of receivers and returns the results asynchronously via the RspCollector interface.
Parameters:
dests - The destination membership. All members if null
req_id - The request id. Used to match requests and responses. has to be unique for this process
method_call - The method to be called
coll - The RspCollector to be called when a message arrives

callRemoteMethod

public java.lang.Object callRemoteMethod(Address dest,
                                         java.lang.String method_name,
                                         int mode,
                                         long timeout)
                                  throws TimeoutException,
                                         SuspectedException
Deprecated. use callRemoteMethod(Address,MethodCall, int, long);

See Also:
callRemoteMethod(Address,MethodCall, int, long)

callRemoteMethod

public java.lang.Object callRemoteMethod(Address dest,
                                         java.lang.String method_name,
                                         java.lang.Object arg1,
                                         int mode,
                                         long timeout)
                                  throws TimeoutException,
                                         SuspectedException
Deprecated. use callRemoteMethod(Address,MethodCall, int, long);

See Also:
callRemoteMethod(Address,MethodCall, int, long)

callRemoteMethod

public java.lang.Object callRemoteMethod(Address dest,
                                         java.lang.String method_name,
                                         java.lang.Object arg1,
                                         java.lang.Object arg2,
                                         int mode,
                                         long timeout)
                                  throws TimeoutException,
                                         SuspectedException
Deprecated. use callRemoteMethod(Address,MethodCall, int, long);

See Also:
callRemoteMethod(Address,MethodCall, int, long)

callRemoteMethod

public java.lang.Object callRemoteMethod(Address dest,
                                         java.lang.String method_name,
                                         java.lang.Object arg1,
                                         java.lang.Object arg2,
                                         java.lang.Object arg3,
                                         int mode,
                                         long timeout)
                                  throws TimeoutException,
                                         SuspectedException
Deprecated. use callRemoteMethod(Address,MethodCall, int, long);

See Also:
callRemoteMethod(Address,MethodCall, int, long)

callRemoteMethod

public java.lang.Object callRemoteMethod(Address dest,
                                         MethodCall method_call,
                                         int mode,
                                         long timeout)
                                  throws TimeoutException,
                                         SuspectedException

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.
Overrides:
handle in class MessageDispatcher

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 © 2001,2002 www.javagroups.com . All Rights Reserved.