Interface ResponseCollector<T>
-
- All Known Subinterfaces:
BiasedCollector
- All Known Implementing Classes:
RemoteGetSingleKeyCollector
,ValidResponseCollector
,ValidSingleResponseCollector
public interface ResponseCollector<T>
A representation of a request's responses.Thread-safety: The request will invoke
addResponse(Address, Response)
andfinish()
while holding the collector's monitor, so implementations don't normally need explicit synchronization.- Since:
- 9.1
- Author:
- Dan Berindei
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description T
addResponse(Address sender, Response response)
Called when a response is received, or when a target node becomes unavailable.T
finish()
Called afteraddResponse(Address, Response)
returnsnull
for the last response.
-
-
-
Method Detail
-
addResponse
T addResponse(Address sender, Response response)
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, 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
,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.
-
finish
T finish()
Called afteraddResponse(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
).
-
-