All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class JavaGroups.Algorithms.GroupRequest

java.lang.Object
   |
   +----JavaGroups.Algorithms.GroupRequest

public class GroupRequest
extends Object
implements RspCollector, Command
Sends a message to all members of the group and waits for all responses (or timeout). Returns a boolean value (success or failure). Results (if any) can be retrieved when done.

When started an array of responses, correlating to the membership, is created. Each response is added to the corresponding field in the array. When all fields have been set, the algorithm terminates. This algorithm can optionally use a suspicion service (failure detector) to detect (and exclude from the membership) fauly members. If no suspicion service is available, timeouts can be used instead (see Execute). When done, a list of suspected members can be retrieved.

Because a channel might deliver requests, and responses to different requests, the GroupRequest class cannot itself receive and process requests/responses from the channel. A mechanism outside this class has to do this; it has to determine what the responses are for the message sent by the Execute method and call ReceiveResponse to do so.

Requirements: lossless delivery, e.g. acknowledgement-based message confirmation.


Variable Index

 o GET_ABS_MAJORITY
 o GET_ALL
 o GET_FIRST
 o GET_MAJORITY
 o GET_N
 o GET_NONE

Constructor Index

 o GroupRequest(Message, RequestCorrelator, Vector, Vector, int)
 o GroupRequest(Message, RequestCorrelator, Vector, Vector, int, long, int)

Method Index

 o Execute()
Sends the message.
 o GetResults()
Returns the results as an array of size membership.length.
 o GetSuspects()
 o IsDone()
 o ReceiveResponse(Message)
Callback (called by RequestCorrelator).
 o Suspect(Object)
Callback (called by RequestCorrelator).

Variables

 o GET_FIRST
 public static final int GET_FIRST
 o GET_ALL
 public static final int GET_ALL
 o GET_MAJORITY
 public static final int GET_MAJORITY
 o GET_ABS_MAJORITY
 public static final int GET_ABS_MAJORITY
 o GET_N
 public static final int GET_N
 o GET_NONE
 public static final int GET_NONE

Constructors

 o GroupRequest
 public GroupRequest(Message m,
                     RequestCorrelator corr,
                     Vector members,
                     Vector suspects,
                     int rsp_mode)
Parameters:
m - The message to be sent
corr - The request correlator to be used. A request correlator sends requests tagged with a unique ID and notifies the sender when matching responses are received. The reason GroupRequest uses it instead of a Transport is that multiple requests/responses might be sent/received concurrently.
members - The initial membership. This value must not be changed during the execution of the group request (so if it was received by means of a view change, its value might need to be copied before supplying it as argument).
suspects - A list of suspected members. When responses are expected, the fact that no responses from members in this list will be received, is accounted for (does not block indefinitely). The execution may add members that are suspected to this list.
rsp_mode - How many responses are expected. Can be
  1. GET_ALL: wait for all responses from non-suspected members. A suspicion service might warn us when a member from which a response is outstanding has crashed, so it can be excluded from the responses. If no suspision service is available, a timeout can be used (a value of 0 means wait forever). If a timeout of 0 is used, no suspicion service is available and a member from which we expect a response has crashed, this methods blocks forever !.
  2. GET_FIRST: wait for the first available response.
  3. GET_MAJORITY: wait for the majority of all responses. The majority is re-computed when a member is suspected.
  4. GET_ABS_MAJORITY: wait for the majority of all members. This includes failed members, so it may block if no timeout is specified.
  5. GET_N: wait for N members. Return if n is >= membership+suspects.
  6. GET_NONE: don't wait for any response. Essentially send an asynchronous message to the group members.
expected_mbrs - Number of responses expected (used with GET_ALL).
 o GroupRequest
 public GroupRequest(Message m,
                     RequestCorrelator corr,
                     Vector members,
                     Vector suspects,
                     int rsp_mode,
                     long timeout,
                     int expected_mbrs)
Parameters:
timeout - Time to wait for responses (ms). A value of <= 0 means wait indefinitely (e.g. if a suspicion service is available; timeouts are not needed).

Methods

 o Execute
 public synchronized boolean Execute()
Sends the message. Returns when n responses have been received, or when a timeout has occurred. n can be the first response, all responses, or a majority of the responses.

 o ReceiveResponse
 public void ReceiveResponse(Message m)
Callback (called by RequestCorrelator). Adds a response to the response table. When all responses have been received, Execute returns.

 o Suspect
 public void Suspect(Object suspected_member)
Callback (called by RequestCorrelator). Report to GroupRequest that a member is reported as faulty (suspected). This method would probably be called when getting a suspect message from a failure detector (where available). It is used to exclude faulty members from the response list.

 o GetResults
 public Object[] GetResults()
Returns the results as an array of size membership.length. Each value in the array corresponds to a value in the membership array. If no (object) values have been returned, the array contains null values, otherwise it contains real values. If a member was suspected, its slot will also contain a null value.

 o GetSuspects
 public Vector GetSuspects()
 o IsDone
 public boolean IsDone()

All Packages  Class Hierarchy  This Package  Previous  Next  Index