public class GroupRequest<T> extends Request
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.
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<Address,Rsp<T>> |
requests
Correlates requests and responses
|
Constructor and Description |
---|
GroupRequest(RequestCorrelator corr,
java.util.Collection<Address> targets,
RequestOptions options) |
Modifier and Type | Method and Description |
---|---|
RspList<T> |
get() |
RspList<T> |
get(long timeout,
java.util.concurrent.TimeUnit unit) |
RspList<T> |
getResults()
Returns the results as a RspList
|
void |
receiveResponse(java.lang.Object response_value,
Address sender,
boolean is_exception)
Callback (called by RequestCorrelator or Transport).
|
protected boolean |
responsesComplete() |
void |
sendRequest(Message req) |
void |
siteUnreachable(java.lang.String site) |
void |
suspect(Address suspected_member)
Callback (called by RequestCorrelator or Transport).
|
java.lang.String |
toString() |
void |
transportClosed()
Marks all responses with an exception (unless a response was already marked as done)
|
void |
viewChange(View view)
Any member of 'membership' that is not in the new view is flagged as
SUSPECTED.
|
cancel, checkCompletion, corrDone, execute, getResponsesComplete, isCancelled, isDone, isMet, requestId, requestId, responsesComplete, setListener, setResponseFilter, waitForResults
public GroupRequest(RequestCorrelator corr, java.util.Collection<Address> targets, RequestOptions options)
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 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 callpublic void sendRequest(Message req) throws java.lang.Exception
sendRequest
in class Request
java.lang.Exception
public void receiveResponse(java.lang.Object response_value, Address sender, boolean is_exception)
execute()
returns.receiveResponse
in class Request
public void suspect(Address suspected_member)
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.public void siteUnreachable(java.lang.String site)
siteUnreachable
in class Request
public void viewChange(View view)
viewChange
in class Request
public void transportClosed()
transportClosed
in class Request
public RspList<T> get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
java.lang.InterruptedException
java.util.concurrent.ExecutionException
public RspList<T> get(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
protected boolean responsesComplete()
responsesComplete
in class Request
Copyright © 1998-2020 Red Hat. All Rights Reserved.