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 interfacestatic interfacestatic classUsed to provide a Marshaller2 interface to a Marshaller. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Listprotected MethodLookupprotected RpcDispatcher.Marshaller2Marshaller to marshall requests at the caller and unmarshal requests at the receiver(s)protected RpcDispatcher.Marshaller2Marshaller to marshal responses at the receiver(s) and unmarshal responses at the callerprotected ObjectFields 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 TypeMethodDescriptionbooleanAdd 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) voidchannelClosed(Channel channel) voidchannelConnected(Channel channel) voidchannelDisconnected(Channel channel) voidchannelReconnected(Address new_addr) voidprotected voidgetName()Message contains MethodCall.booleansendMessage(Message msg, int mode, long timeout) Sends a message to a single member (destination = msg.dest) and returns the response.voidvoidsetMethodLookup(MethodLookup method_lookup) voidvoidvoidsetServerObject(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:
castMessagein classMessageDispatcher
-
sendMessage
public Object sendMessage(Message msg, int mode, long timeout) throws TimeoutException, SuspectedException Description copied from class:MessageDispatcherSends a message to a single member (destination = msg.dest) and returns the response. The message's destination must be non-zero !- Overrides:
sendMessagein classMessageDispatcher- Throws:
TimeoutExceptionSuspectedException
-
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:
correlatorStartedin classMessageDispatcher
-
handle
Message contains MethodCall. Execute it against *this* object and return result. Use MethodCall.invoke() to do this. Return result.- Specified by:
handlein interfaceRequestHandler- Overrides:
handlein 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:
channelConnectedin interfaceChannelListener
-
channelDisconnected
- Specified by:
channelDisconnectedin interfaceChannelListener
-
channelClosed
- Specified by:
channelClosedin interfaceChannelListener
-
channelShunned
public void channelShunned()- Specified by:
channelShunnedin interfaceChannelListener
-
channelReconnected
- Specified by:
channelReconnectedin interfaceChannelListener
-