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>,Request<T>
- Direct Known Subclasses:
ExclusiveTargetRequest,SingleSiteRequest,SingleTargetRequest
public abstract class AbstractRequest<T>
extends CompletableFuture<T>
implements Callable<Void>, 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
FieldsModifier and TypeFieldDescriptionprotected final RequestRepositoryprotected final longprotected final ResponseCollector<T> Fields inherited from interface org.infinispan.remoting.transport.impl.Request
NO_REQUEST_ID -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractRequest(long requestId, ResponseCollector<T> responseCollector, RequestRepository repository) -
Method Summary
Modifier and TypeMethodDescriptionfinal Voidcall()booleancancel(boolean mayInterruptIfRunning) voidComplete the request with an exception and release its resources.booleanbooleanfinal longlongprotected abstract voidCalled 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, exceptionallyAsync, exceptionallyAsync, exceptionallyCompose, exceptionallyComposeAsync, exceptionallyComposeAsync, 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, whenCompleteAsyncMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.concurrent.CompletionStage
acceptEither, acceptEitherAsync, acceptEitherAsync, applyToEither, applyToEitherAsync, applyToEitherAsync, exceptionally, exceptionallyAsync, exceptionallyAsync, exceptionallyCompose, exceptionallyComposeAsync, exceptionallyComposeAsync, 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, whenCompleteAsyncMethods inherited from interface org.infinispan.remoting.transport.impl.Request
onNewView, onResponse
-
Field Details
-
responseCollector
-
requestId
protected final long requestId -
repository
-
-
Constructor Details
-
AbstractRequest
protected AbstractRequest(long requestId, ResponseCollector<T> responseCollector, RequestRepository repository)
-
-
Method Details
-
onTimeout
protected abstract void onTimeout()Called when the timeout task scheduled withsetTimeout(ScheduledExecutorService, long, TimeUnit)expires. -
getRequestId
public final long getRequestId()- Specified by:
getRequestIdin interfaceRequest<T>- Returns:
- The unique request id.
-
setTimeout
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
-
complete
- Overrides:
completein classCompletableFuture<T>
-
completeExceptionally
- Overrides:
completeExceptionallyin classCompletableFuture<T>
-
cancel
-
call
-
getTimeoutMs
public long getTimeoutMs()
-