All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class JavaGroups.JavaStack.MessageProtocol

java.lang.Object
   |
   +----JavaGroups.JavaStack.Protocol
           |
           +----JavaGroups.JavaStack.MessageProtocol

public abstract class MessageProtocol
extends Protocol
implements Transport, RequestHandler
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 Messages, 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.


Variable Index

 o ALL
 o FIRST
 o MAJORITY
 o NONE

Constructor Index

 o MessageProtocol()

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 Handle(Message)
Processes a request destined for this layer.
 o Receive(long)
 o Send(Message)
Add header and pass down.
 o SendMessage(Message, int, long)
Sends a message to a single member (destination = msg.dest) and returns the response.
 o Up(Event)
An event was received from the layer below.

Variables

 o FIRST
 public static final int FIRST
 o ALL
 public static final int ALL
 o NONE
 public static final int NONE
 o MAJORITY
 public static final int MAJORITY

Constructors

 o MessageProtocol
 public MessageProtocol()

Methods

 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
msg - The message to be sent to n members
mode - The number of responses to wait for:
  1. FIRST: return when 1 response has been received
  2. ALL: wait for all responses (minus responses from suspected members)
  3. NONE: don't wait for any responses (asynchronous, one-way message send)
  4. MAJORITY: wait for a majority of the members to respond. If a members crashes during the wait, the majority is recomputed.
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 req)
Processes a request destined for this layer. The return value is sent as response.

 o Send
 public void Send(Message msg) throws Exception
Add header and pass down. Only used for sending responses (by RequestCorrelator).

 o Receive
 public Object Receive(long timeout) throws Exception
 o Up
 public final void Up(Event evt)
An event was received from the layer below.

Overrides:
Up in class Protocol
 o Down
 public final 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