| java.lang.Object org.jgroups.blocks.MessageDispatcher
All known Subclasses: org.jgroups.blocks.RpcDispatcher,
MessageDispatcher | public class MessageDispatcher implements RequestHandler(Code) | | Provides synchronous and asynchronous message sending with request-response
correlation; i.e., matching responses with the original request.
It also offers push-style message reception (by internally using the PullPushAdapter).
Channels are simple patterns to asynchronously send a receive messages.
However, a significant number of communication patterns in group communication
require synchronous communication. For example, a sender would like to send a
message to the group and wait for all responses. Or another application would
like to send a message to the group and wait only until the majority of the
receivers have sent a response, or until a timeout occurred. MessageDispatcher
offers a combination of the above pattern with other patterns.
Used on top of channel to implement group requests. Client's handle()
method is called when request is received. Is the equivalent of RpcProtocol on
the application instead of protocol level.
author: Bela Ban version: $Id: MessageDispatcher.java,v 1.60.2.3 2007/03/08 10:14:45 belaban Exp $ |
Inner Class :class TransportAdapter implements Transport | |
Constructor Summary | |
public | MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2) | public | MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2, boolean deadlock_detection) | public | MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2, boolean deadlock_detection, boolean concurrent_processing) | public | MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2, RequestHandler req_handler) | public | MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2, RequestHandler req_handler, boolean deadlock_detection) | public | MessageDispatcher(Channel channel, MessageListener l, MembershipListener l2, RequestHandler req_handler, boolean deadlock_detection, boolean concurrent_processing) | public | MessageDispatcher(PullPushAdapter adapter, Serializable id, MessageListener l, MembershipListener l2) | public | MessageDispatcher(PullPushAdapter adapter, Serializable id, MessageListener l, MembershipListener l2, RequestHandler req_handler) | public | MessageDispatcher(PullPushAdapter adapter, Serializable id, MessageListener l, MembershipListener l2, RequestHandler req_handler, boolean concurrent_processing) |
Method Summary | |
public RspList | castMessage(Vector dests, Message msg, int mode, long timeout) | public RspList | castMessage(Vector dests, Message msg, int mode, long timeout, boolean use_anycasting) Cast a message to all members, and wait for mode responses. | public void | castMessage(Vector dests, long req_id, Message msg, RspCollector coll) Multicast a message request to all members in dests and receive responses via the RspCollector
interface. | protected void | correlatorStarted() | public void | done(long req_id) | public Channel | getChannel() Offers access to the underlying Channel. | protected Collection | getMembers() | public MessageListener | getMessageListener() Gives access to the currently configured MessageListener. | public Object | handle(Message msg) | public void | send(Message msg) | public Object | sendMessage(Message msg, int mode, long timeout) Sends a message to a single member (destination = msg.dest) and returns the response. | public void | setConcurrentProcessing(boolean flag) | public void | setDeadlockDetection(boolean flag) | final public void | setMembershipListener(MembershipListener l) | final public void | setMessageListener(MessageListener l) | final public void | setRequestHandler(RequestHandler rh) | final public void | start() | public void | stop() |
concurrent_processing | protected boolean concurrent_processing(Code) | | Process items on the queue concurrently (RequestCorrelator). The default is to wait until the processing of an
item has completed before fetching the next item from the queue. Note that setting this to true may destroy the
properties of a protocol stack, e.g total or causal order may not be guaranteed. Set this to true only if you
know what you're doing !
|
deadlock_detection | protected boolean deadlock_detection(Code) | | |
handler | protected PullPushHandler handler(Code) | | |
log | final protected Log log(Code) | | |
prot_adapter | protected ProtocolAdapter prot_adapter(Code) | | |
transport_adapter | protected TransportAdapter transport_adapter(Code) | | |
castMessage | public RspList castMessage(Vector dests, Message msg, int mode, long timeout, boolean use_anycasting)(Code) | | 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 .
Parameters: dests - The members to which the message is to be sent. If it is null, then the message is sent to allmembers Parameters: msg - The message to be sent to n members Parameters: mode - Defined in GroupRequest . The number of responses to wait for: - GET_FIRST:return the first response received.
- GET_ALL: wait for all responses (minus the ones fromsuspected members)
- GET_MAJORITY: wait for a majority of all responses (relative to the grpsize)
- GET_ABS_MAJORITY: wait for majority (absolute, computed once)
- GET_N: wait for nresponses (may block if n > group size)
- GET_NONE: wait for no responses, return immediately(non-blocking)
Parameters: timeout - If 0: wait forever. Otherwise, wait for mode responses or timeout time. RspList A list of responses. Each response is an Object and associated to its sender. |
castMessage | public void castMessage(Vector dests, long req_id, Message msg, RspCollector coll)(Code) | | Multicast a message request to all members in dests and receive responses via the RspCollector
interface. When done receiving the required number of responses, the caller has to call done(req_id) on the
underlyinh RequestCorrelator, so that the resources allocated to that request can be freed.
Parameters: dests - The list of members from which to receive responses. Null means all members Parameters: req_id - The ID of the request. Used by the underlying RequestCorrelator to correlate responses withrequests Parameters: msg - The request to be sent Parameters: coll - The sender needs to provide this interface to collect responses. Call will return immediately ifthis is null |
correlatorStarted | protected void correlatorStarted()(Code) | | |
done | public void done(long req_id)(Code) | | |
getChannel | public Channel getChannel()(Code) | | Offers access to the underlying Channel.
a reference to the underlying Channel. |
getMessageListener | public MessageListener getMessageListener()(Code) | | Gives access to the currently configured MessageListener. Returns null if there is no
configured MessageListener.
|
setConcurrentProcessing | public void setConcurrentProcessing(boolean flag)(Code) | | |
setDeadlockDetection | public void setDeadlockDetection(boolean flag)(Code) | | |
start | final public void start()(Code) | | |
|
|