All Packages Class Hierarchy This Package Previous Next Index
Class JavaGroups.MessageDispatcher
java.lang.Object
|
+----JavaGroups.JavaStack.Protocol
|
+----JavaGroups.MessageDispatcher
- public class MessageDispatcher
- extends Protocol
- implements UpHandler, RequestHandler
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.
-
MessageDispatcher(Channel, MessageListener, MembershipListener)
-
-
MessageDispatcher(Channel, MessageListener, MembershipListener, RequestHandler)
-
-
CastMessage(Vector, Message, int, long)
- Cast a message to all members, and wait for
mode
responses.
-
Down(Event)
- An event is to be sent down the stack.
-
finalize()
-
-
GetName()
-
-
Handle(Message)
-
-
PassDown(Event)
- Causes the event to be forwarded to the next layer down in the hierarchy.Typically called
by the implementation of
Down
(when done).
-
PassUp(Event)
- Called by request correlator when message was not generated by it.
-
Send(Message)
-
-
SendMessage(Message, int, long)
- Sends a message to a single member (destination = msg.dest) and returns the response.
-
SetMembershipListener(MembershipListener)
-
-
SetMessageListener(MessageListener)
-
-
SetRequestHandler(RequestHandler)
-
-
Start()
-
-
StartDownHandler()
- Used internally.
-
StartUpHandler()
- Used internally.
-
Stop()
-
-
StopInternal()
- Used internally.
-
Up(Event)
- Called by channel (we registered before) when event is received.
MessageDispatcher
public MessageDispatcher(Channel channel,
MessageListener l,
MembershipListener l2)
MessageDispatcher
public MessageDispatcher(Channel channel,
MessageListener l,
MembershipListener l2,
RequestHandler req_handler)
finalize
public void finalize()
- Overrides:
- finalize in class Object
Start
public void Start()
Stop
public void Stop()
SetMessageListener
public void SetMessageListener(MessageListener l)
SetMembershipListener
public void SetMembershipListener(MembershipListener l)
SetRequestHandler
public void SetRequestHandler(RequestHandler rh)
Send
public void Send(Message msg) throws ChannelNotConnected, ChannelClosed
CastMessage
public RspList CastMessage(Vector dests,
Message msg,
int mode,
long timeout)
- 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 then message is to be sent. If it is null, then the message
is sent to all members
- msg - The message to be sent to n members
- 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)
- 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.
SendMessage
public Object SendMessage(Message msg,
int mode,
long timeout) throws Timeout, Suspected
- Sends a message to a single member (destination = msg.dest) and returns the response.
The message's destination must be non-zero !
Handle
public Object Handle(Message msg)
GetName
public String GetName()
- Overrides:
- GetName in class Protocol
StartUpHandler
public void StartUpHandler()
- Used internally.
- Overrides:
- StartUpHandler in class Protocol
StartDownHandler
public void StartDownHandler()
- Used internally.
- Overrides:
- StartDownHandler in class Protocol
StopInternal
public void StopInternal()
- Used internally.
- Overrides:
- StopInternal in class Protocol
PassUp
public void PassUp(Event evt)
- Called by request correlator when message was not generated by it. We handle it and call the
message listener's corresponding methods
- Overrides:
- PassUp in class Protocol
PassDown
public void PassDown(Event evt)
- Causes the event to be forwarded to the next layer down in the hierarchy.Typically called
by the implementation of
Down
(when done).
- Overrides:
- PassDown in class Protocol
Up
public void Up(Event evt)
- Called by channel (we registered before) when event is received. This is the UpHandler interface.
- Overrides:
- Up in class Protocol
Down
public void Down(Event evt)
- An event is to be sent down the stack.
- Overrides:
- Down in class Protocol
All Packages Class Hierarchy This Package Previous Next Index