Class AbstractRequest<T>
- java.lang.Object
-
- java.util.concurrent.CompletableFuture<T>
-
- org.infinispan.remoting.transport.AbstractRequest<T>
-
- All Implemented Interfaces:
Callable<Void>,CompletionStage<T>,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 CompletableFuture<T> implements Callable<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
CompletableFuture.AsynchronousCompletionTask
-
-
Field Summary
Fields Modifier and Type Field Description protected org.infinispan.remoting.transport.impl.RequestRepositoryrepositoryprotected longrequestIdprotected ResponseCollector<T>responseCollector
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractRequest(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 Voidcall()booleancancel(boolean mayInterruptIfRunning)voidcancel(Exception exception)Complete the request with an exception and release its resources.booleancomplete(T value)booleancompleteExceptionally(Throwable ex)longgetRequestId()protected abstract voidonTimeout()Called when the timeout task scheduled withsetTimeout(ScheduledExecutorService, long, TimeUnit)expires.voidsetTimeout(ScheduledExecutorService timeoutExecutor, long timeout, TimeUnit unit)Schedule a timeout task on the given executor, and complete the request with aTimeoutExceptionwhen 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
-
-
-
-
Field Detail
-
responseCollector
protected final ResponseCollector<T> responseCollector
-
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
-
onTimeout
protected abstract void onTimeout()
Called when the timeout task scheduled withsetTimeout(ScheduledExecutorService, long, TimeUnit)expires.
-
getRequestId
public final long getRequestId()
- Specified by:
getRequestIdin interfaceorg.infinispan.remoting.transport.impl.Request<T>- Returns:
- The unique request id.
-
setTimeout
public void setTimeout(ScheduledExecutorService timeoutExecutor, long timeout, TimeUnit unit)
Schedule a timeout task on the given executor, and complete the request with aTimeoutExceptionwhen the task runs. If a timeout task was already registered with this request, it is cancelled.
-
cancel
public void cancel(Exception exception)
Description copied from interface:org.infinispan.remoting.transport.impl.RequestComplete the request with an exception and release its resources.- Specified by:
cancelin interfaceorg.infinispan.remoting.transport.impl.Request<T>
-
complete
public boolean complete(T value)
- Overrides:
completein classCompletableFuture<T>
-
completeExceptionally
public boolean completeExceptionally(Throwable ex)
- Overrides:
completeExceptionallyin classCompletableFuture<T>
-
cancel
public boolean cancel(boolean mayInterruptIfRunning)
-
-