Package com.google.cloud.spanner
Class DelayedAsyncTransactionManager
java.lang.Object
com.google.cloud.spanner.DelayedAsyncTransactionManager
- All Implemented Interfaces:
AsyncTransactionManager,AutoCloseable
Represents a
AsyncTransactionManager using a multiplexed session that is not yet ready.
The execution will be delayed until the multiplexed session has been created and is ready. This
class is only used during the startup of the client and the multiplexed session has not yet been
created.-
Nested Class Summary
Nested classes/interfaces inherited from interface com.google.cloud.spanner.AsyncTransactionManager
AsyncTransactionManager.AsyncTransactionFunction<I,O>, AsyncTransactionManager.AsyncTransactionStep<I, O>, AsyncTransactionManager.CommitTimestampFuture, AsyncTransactionManager.TransactionContextFuture -
Method Summary
Modifier and TypeMethodDescriptionCreates a new read write transaction.beginAsync(AbortedException exception) Initializes a new read-write transaction that is a retry of a previously aborted transaction.voidclose()Closes the manager.com.google.api.core.ApiFuture<Void>Closes the transaction manager.com.google.api.core.ApiFuture<CommitResponse>Returns theCommitResponseof this transaction.getState()Returns the state of the transaction.Creates a new transaction for retry.com.google.api.core.ApiFuture<Void>Rolls back the currently active transaction.
-
Method Details
-
beginAsync
Description copied from interface:AsyncTransactionManagerCreates a new read write transaction. This must be called before doing any other operation and can only be called once. To create a new transaction for subsequent retries, seeAsyncTransactionManager.resetForRetryAsync().- Specified by:
beginAsyncin interfaceAsyncTransactionManager
-
beginAsync
Description copied from interface:AsyncTransactionManagerInitializes a new read-write transaction that is a retry of a previously aborted transaction. This method must be called before performing any operations, and it can only be invoked once per transaction lifecycle.This method should only be used when multiplexed sessions are enabled to create a retry for a previously aborted transaction. This method can be used instead of
AsyncTransactionManager.resetForRetryAsync()to create a retry. Using this method orAsyncTransactionManager.resetForRetryAsync()will have the same effect. You must pass in theAbortedExceptionfrom the previous attempt to preserve the transaction's priority.For regular sessions, this behaves the same as
AsyncTransactionManager.beginAsync().- Specified by:
beginAsyncin interfaceAsyncTransactionManager
-
rollbackAsync
Description copied from interface:AsyncTransactionManagerRolls back the currently active transaction. In most cases there should be no need to call this explicitly sinceAsyncTransactionManager.close()would automatically roll back any active transaction.- Specified by:
rollbackAsyncin interfaceAsyncTransactionManager
-
resetForRetryAsync
Description copied from interface:AsyncTransactionManagerCreates a new transaction for retry. This should only be called if the previous transaction failed withABORTED. In all other cases, this will throw anIllegalStateException. Users should backoff before calling this method. Backoff delay is specified bySpannerException.getRetryDelayInMillis()on theSpannerExceptionthrow by the previous commit call.- Specified by:
resetForRetryAsyncin interfaceAsyncTransactionManager
-
getState
Description copied from interface:AsyncTransactionManagerReturns the state of the transaction.- Specified by:
getStatein interfaceAsyncTransactionManager
-
getCommitResponse
Description copied from interface:AsyncTransactionManagerReturns theCommitResponseof this transaction.- Specified by:
getCommitResponsein interfaceAsyncTransactionManager
-
close
public void close()Description copied from interface:AsyncTransactionManagerCloses the manager. If there is an active transaction, it will be rolled back. Underlying session will be released back to the session pool.- Specified by:
closein interfaceAsyncTransactionManager- Specified by:
closein interfaceAutoCloseable
-
closeAsync
Description copied from interface:AsyncTransactionManagerCloses the transaction manager. If there is an active transaction, it will be rolled back. The underlying session will be released back to the session pool. The returnedApiFutureis done when the transaction (if any) has been rolled back.- Specified by:
closeAsyncin interfaceAsyncTransactionManager
-