Interface PendingLockPromise
public interface PendingLockPromise
A promise returned by
PendingLockManager
.
When a transaction need to wait for older topology transaction, this class allows it to check the state. If the
transaction does not need to wait, or all older transactions have finished or have timed out, the isReady()
method returns true
. Also, it allows the caller to add listeners to be notified when it is ready.
- Since:
- 8.0
- Author:
- Pedro Ruivo
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(PendingLockListener listener) Adds a listener to this promise.long
boolean
boolean
isReady()
If successful,getRemainingTimeout()
will return the remaining timeout, in millis.
-
Field Details
-
NO_OP
-
-
Method Details
-
isReady
boolean isReady()- Returns:
true
when the transaction has finished the waiting.
-
addListener
Adds a listener to this promise.The listener must be non-null and it is invoked only once. If
isReady()
returnstrue
, thelistener
is immediately invoked in the invoker thread.- Parameters:
listener
- thePendingLockListener
to add.
-
hasTimedOut
boolean hasTimedOut()- Returns:
true
if the time out happened while waiting for older transactions.
-
getRemainingTimeout
long getRemainingTimeout()- Returns:
- the remaining timeout, in millis. It is zero when
hasTimedOut()
istrue
.
-
toInvocationStage
InvocationStage toInvocationStage()If successful,getRemainingTimeout()
will return the remaining timeout, in millis. If timed out, the resultInvocationStage
will be completed with aTimeoutException
.- Returns:
- an
InvocationStage
for this lock.
-