Class ValidResponseCollector<T>
- All Implemented Interfaces:
ResponseCollector<T>
- Direct Known Subclasses:
FilterMapResponseCollector
,MapResponseCollector
,VoidResponseCollector
null
value or throwing an exception from any of the
addValidResponse(Address, ValidResponse)
, addException(Address, Exception)
, or
addTargetNotFound(Address)
methods will complete the request.
If all invocations return null
, the request will be completed with the result of finish()
.- Since:
- 9.1
- Author:
- Dan Berindei
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract T
addException
(Address sender, Exception exception) Process an exception from a target.final T
addResponse
(Address sender, Response response) Called when a response is received, or when a target node becomes unavailable.protected abstract T
addTargetNotFound
(Address sender) Process a target leaving the cluster or stopping the cache.protected abstract T
addValidResponse
(Address sender, ValidResponse response) Process a valid response from a target.abstract T
finish()
Called afterResponseCollector.addResponse(Address, Response)
returnsnull
for the last response.
-
Constructor Details
-
ValidResponseCollector
public ValidResponseCollector()
-
-
Method Details
-
addResponse
Description copied from interface:ResponseCollector
Called when a response is received, or when a target node becomes unavailable.When a target node leaves the cluster, this method is called with a
CacheNotFoundResponse
.Should return a non-
null
result if the request should complete with that value, ornull
if it should wait for more responses. If the method throws an exception, the request will be completed with that exception. If the last response is received andaddResponse()
still returnsnull
,ResponseCollector.finish()
will also be called to obtain a result.Thread safety:
addResponse()
will *not* be called concurrently from multiple threads, and the request will not be completed whileaddResponse()
is running.- Specified by:
addResponse
in interfaceResponseCollector<T>
-
finish
Description copied from interface:ResponseCollector
Called afterResponseCollector.addResponse(Address, Response)
returnsnull
for the last response.If
finish()
finishes normally, the request will complete with its return value (even ifnull
). Iffinish()
throws an exception, the request will complete exceptionally with that exception, wrapped in aCompletionException
(unless the exception is already aCompletionException
).- Specified by:
finish
in interfaceResponseCollector<T>
-
addValidResponse
Process a valid response from a target.- Returns:
null
to continue waiting for response, non-null
to complete with that value.
-
addTargetNotFound
Process a target leaving the cluster or stopping the cache.- Returns:
null
to continue waiting for response, non-null
to complete with that value.
-
addException
Process an exception from a target.- Returns:
null
to continue waiting for responses (the default), non-null
to complete with that value.
-