public class GroupRequest<T> extends Request<RspList<T>>
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.
CompletableFuture.AsynchronousCompletionTask
Modifier and Type | Field and Description |
---|---|
protected Lock |
lock |
protected int |
num_received |
protected int |
num_valid |
protected RspList<T> |
rsps
Correlates requests and responses
|
corr, options, req_id, start_time
Constructor and Description |
---|
GroupRequest(RequestCorrelator corr,
Collection<Address> targets,
RequestOptions options) |
Modifier and Type | Method and Description |
---|---|
protected RspList<T> |
doAndComplete(Callable<RspList<T>> supplier) |
RspList<T> |
get() |
RspList<T> |
get(long timeout,
TimeUnit unit) |
RspList<T> |
getNow(RspList<T> valueIfAbsent) |
boolean |
getResponsesComplete() |
RspList<T> |
join() |
void |
receiveResponse(Object response_value,
Address sender,
boolean is_exception)
Callback (called by RequestCorrelator or Transport).
|
protected boolean |
responsesComplete() |
void |
sendRequest(Buffer data) |
protected void |
sendRequest(Buffer data,
Collection<Address> targetMembers) |
void |
siteUnreachable(String site) |
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.
|
RspList<T> |
waitForCompletion() |
RspList<T> |
waitForCompletion(long timeout,
TimeUnit unit)
Blocks until all responses have been received and returns result or throws exception
|
cancel, corrDone, execute, requestId, requestId, setResponseFilter
acceptEither, acceptEitherAsync, acceptEitherAsync, allOf, anyOf, applyToEither, applyToEitherAsync, applyToEitherAsync, complete, completedFuture, completeExceptionally, exceptionally, getNumberOfDependents, handle, handleAsync, handleAsync, isCancelled, isCompletedExceptionally, isDone, obtrudeException, obtrudeValue, runAfterBoth, runAfterBothAsync, runAfterBothAsync, runAfterEither, runAfterEitherAsync, runAfterEitherAsync, runAsync, runAsync, supplyAsync, supplyAsync, thenAccept, thenAcceptAsync, thenAcceptAsync, thenAcceptBoth, thenAcceptBothAsync, thenAcceptBothAsync, thenApply, thenApplyAsync, thenApplyAsync, thenCombine, thenCombineAsync, thenCombineAsync, thenCompose, thenComposeAsync, thenComposeAsync, thenRun, thenRunAsync, thenRunAsync, toCompletableFuture, whenComplete, whenCompleteAsync, whenCompleteAsync
protected final Lock lock
protected int num_valid
protected int num_received
public GroupRequest(RequestCorrelator corr, 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(Buffer data) throws Exception
sendRequest
in class Request<RspList<T>>
Exception
public void receiveResponse(Object response_value, Address sender, boolean is_exception)
execute()
returns.receiveResponse
in class Request<RspList<T>>
public void siteUnreachable(String site)
siteUnreachable
in class Request<RspList<T>>
public void viewChange(View view)
viewChange
in class Request<RspList<T>>
public void transportClosed()
transportClosed
in class Request<RspList<T>>
public boolean getResponsesComplete()
public RspList<T> get() throws InterruptedException, ExecutionException
get
in interface Future<RspList<T>>
get
in class CompletableFuture<RspList<T>>
InterruptedException
ExecutionException
public RspList<T> get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
get
in interface Future<RspList<T>>
get
in class CompletableFuture<RspList<T>>
InterruptedException
ExecutionException
TimeoutException
public RspList<T> getNow(RspList<T> valueIfAbsent)
getNow
in class CompletableFuture<RspList<T>>
public RspList<T> waitForCompletion(long timeout, TimeUnit unit)
Request
waitForCompletion
in class Request<RspList<T>>
public RspList<T> waitForCompletion() throws ExecutionException, InterruptedException
waitForCompletion
in class Request<RspList<T>>
ExecutionException
InterruptedException
protected void sendRequest(Buffer data, Collection<Address> targetMembers) throws Exception
Exception
protected boolean responsesComplete()
Copyright © 2018 JBoss, a division of Red Hat. All rights reserved.