|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jgroups.stack.Protocol
org.jgroups.stack.MessageProtocol
public abstract class MessageProtocol
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.
Field Summary | |
---|---|
protected RequestCorrelator |
_corr
|
protected java.util.Vector |
members
|
Fields inherited from class org.jgroups.stack.Protocol |
---|
down_handler, down_prot, down_queue, down_thread, down_thread_prio, log, observer, props, stack, stats, up_handler, up_prot, up_queue, up_thread, up_thread_prio |
Constructor Summary | |
---|---|
MessageProtocol()
|
Method Summary | |
---|---|
RspList |
castMessage(java.util.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. |
java.lang.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. |
java.lang.Object |
sendMessage(Message msg,
int mode,
long timeout)
Sends a message to a single member (destination = msg.dest) and returns the response. |
void |
start()
This method is called on a Channel.connect(String) . |
void |
stop()
This method is called on a Channel.disconnect() . |
void |
up(Event evt)
Handle an event coming from the layer above |
protected void |
updateView(View new_view)
|
Methods inherited from class org.jgroups.stack.Protocol |
---|
destroy, downThreadEnabled, dumpStats, enableStats, getDownProtocol, getDownQueue, getName, getProperties, getUpProtocol, getUpQueue, handleSpecialDownEvent, init, passDown, passUp, printStats, providedDownServices, providedUpServices, receiveDownEvent, receiveUpEvent, requiredDownServices, requiredUpServices, resetStats, setDownProtocol, setObserver, setProperties, setPropertiesInternal, setProtocolStack, setUpProtocol, startDownHandler, startUpHandler, statsEnabled, stopInternal, upThreadEnabled |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected RequestCorrelator _corr
protected final java.util.Vector members
Constructor Detail |
---|
public MessageProtocol()
Method Detail |
---|
public void start() throws java.lang.Exception
Protocol
Channel.connect(String)
. Starts work.
Protocols are connected and queues are ready to receive events.
Will be called from bottom to top. This call will replace
the START and START_OK events.
start
in class Protocol
java.lang.Exception
- Thrown if protocol cannot be started successfully. This will cause the ProtocolStack
to fail, so Channel.connect(String)
will throw an exceptionpublic void stop()
Protocol
Channel.disconnect()
. Stops work (e.g. by closing multicast socket).
Will be called from top to bottom. This means that at the time of the method invocation the
neighbor protocol below is still working. This method will replace the
STOP, STOP_OK, CLEANUP and CLEANUP_OK events. The ProtocolStack guarantees that
when this method is called all messages in the down queue will have been flushed
stop
in class Protocol
public RspList castMessage(java.util.Vector dests, Message msg, int mode, long timeout)
mode
responses. The responses are
returned in a response list, where each response is associated with its sender.
Uses GroupRequest
.
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 membersmode
- Defined in GroupRequest
. The number of responses to wait for:
timeout
- If 0: wait forever. Otherwise, wait for mode
responses
or timeout time.
Object
and associated
to its sender.public java.lang.Object sendMessage(Message msg, int mode, long timeout) throws TimeoutException, SuspectedException
TimeoutException
SuspectedException
public java.lang.Object handle(Message req)
handle
in interface RequestHandler
public final void up(Event evt)
up
in class Protocol
public final void down(Event evt)
down
in class Protocol
protected void updateView(View new_view)
protected boolean handleUpEvent(Event evt)
protected boolean handleDownEvent(Event evt)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |