Package org.jgroups.blocks
Class RpcDispatcher
java.lang.Object
org.jgroups.blocks.MessageDispatcher
org.jgroups.blocks.RpcDispatcher
- All Implemented Interfaces:
RequestHandler
,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 ClassesModifier and TypeClassDescriptionstatic interface
static interface
static class
Used to provide a Marshaller2 interface to a Marshaller. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final List
protected MethodLookup
protected RpcDispatcher.Marshaller2
Marshaller to marshall requests at the caller and unmarshal requests at the receiver(s)protected RpcDispatcher.Marshaller2
Marshaller to marshal responses at the receiver(s) and unmarshal responses at the callerprotected Object
Fields inherited from class org.jgroups.blocks.MessageDispatcher
adapter, channel, concurrent_processing, corr, deadlock_detection, handler, id, local_addr, log, members, membership_listener, msg_listener, prot_adapter, req_handler, transport_adapter
-
Constructor Summary
ConstructorsConstructorDescriptionRpcDispatcher
(PullPushAdapter adapter, Serializable id, MessageListener l, MembershipListener l2, Object server_obj) RpcDispatcher
(Channel channel, MessageListener l, MembershipListener l2, Object server_obj) RpcDispatcher
(Channel channel, MessageListener l, MembershipListener l2, Object server_obj, boolean deadlock_detection) RpcDispatcher
(Channel channel, MessageListener l, MembershipListener l2, Object server_obj, boolean deadlock_detection, boolean concurrent_processing) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Add a new channel listener to be notified on the channel's state change.callRemoteMethod
(Address dest, String method_name, Object[] args, Class[] types, int mode, long timeout) callRemoteMethod
(Address dest, String method_name, Object[] args, String[] signature, int mode, long timeout) callRemoteMethod
(Address dest, MethodCall method_call, int mode, long timeout) callRemoteMethod
(Address dest, MethodCall method_call, int mode, long timeout, boolean oob) callRemoteMethods
(Vector dests, String method_name, Object[] args, Class[] types, int mode, long timeout) callRemoteMethods
(Vector dests, String method_name, Object[] args, Class[] types, int mode, long timeout, boolean use_anycasting) callRemoteMethods
(Vector dests, String method_name, Object[] args, Class[] types, int mode, long timeout, boolean use_anycasting, RspFilter filter) callRemoteMethods
(Vector dests, String method_name, Object[] args, String[] signature, int mode, long timeout) callRemoteMethods
(Vector dests, String method_name, Object[] args, String[] signature, int mode, long timeout, boolean use_anycasting) callRemoteMethods
(Vector dests, MethodCall method_call, int mode, long timeout) callRemoteMethods
(Vector dests, MethodCall method_call, int mode, long timeout, boolean use_anycasting) callRemoteMethods
(Vector dests, MethodCall method_call, int mode, long timeout, boolean use_anycasting, boolean oob) callRemoteMethods
(Vector dests, MethodCall method_call, int mode, long timeout, boolean use_anycasting, boolean oob, RspFilter filter) castMessage
(Vector dests, Message msg, int mode, long timeout) void
channelClosed
(Channel channel) void
channelConnected
(Channel channel) void
channelDisconnected
(Channel channel) void
channelReconnected
(Address new_addr) void
protected void
getName()
Message contains MethodCall.boolean
sendMessage
(Message msg, int mode, long timeout) Sends a message to a single member (destination = msg.dest) and returns the response.void
void
setMethodLookup
(MethodLookup method_lookup) void
void
void
setServerObject
(Object server_obj) Methods inherited from class org.jgroups.blocks.MessageDispatcher
castMessage, castMessage, castMessage, done, getChannel, getConcurrentProcessing, getDeadlockDetection, getMembers, getMessageListener, send, setChannel, setConcurrentProcessing, setDeadlockDetection, setMembershipListener, setMessageListener, setRequestHandler, start, stop
-
Field Details
-
server_obj
-
req_marshaller
Marshaller to marshall requests at the caller and unmarshal requests at the receiver(s) -
rsp_marshaller
Marshaller to marshal responses at the receiver(s) and unmarshal responses at the caller -
additionalChannelListeners
-
method_lookup
-
-
Constructor Details
-
RpcDispatcher
public RpcDispatcher() -
RpcDispatcher
-
RpcDispatcher
public RpcDispatcher(Channel channel, MessageListener l, MembershipListener l2, Object server_obj, boolean deadlock_detection) -
RpcDispatcher
public RpcDispatcher(Channel channel, MessageListener l, MembershipListener l2, Object server_obj, boolean deadlock_detection, boolean concurrent_processing) -
RpcDispatcher
public RpcDispatcher(PullPushAdapter adapter, Serializable id, MessageListener l, MembershipListener l2, Object server_obj)
-
-
Method Details
-
getName
-
getRequestMarshaller
-
setRequestMarshaller
-
getResponseMarshaller
-
setResponseMarshaller
-
getMarshaller
-
setMarshaller
-
getServerObject
-
setServerObject
-
getMethodLookup
-
setMethodLookup
-
castMessage
- Overrides:
castMessage
in classMessageDispatcher
-
sendMessage
public 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 classMessageDispatcher
- Throws:
TimeoutException
SuspectedException
-
callRemoteMethods
-
callRemoteMethods
-
callRemoteMethods
-
callRemoteMethods
-
callRemoteMethods
-
callRemoteMethods
-
callRemoteMethods
public RspList callRemoteMethods(Vector dests, MethodCall method_call, int mode, long timeout, boolean use_anycasting) -
callRemoteMethods
public RspList callRemoteMethods(Vector dests, MethodCall method_call, int mode, long timeout, boolean use_anycasting, boolean oob) -
callRemoteMethods
public RspList callRemoteMethods(Vector dests, MethodCall method_call, int mode, long timeout, boolean use_anycasting, boolean oob, RspFilter filter) -
callRemoteMethod
public Object callRemoteMethod(Address dest, String method_name, Object[] args, Class[] types, int mode, long timeout) throws Throwable - Throws:
Throwable
-
callRemoteMethod
public Object callRemoteMethod(Address dest, String method_name, Object[] args, String[] signature, int mode, long timeout) throws Throwable - Throws:
Throwable
-
callRemoteMethod
public Object callRemoteMethod(Address dest, MethodCall method_call, int mode, long timeout) throws Throwable - Throws:
Throwable
-
callRemoteMethod
public Object callRemoteMethod(Address dest, MethodCall method_call, int mode, long timeout, boolean oob) throws Throwable - Throws:
Throwable
-
correlatorStarted
protected void correlatorStarted()- Overrides:
correlatorStarted
in classMessageDispatcher
-
handle
Message contains MethodCall. Execute it against *this* object and return result. Use MethodCall.invoke() to do this. Return result.- Specified by:
handle
in interfaceRequestHandler
- Overrides:
handle
in classMessageDispatcher
-
addChannelListener
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
- Returns:
- true if the channel was removed indeed.
-
channelConnected
- Specified by:
channelConnected
in interfaceChannelListener
-
channelDisconnected
- Specified by:
channelDisconnected
in interfaceChannelListener
-
channelClosed
- Specified by:
channelClosed
in interfaceChannelListener
-
channelShunned
public void channelShunned()- Specified by:
channelShunned
in interfaceChannelListener
-
channelReconnected
- Specified by:
channelReconnected
in interfaceChannelListener
-