Class ExclusiveTargetRequest<T>
- All Implemented Interfaces:
Callable<Void>,CompletionStage<T>,Future<T>,Request<T>
- Direct Known Subclasses:
MultiTargetRequest
This Request handles concurrent calls to onResponse(Address, Response),
onNewView(Set) and onTimeout() by using a very small synchronized block to guarantee only a single
thread is performing any these actual operations at a time. This is done by updating the instance variable handling
to true for the first caller to enter one of these methods. The thread that updates it to true will perform their
operation immediately. However, if another concurrent call enters any of these methods and handling is already
true this thread will instead initialize the queue if necessary and add its operation as a Runnable to it.
The caller that updated handling to true will after performing its operation check under lock if the
queue has been updated and if so run any of those operations, thus guaranteeing thread safety.
Note that onNewView(Set) return value is only valid if invoked before submitting this request. This is due
to the update being possibly enqueued, and thus we cannot guarantee its correctness.
- Author:
- William Burns
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.concurrent.CompletableFuture
CompletableFuture.AsynchronousCompletionTask -
Field Summary
Fields inherited from class org.infinispan.remoting.transport.AbstractRequest
repository, requestId, responseCollectorFields inherited from interface org.infinispan.remoting.transport.impl.Request
NO_REQUEST_ID -
Constructor Summary
ConstructorsConstructorDescriptionExclusiveTargetRequest(ResponseCollector<T> responseCollector, long requestId, RequestRepository repository) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidactualOnResponse(Address sender, Response response) protected abstract voidprotected abstract booleanactualOnView(Set<Address> members) final booleanCalled when the node received a new cluster view.final voidonResponse(Address sender, Response response) Called when a response is received for this response.protected final voidCalled when the timeout task scheduled withAbstractRequest.setTimeout(ScheduledExecutorService, long, TimeUnit)expires.Methods inherited from class org.infinispan.remoting.transport.AbstractRequest
call, cancel, cancel, complete, completeExceptionally, getRequestId, getTimeoutMs, setTimeoutMethods 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, whenCompleteAsync
-
Constructor Details
-
ExclusiveTargetRequest
public ExclusiveTargetRequest(ResponseCollector<T> responseCollector, long requestId, RequestRepository repository)
-
-
Method Details
-
onResponse
-
onNewView
-
onTimeout
protected final void onTimeout()Description copied from class:AbstractRequestCalled when the timeout task scheduled withAbstractRequest.setTimeout(ScheduledExecutorService, long, TimeUnit)expires.- Specified by:
onTimeoutin classAbstractRequest<T>
-
actualOnResponse
-
actualOnView
-
actualOnTimeout
protected abstract void actualOnTimeout()
-