Class ValidResponseCollector<T>
- java.lang.Object
-
- org.infinispan.remoting.transport.ValidResponseCollector<T>
-
- All Implemented Interfaces:
ResponseCollector<T>
public abstract class ValidResponseCollector<T> extends Object implements ResponseCollector<T>
Base class for response collectors, splitting responses into valid responses, exception responses, and target missing. Returning a non-nullvalue or throwing an exception from any of theaddValidResponse(Address, ValidResponse),addException(Address, Exception), oraddTargetNotFound(Address)methods will complete the request. If all invocations returnnull, the request will be completed with the result offinish().- Since:
- 9.1
- Author:
- Dan Berindei
-
-
Constructor Summary
Constructors Constructor Description ValidResponseCollector()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract TaddException(Address sender, Exception exception)Process an exception from a target.TaddResponse(Address sender, Response response)Called when a response is received, or when a target node becomes unavailable.protected abstract TaddTargetNotFound(Address sender)Process a target leaving the cluster or stopping the cache.protected abstract TaddValidResponse(Address sender, ValidResponse response)Process a valid response from a target.abstract Tfinish()Called afterResponseCollector.addResponse(Address, Response)returnsnullfor the last response.
-
-
-
Method Detail
-
addResponse
public final T addResponse(Address sender, Response response)
Description copied from interface:ResponseCollectorCalled 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-
nullresult if the request should complete, ornullif 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:
addResponsein interfaceResponseCollector<T>
-
finish
public abstract T finish()
Description copied from interface:ResponseCollectorCalled afterResponseCollector.addResponse(Address, Response)returnsnullfor 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:
finishin interfaceResponseCollector<T>
-
addValidResponse
protected abstract T addValidResponse(Address sender, ValidResponse response)
Process a valid response from a target.- Returns:
nullto continue waiting for response, non-nullto complete with that value.
-
addTargetNotFound
protected abstract T addTargetNotFound(Address sender)
Process a target leaving the cluster or stopping the cache.- Returns:
nullto continue waiting for response, non-nullto complete with that value.
-
-