Class UnicastRequest<T>

  • All Implemented Interfaces:
    java.util.concurrent.CompletionStage<T>, java.util.concurrent.Future<T>

    public class UnicastRequest<T>
    extends Request<T>
    Sends a request to a single target destination
    Author:
    Bela Ban
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.util.concurrent.CompletableFuture

        java.util.concurrent.CompletableFuture.AsynchronousCompletionTask
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected T around​(java.util.function.Supplier<T> supplier)  
      T get()  
      T get​(long timeout, java.util.concurrent.TimeUnit unit)  
      T getNow​(T valueIfAbsent)  
      protected T getResult​(java.util.concurrent.Callable<T> supplier)  
      T join()  
      void receiveResponse​(java.lang.Object response_value, Address sender, boolean is_exception)
      Callback (called by RequestCorrelator or Transport).
      boolean responsesComplete()  
      void sendRequest​(Buffer data)  
      void siteUnreachable​(java.lang.String site)  
      java.lang.String toString()  
      void transportClosed()  
      void viewChange​(View view, boolean handle_previous_subgroups)
      If the target address is not a member of the new view, we'll mark the response as suspected and unblock the caller of execute()
      T waitForCompletion()  
      T waitForCompletion​(long timeout, java.util.concurrent.TimeUnit unit)
      Blocks until all responses have been received and returns result or throws exception
      • Methods inherited from class java.util.concurrent.CompletableFuture

        acceptEither, acceptEitherAsync, acceptEitherAsync, allOf, anyOf, applyToEither, applyToEitherAsync, applyToEitherAsync, complete, completeAsync, completeAsync, completedFuture, completedStage, completeExceptionally, completeOnTimeout, copy, defaultExecutor, delayedExecutor, delayedExecutor, exceptionally, failedFuture, failedStage, getNumberOfDependents, handle, handleAsync, handleAsync, isCancelled, isCompletedExceptionally, isDone, minimalCompletionStage, newIncompleteFuture, obtrudeException, obtrudeValue, orTimeout, 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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • target

        protected final Address target
    • Method Detail

      • sendRequest

        public void sendRequest​(Buffer data)
                         throws java.lang.Exception
        Specified by:
        sendRequest in class Request<T>
        Throws:
        java.lang.Exception
      • receiveResponse

        public void receiveResponse​(java.lang.Object response_value,
                                    Address sender,
                                    boolean is_exception)
        Callback (called by RequestCorrelator or Transport). Adds a response to the response table. When all responses have been received, execute() returns.
        Specified by:
        receiveResponse in class Request<T>
      • siteUnreachable

        public void siteUnreachable​(java.lang.String site)
        Specified by:
        siteUnreachable in class Request<T>
      • viewChange

        public void viewChange​(View view,
                               boolean handle_previous_subgroups)
        If the target address is not a member of the new view, we'll mark the response as suspected and unblock the caller of execute()
        Specified by:
        viewChange in class Request<T>
      • get

        public T get()
              throws java.lang.InterruptedException,
                     java.util.concurrent.ExecutionException
        Specified by:
        get in interface java.util.concurrent.Future<T>
        Overrides:
        get in class java.util.concurrent.CompletableFuture<T>
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
      • get

        public T get​(long timeout,
                     java.util.concurrent.TimeUnit unit)
              throws java.lang.InterruptedException,
                     java.util.concurrent.ExecutionException,
                     java.util.concurrent.TimeoutException
        Specified by:
        get in interface java.util.concurrent.Future<T>
        Overrides:
        get in class java.util.concurrent.CompletableFuture<T>
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
        java.util.concurrent.TimeoutException
      • join

        public T join()
        Overrides:
        join in class java.util.concurrent.CompletableFuture<T>
      • getNow

        public T getNow​(T valueIfAbsent)
        Overrides:
        getNow in class java.util.concurrent.CompletableFuture<T>
      • waitForCompletion

        public T waitForCompletion​(long timeout,
                                   java.util.concurrent.TimeUnit unit)
                            throws java.lang.Exception
        Description copied from class: Request
        Blocks until all responses have been received and returns result or throws exception
        Specified by:
        waitForCompletion in class Request<T>
        Throws:
        java.lang.Exception
      • waitForCompletion

        public T waitForCompletion()
                            throws java.lang.Exception
        Specified by:
        waitForCompletion in class Request<T>
        Throws:
        java.lang.Exception
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class Request<T>
      • responsesComplete

        public boolean responsesComplete()
      • around

        protected T around​(java.util.function.Supplier<T> supplier)
      • getResult

        protected T getResult​(java.util.concurrent.Callable<T> supplier)
                       throws java.lang.Exception
        Throws:
        java.lang.Exception