Class ValidSingleResponseCollector<T>

  • All Implemented Interfaces:

    public abstract class ValidSingleResponseCollector<T>
    extends java.lang.Object
    implements ResponseCollector<T>
    Dan Berindei
    • Constructor Detail

      • ValidSingleResponseCollector

        public ValidSingleResponseCollector()
    • Method Detail

      • addResponse

        public final T addResponse​(Address sender,
                                   Response response)
        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, or null 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 and addResponse() still returns null, 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 while addResponse() is running.

        Specified by:
        addResponse in interface ResponseCollector<T>
      • finish

        public final T finish()
        Description copied from interface: ResponseCollector
        Called after ResponseCollector.addResponse(Address, Response) returns null for the last response.

        If finish() finishes normally, the request will complete with its return value (even if null). If finish() throws an exception, the request will complete exceptionally with that exception, wrapped in a CompletionException (unless the exception is already a CompletionException).

        Specified by:
        finish in interface ResponseCollector<T>
      • withException

        protected T withException​(Address sender,
                                  java.lang.Exception exception)
      • withValidResponse

        protected abstract T withValidResponse​(Address sender,
                                               ValidResponse response)
      • targetNotFound

        protected abstract T targetNotFound​(Address sender)