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.


Constructor Index

 o MessageDispatcher(Channel, MessageListener, MembershipListener)
 o MessageDispatcher(Channel, MessageListener, MembershipListener, RequestHandler)

Method Index

 o CastMessage(Vector, Message, int, long)
Cast a message to all members, and wait for mode responses.
 o Down(Event)
An event is to be sent down the stack.
 o finalize()
 o GetName()
 o Handle(Message)
 o 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).
 o PassUp(Event)
Called by request correlator when message was not generated by it.
 o Send(Message)
 o SendMessage(Message, int, long)
Sends a message to a single member (destination = msg.dest) and returns the response.
 o SetMembershipListener(MembershipListener)
 o SetMessageListener(MessageListener)
 o SetRequestHandler(RequestHandler)
 o Start()
 o StartDownHandler()
Used internally.
 o StartUpHandler()
Used internally.
 o Stop()
 o StopInternal()
Used internally.
 o Up(Event)
Called by channel (we registered before) when event is received.

Constructors

 o MessageDispatcher
 public MessageDispatcher(Channel channel,
                          MessageListener l,
                          MembershipListener l2)
 o MessageDispatcher
 public MessageDispatcher(Channel channel,
                          MessageListener l,
                          MembershipListener l2,
                          RequestHandler req_handler)

Methods

 o finalize
 public void finalize()
Overrides:
finalize in class Object
 o Start
 public void Start()
 o Stop
 public void Stop()
 o SetMessageListener
 public void SetMessageListener(MessageListener l)
 o SetMembershipListener
 public void SetMembershipListener(MembershipListener l)
 o SetRequestHandler
 public void SetRequestHandler(RequestHandler rh)
 o Send
 public void Send(Message msg) throws ChannelNotConnected, ChannelClosed
 o 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:
  1. GET_FIRST: return the first response received.
  2. GET_ALL: wait for all responses (minus the ones from suspected members)
  3. GET_MAJORITY: wait for a majority of all responses (relative to the grp size)
  4. GET_ABS_MAJORITY: wait for majority (absolute, computed once)
  5. GET_N: wait for n responses (may block if n > group size)
  6. 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.
 o 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 !

 o Handle
 public Object Handle(Message msg)
 o GetName
 public String GetName()
Overrides:
GetName in class Protocol
 o StartUpHandler
 public void StartUpHandler()
Used internally.

Overrides:
StartUpHandler in class Protocol
 o StartDownHandler
 public void StartDownHandler()
Used internally.

Overrides:
StartDownHandler in class Protocol
 o StopInternal
 public void StopInternal()
Used internally.

Overrides:
StopInternal in class Protocol
 o 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
 o 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
 o 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
 o 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