Package org.jgroups.blocks
Class RpcDispatcher
- java.lang.Object
-
- org.jgroups.blocks.MessageDispatcher
-
- org.jgroups.blocks.RpcDispatcher
-
- All Implemented Interfaces:
RequestHandler,ChannelListener
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 Description static interfaceRpcDispatcher.Marshallerstatic interfaceRpcDispatcher.Marshaller2static classRpcDispatcher.MarshallerAdapterUsed to provide a Marshaller2 interface to a Marshaller.
-
Field Summary
Fields Modifier and Type Field Description protected java.util.ListadditionalChannelListenersprotected MethodLookupmethod_lookupprotected RpcDispatcher.Marshaller2req_marshallerMarshaller to marshall requests at the caller and unmarshal requests at the receiver(s)protected RpcDispatcher.Marshaller2rsp_marshallerMarshaller to marshal responses at the receiver(s) and unmarshal responses at the callerprotected java.lang.Objectserver_obj-
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
Constructors Constructor Description RpcDispatcher()RpcDispatcher(PullPushAdapter adapter, java.io.Serializable id, MessageListener l, MembershipListener l2, java.lang.Object server_obj)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(Channel channel, MessageListener l, MembershipListener l2, java.lang.Object server_obj, boolean deadlock_detection, boolean concurrent_processing)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddChannelListener(ChannelListener l)Add a new channel listener to be notified on the channel's state change.java.lang.ObjectcallRemoteMethod(Address dest, java.lang.String method_name, java.lang.Object[] args, java.lang.Class[] types, int mode, long timeout)java.lang.ObjectcallRemoteMethod(Address dest, java.lang.String method_name, java.lang.Object[] args, java.lang.String[] signature, int mode, long timeout)java.lang.ObjectcallRemoteMethod(Address dest, MethodCall method_call, int mode, long timeout)java.lang.ObjectcallRemoteMethod(Address dest, MethodCall method_call, int mode, long timeout, boolean oob)RspListcallRemoteMethods(java.util.Vector dests, java.lang.String method_name, java.lang.Object[] args, java.lang.Class[] types, int mode, long timeout)RspListcallRemoteMethods(java.util.Vector dests, java.lang.String method_name, java.lang.Object[] args, java.lang.Class[] types, int mode, long timeout, boolean use_anycasting)RspListcallRemoteMethods(java.util.Vector dests, java.lang.String method_name, java.lang.Object[] args, java.lang.Class[] types, int mode, long timeout, boolean use_anycasting, RspFilter filter)RspListcallRemoteMethods(java.util.Vector dests, java.lang.String method_name, java.lang.Object[] args, java.lang.String[] signature, int mode, long timeout)RspListcallRemoteMethods(java.util.Vector dests, java.lang.String method_name, java.lang.Object[] args, java.lang.String[] signature, int mode, long timeout, boolean use_anycasting)RspListcallRemoteMethods(java.util.Vector dests, MethodCall method_call, int mode, long timeout)RspListcallRemoteMethods(java.util.Vector dests, MethodCall method_call, int mode, long timeout, boolean use_anycasting)RspListcallRemoteMethods(java.util.Vector dests, MethodCall method_call, int mode, long timeout, boolean use_anycasting, boolean oob)RspListcallRemoteMethods(java.util.Vector dests, MethodCall method_call, int mode, long timeout, boolean use_anycasting, boolean oob, RspFilter filter)RspListcastMessage(java.util.Vector dests, Message msg, int mode, long timeout)voidchannelClosed(Channel channel)voidchannelConnected(Channel channel)voidchannelDisconnected(Channel channel)voidchannelReconnected(Address new_addr)voidchannelShunned()protected voidcorrelatorStarted()RpcDispatcher.MarshallergetMarshaller()MethodLookupgetMethodLookup()java.lang.StringgetName()RpcDispatcher.MarshallergetRequestMarshaller()RpcDispatcher.MarshallergetResponseMarshaller()java.lang.ObjectgetServerObject()java.lang.Objecthandle(Message req)Message contains MethodCall.booleanremoveChannelListener(ChannelListener l)java.lang.ObjectsendMessage(Message msg, int mode, long timeout)Sends a message to a single member (destination = msg.dest) and returns the response.voidsetMarshaller(RpcDispatcher.Marshaller m)voidsetMethodLookup(MethodLookup method_lookup)voidsetRequestMarshaller(RpcDispatcher.Marshaller m)voidsetResponseMarshaller(RpcDispatcher.Marshaller m)voidsetServerObject(java.lang.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 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 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
public RpcDispatcher(Channel channel, MessageListener l, MembershipListener l2, java.lang.Object server_obj, boolean deadlock_detection)
-
RpcDispatcher
public RpcDispatcher(Channel channel, MessageListener l, MembershipListener l2, java.lang.Object server_obj, boolean deadlock_detection, boolean concurrent_processing)
-
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()
-
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)
-
castMessage
public RspList castMessage(java.util.Vector dests, Message msg, int mode, long timeout)
- Overrides:
castMessagein classMessageDispatcher
-
sendMessage
public java.lang.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
public RspList callRemoteMethods(java.util.Vector dests, java.lang.String method_name, java.lang.Object[] args, java.lang.Class[] types, int mode, long timeout)
-
callRemoteMethods
public RspList callRemoteMethods(java.util.Vector dests, java.lang.String method_name, java.lang.Object[] args, java.lang.Class[] types, int mode, long timeout, boolean use_anycasting)
-
callRemoteMethods
public RspList callRemoteMethods(java.util.Vector dests, java.lang.String method_name, java.lang.Object[] args, java.lang.Class[] types, int mode, long timeout, boolean use_anycasting, RspFilter filter)
-
callRemoteMethods
public RspList callRemoteMethods(java.util.Vector dests, java.lang.String method_name, java.lang.Object[] args, java.lang.String[] signature, int mode, long timeout)
-
callRemoteMethods
public RspList callRemoteMethods(java.util.Vector dests, java.lang.String method_name, java.lang.Object[] args, java.lang.String[] signature, int mode, long timeout, boolean use_anycasting)
-
callRemoteMethods
public RspList callRemoteMethods(java.util.Vector dests, MethodCall method_call, int mode, long timeout)
-
callRemoteMethods
public RspList callRemoteMethods(java.util.Vector dests, MethodCall method_call, int mode, long timeout, boolean use_anycasting)
-
callRemoteMethods
public RspList callRemoteMethods(java.util.Vector dests, MethodCall method_call, int mode, long timeout, boolean use_anycasting, boolean oob)
-
callRemoteMethods
public RspList callRemoteMethods(java.util.Vector dests, MethodCall method_call, int mode, long timeout, boolean use_anycasting, boolean oob, RspFilter filter)
-
callRemoteMethod
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
- Throws:
java.lang.Throwable
-
callRemoteMethod
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
- Throws:
java.lang.Throwable
-
callRemoteMethod
public java.lang.Object callRemoteMethod(Address dest, MethodCall method_call, int mode, long timeout) throws java.lang.Throwable
- Throws:
java.lang.Throwable
-
callRemoteMethod
public java.lang.Object callRemoteMethod(Address dest, MethodCall method_call, int mode, long timeout, boolean oob) throws java.lang.Throwable
- Throws:
java.lang.Throwable
-
correlatorStarted
protected void correlatorStarted()
- Overrides:
correlatorStartedin classMessageDispatcher
-
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:
handlein interfaceRequestHandler- Overrides:
handlein classMessageDispatcher
-
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:
channelConnectedin interfaceChannelListener
-
channelDisconnected
public void channelDisconnected(Channel channel)
- Specified by:
channelDisconnectedin interfaceChannelListener
-
channelClosed
public void channelClosed(Channel channel)
- Specified by:
channelClosedin interfaceChannelListener
-
channelShunned
public void channelShunned()
- Specified by:
channelShunnedin interfaceChannelListener
-
channelReconnected
public void channelReconnected(Address new_addr)
- Specified by:
channelReconnectedin interfaceChannelListener
-
-