| java.lang.Object java.lang.Thread org.jgroups.stack.UpHandler org.jgroups.stack.MessageProtocol
All known Subclasses: org.jgroups.protocols.FLOW_CONTROL, org.jgroups.protocols.MessageProtocolEXAMPLE, org.jgroups.stack.RpcProtocol,
MessageProtocol | abstract public class MessageProtocol extends Protocol implements RequestHandler(Code) | | Based on Protocol, but incorporates RequestCorrelator and GroupRequest: the latter can
be used to mcast messages to all members and receive their reponses.
A protocol based on this template can send messages to all members and receive all, a single,
n, or none responses. Requests directed towards the protocol can be handled by overriding
method Handle .
Requests and responses are in the form of Message s, which would typically need to
contain information pertaining to the request/response, e.g. in the form of objects contained
in the message. To use remote method calls, use RpcProtocol instead.
Typical use of of a MessageProtocol would be when a protocol needs to interact with
its peer protocols at each of the members' protocol stacks. A simple protocol like fragmentation,
which does not need to interact with other instances of fragmentation, may simply subclass
Protocol instead.
author: Bela Ban |
Method Summary | |
public RspList | castMessage(Vector dests, Message msg, int mode, long timeout) Cast a message to all members, and wait for mode responses. | final public void | down(Event evt) This message is not originated by this layer, therefore we can just
pass it down without having to go through the request correlator. | public Object | handle(Message req) Processes a request destined for this layer. | protected boolean | handleDownEvent(Event evt) Handle down event. | protected boolean | handleUpEvent(Event evt) Handle up event. | 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 | start() | public void | stop() | final public void | up(Event evt) | protected void | updateView(View new_view) |
castMessage | public RspList castMessage(Vector dests, Message msg, int mode, long timeout)(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 from which responses are expected. If it is null, replies from all membersare expected. The request itself is multicast to all members. 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 from suspected members)
- GET_MAJORITY: wait for a majority of all responses (relative to the grp size)
- GET_ABS_MAJORITY: wait for majority (absolute, computed once)
- GET_N: wait for n responses (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 responsesor timeout time. RspList A list of responses. Each response is an Object and associatedto its sender. |
down | final public void down(Event evt)(Code) | | This message is not originated by this layer, therefore we can just
pass it down without having to go through the request correlator.
We do this ONLY for messages !
|
handle | public Object handle(Message req)(Code) | | Processes a request destined for this layer. The return value is sent as response.
|
handleDownEvent | protected boolean handleDownEvent(Event evt)(Code) | | Handle down event. Return false if it should not be passed down the stack.
|
handleUpEvent | protected boolean handleUpEvent(Event evt)(Code) | | Handle up event. Return false if it should not be passed up the stack.
|
up | final public void up(Event evt)(Code) | | Handle an event coming from the layer above
|
updateView | protected void updateView(View new_view)(Code) | | |
Fields inherited from org.jgroups.stack.UpHandler | final protected Log log(Code)(Java Doc)
|
|
|