Class GroupRequest
- All Implemented Interfaces:
Future,RspCollector,Command,NotifyingFuture
The supported transport to send requests is currently either a RequestCorrelator or a generic Transport. One of them has to be given in the constructor. It will then be used to send a request. When a message is received by either one, the receiveResponse() of this class has to be called (this class does not actively receive requests/responses itself). Also, when a view change or suspicion is received, the methods viewChange() or suspect() of this class have to be called.
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. acknowledgment-based message confirmation.
- Author:
- Bela Ban
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.concurrent.Future
Future.State -
Field Summary
Fields inherited from class org.jgroups.blocks.Request
block_for_results, completed, corr, done, GET_ABS_MAJORITY, GET_ALL, GET_FIRST, GET_MAJORITY, GET_N, GET_NONE, listener, lock, log, options, req_id, REQUEST_ID, request_msg, transport -
Constructor Summary
ConstructorsConstructorDescriptionGroupRequest(Message msg, RequestCorrelator corr, Collection<Address> targets, RequestOptions options) GroupRequest(Message m, RequestCorrelator corr, Address target, RequestOptions options) GroupRequest(Message m, Transport transport, Collection<Address> mbrs, RequestOptions options) -
Method Summary
Modifier and TypeMethodDescriptionget()booleanReturns the results as a RspListvoidreceiveResponse(Object response_value, Address sender) Callback (called by RequestCorrelator or Transport).protected booleanvoidvoidsetAnycasting(boolean anycasting) voidCallback (called by RequestCorrelator or Transport).toString()voidviewChange(View new_view) Any member of 'membership' that is not in the new view is flagged as SUSPECTED.Methods inherited from class org.jgroups.blocks.Request
cancel, checkCompletion, execute, getBlockForResults, getRequestId, getResponsesComplete, isCancelled, isDone, modeToString, responsesComplete, setBlockForResults, setListener, setResponseFilter, waitForResultsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.concurrent.Future
exceptionNow, resultNow, state
-
Constructor Details
-
GroupRequest
public GroupRequest(Message msg, RequestCorrelator corr, Collection<Address> targets, RequestOptions options) - Parameters:
msg- The message to be sentcorr- 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 reasonGroupRequestuses it instead of aTransportis that multiple requests/responses might be sent/received concurrentlytargets- The targets, which are supposed to receive the message. Any receiver not in this set will discard the message. Targets are always a subset of the current membershipoptions- The request options to be used for this call
-
GroupRequest
-
GroupRequest
public GroupRequest(Message m, Transport transport, Collection<Address> mbrs, RequestOptions options)
-
-
Method Details
-
getAnycasting
public boolean getAnycasting() -
setAnycasting
public void setAnycasting(boolean anycasting) -
sendRequest
- Specified by:
sendRequestin classRequest- Throws:
Exception
-
receiveResponse
Callback (called by RequestCorrelator or Transport). Adds a response to the response table. When all responses have been received,execute()returns.- Specified by:
receiveResponsein interfaceRspCollector- Specified by:
receiveResponsein classRequest
-
suspect
Callback (called by RequestCorrelator or Transport). Report toGroupRequestthat 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.- Specified by:
suspectin interfaceRspCollector- Specified by:
suspectin classRequest
-
viewChange
Any member of 'membership' that is not in the new view is flagged as SUSPECTED. Any member in the new view that is not in the membership (ie, the set of responses expected for the current RPC) will not be added to it. If we did this we might run into the following problem:- Membership is {A,B}
- A sends a synchronous group RPC (which sleeps for 60 secs in the invocation handler)
- C joins while A waits for responses from A and B
- If this would generate a new view {A,B,C} and if this expanded the response set to {A,B,C}, A would wait forever on C's response because C never received the request in the first place, therefore won't send a response.
- Specified by:
viewChangein interfaceRspCollector- Specified by:
viewChangein classRequest
-
getResults
Returns the results as a RspList -
get
-
get
public RspList get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException -
toString
-
responsesComplete
protected boolean responsesComplete()- Specified by:
responsesCompletein classRequest
-