org.jgroups.stack
public abstract class MessageProtocol extends Protocol implements RequestHandler
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.
Field Summary | |
---|---|
protected Vector | members |
protected RequestCorrelator | _corr |
Method Summary | |
---|---|
RspList | castMessage(Vector dests, Message msg, int mode, long timeout)
Cast a message to all members, and wait for mode responses. |
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.
|
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. |
Object | sendMessage(Message msg, int mode, long timeout)
Sends a message to a single member (destination = msg.dest) and returns the response.
|
void | start() |
void | stop() |
void | up(Event evt)
Handle an event coming from the layer above |
protected void | updateView(View new_view) |
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 members
are expected. The request itself is multicast to all members. msg The message to be sent to n members mode Defined in GroupRequest
. The number of responses to wait for:
timeout If 0: wait forever. Otherwise, wait for mode
responses
or timeout time.
Returns: RspList A list of responses. Each response is an Object
and associated
to its sender.