Class AbstractRequest<T>

  • All Implemented Interfaces:
    java.util.concurrent.Callable<java.lang.Void>, java.util.concurrent.CompletionStage<T>, java.util.concurrent.Future<T>, org.infinispan.remoting.transport.impl.Request<T>
    Direct Known Subclasses:
    org.infinispan.remoting.transport.impl.MultiTargetRequest, SingleSiteRequest

    public abstract class AbstractRequest<T>
    extends java.util.concurrent.CompletableFuture<T>
    implements java.util.concurrent.Callable<java.lang.Void>, org.infinispan.remoting.transport.impl.Request<T>
    A remote invocation request.

    Thread-safety: This class and its sub-classes are thread-safe. They use the ResponseCollector's monitor for synchronization, so that collectors usually don't need any explicit synchronization.

    Since:
    9.1
    Author:
    Dan Berindei
    • Nested Class Summary

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

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

      Fields 
      Modifier and Type Field Description
      protected org.infinispan.remoting.transport.impl.RequestRepository repository  
      protected long requestId  
      protected ResponseCollector<T> responseCollector  
      • Fields inherited from interface org.infinispan.remoting.transport.impl.Request

        NO_REQUEST_ID
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AbstractRequest​(long requestId, ResponseCollector<T> responseCollector, org.infinispan.remoting.transport.impl.RequestRepository repository)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Void call()  
      boolean cancel​(boolean mayInterruptIfRunning)  
      void cancel​(java.lang.Exception exception)
      Complete the request with an exception and release its resources.
      boolean complete​(T value)  
      boolean completeExceptionally​(java.lang.Throwable ex)  
      long getRequestId()  
      protected abstract void onTimeout()
      Called when the timeout task scheduled with setTimeout(ScheduledExecutorService, long, TimeUnit) expires.
      void setTimeout​(java.util.concurrent.ScheduledExecutorService timeoutExecutor, long timeout, java.util.concurrent.TimeUnit unit)
      Schedule a timeout task on the given executor, and complete the request with a TimeoutException when the task runs.
      • Methods inherited from class java.util.concurrent.CompletableFuture

        acceptEither, acceptEitherAsync, acceptEitherAsync, allOf, anyOf, applyToEither, applyToEitherAsync, applyToEitherAsync, completeAsync, completeAsync, completedFuture, completedStage, completeOnTimeout, copy, defaultExecutor, delayedExecutor, delayedExecutor, exceptionally, failedFuture, failedStage, get, get, getNow, getNumberOfDependents, handle, handleAsync, handleAsync, isCancelled, isCompletedExceptionally, isDone, join, 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, toString, whenComplete, whenCompleteAsync, whenCompleteAsync
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.concurrent.CompletionStage

        acceptEither, acceptEitherAsync, acceptEitherAsync, applyToEither, applyToEitherAsync, applyToEitherAsync, exceptionally, handle, handleAsync, handleAsync, runAfterBoth, runAfterBothAsync, runAfterBothAsync, runAfterEither, runAfterEitherAsync, runAfterEitherAsync, 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 interface org.infinispan.remoting.transport.impl.Request

        onNewView, onResponse
    • Field Detail

      • requestId

        protected final long requestId
      • repository

        protected final org.infinispan.remoting.transport.impl.RequestRepository repository
    • Constructor Detail

      • AbstractRequest

        protected AbstractRequest​(long requestId,
                                  ResponseCollector<T> responseCollector,
                                  org.infinispan.remoting.transport.impl.RequestRepository repository)
    • Method Detail

      • getRequestId

        public final long getRequestId()
        Specified by:
        getRequestId in interface org.infinispan.remoting.transport.impl.Request<T>
        Returns:
        The unique request id.
      • setTimeout

        public void setTimeout​(java.util.concurrent.ScheduledExecutorService timeoutExecutor,
                               long timeout,
                               java.util.concurrent.TimeUnit unit)
        Schedule a timeout task on the given executor, and complete the request with a TimeoutException when the task runs. If a timeout task was already registered with this request, it is cancelled.
      • cancel

        public void cancel​(java.lang.Exception exception)
        Description copied from interface: org.infinispan.remoting.transport.impl.Request
        Complete the request with an exception and release its resources.
        Specified by:
        cancel in interface org.infinispan.remoting.transport.impl.Request<T>
      • complete

        public boolean complete​(T value)
        Overrides:
        complete in class java.util.concurrent.CompletableFuture<T>
      • completeExceptionally

        public boolean completeExceptionally​(java.lang.Throwable ex)
        Overrides:
        completeExceptionally in class java.util.concurrent.CompletableFuture<T>
      • cancel

        public boolean cancel​(boolean mayInterruptIfRunning)
        Specified by:
        cancel in interface java.util.concurrent.Future<T>
        Overrides:
        cancel in class java.util.concurrent.CompletableFuture<T>
      • call

        public final java.lang.Void call()
                                  throws java.lang.Exception
        Specified by:
        call in interface java.util.concurrent.Callable<T>
        Throws:
        java.lang.Exception