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:
MultiTargetRequest
,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 RequestRepository
protected final long
protected final ResponseCollector<T>
Fields inherited from interface org.infinispan.remoting.transport.impl.Request
NO_REQUEST_ID
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractRequest
(long requestId, ResponseCollector<T> responseCollector, RequestRepository repository) -
Method Summary
Modifier and TypeMethodDescriptionfinal Void
call()
boolean
cancel
(boolean mayInterruptIfRunning) void
Complete the request with an exception and release its resources.boolean
boolean
final long
long
protected abstract void
Called when the timeout task scheduled withsetTimeout(ScheduledExecutorService, long, TimeUnit)
expires.void
setTimeout
(ScheduledExecutorService timeoutExecutor, long timeout, TimeUnit unit) Schedule a timeout task on the given executor, and complete the request with aTimeoutException
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 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:
getRequestId
in interfaceRequest<T>
- Returns:
- The unique request id.
-
setTimeout
Schedule a timeout task on the given executor, and complete the request with aTimeoutException
when the task runs. If a timeout task was already registered with this request, it is cancelled. -
cancel
Description copied from interface:Request
Complete the request with an exception and release its resources. -
complete
- Overrides:
complete
in classCompletableFuture<T>
-
completeExceptionally
- Overrides:
completeExceptionally
in classCompletableFuture<T>
-
cancel
public boolean cancel(boolean mayInterruptIfRunning) -
call
-
getTimeoutMs
public long getTimeoutMs()
-