Class GammaTxn
- All Implemented Interfaces:
Txn, MultiverseConstants, GammaConstants
- Direct Known Subclasses:
FatFixedLengthGammaTxn, FatMonoGammaTxn, FatVariableLengthGammaTxn, LeanFixedLengthGammaTxn, LeanMonoGammaTxn
-
Field Summary
FieldsModifier and TypeFieldDescriptionbooleanintbooleanbooleanbooleanfinal GammaObjectPoollongfinal RetryLatchbooleanintfinal intFields inherited from interface GammaConstants
FAILURE, MASK_CONFLICT, MASK_SUCCESS, MASK_UNREGISTERED, REGISTRATION_DONE, REGISTRATION_NONE, REGISTRATION_NOT_NEEDED, TRANLOCAL_COMMUTING, TRANLOCAL_CONSTRUCTING, TRANLOCAL_READ, TRANLOCAL_WRITE, TRANSACTIONTYPE_FAT_FIXED_LENGTH, TRANSACTIONTYPE_FAT_MONO, TRANSACTIONTYPE_FAT_VARIABLE_LENGTH, TRANSACTIONTYPE_LEAN_FIXED_LENGTH, TRANSACTIONTYPE_LEAN_MONO, TX_ABORTED, TX_ACTIVE, TX_COMMITTED, TX_PREPARED, TYPE_BOOLEAN, TYPE_DOUBLE, TYPE_INT, TYPE_LONG, TYPE_REF, VERSION_UNCOMMITTEDFields inherited from interface MultiverseConstants
LOCKMODE_EXCLUSIVE, LOCKMODE_NONE, LOCKMODE_READ, LOCKMODE_WRITE, SHAKE_BUGS, SPIN_YIELD, TRACING_ENABLED -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidabort()Aborts this Txn.final NullPointerExceptionfinal IllegalTxnStateExceptionabortCommuteOnBadStatus(GammaObject object, Function function) abortCommuteOnBadStm(GammaObject object) abortCommuteOnReadonly(GammaObject object) final voidfinal IllegalTxnStateExceptionabortLocateOnBadStatus(GammaObject object) final NullPointerExceptionfinal ReadWriteConflictabortOnReadWriteConflict(GammaObject object) abortOnTransactionTooSmall(int minimalSize) final IllegalArgumentExceptionfinal IllegalTxnStateExceptionfinal StmMismatchExceptionfinal IllegalTxnStateExceptionfinal StmMismatchExceptionfinal ReadonlyExceptionfinal IllegalTxnStateExceptionprivate IllegalTxnStateExceptionprivate NullPointerExceptionfinal IllegalTxnStateExceptionfinal RetryNotAllowedExceptionfinal IllegalTxnStateExceptionfinal voidabstract voidcommit()Commits this Txn.final voidcopyForSpeculativeFailure(GammaTxn failingTx) final intGets the current attempt (so the number of tries this transaction already had).final GammaTxnConfigReturns the TxnConfig used by this Txn.abstract TranlocalGets the Tranlocal for a specific AbstractGammaTxnRef.final longGets the remaining timeout in nanoseconds.final TxnStatusReturns the status of this Txn.abstract voidDoes a hard reset of an aborted/committed transaction.final booleanfinal voidinit(GammaTxnConfig config) abstract voidInitializes the local conflict counter if the transaction has a need for it.booleanChecks if this Txn is abort only (so will always fail when committing or preparing).final booleanisAlive()final booleanisLean()abstract booleanisReadConsistent(Tranlocal justAdded) abstract Tranlocalprotected RetryErrorprotected voidnotifyListeners(TxnEvent event) voidregister(TxnListener listener) Registers a TxnListener.final voidSignals that the only possible outcome of the Txn is one that aborts.final booleanabstract booleanDoes a soft reset of an aborted/committed transaction.
-
Field Details
-
pool
-
status
public int status -
config
-
attempt
public int attempt -
remainingTimeoutNs
public long remainingTimeoutNs -
hasWrites
public boolean hasWrites -
transactionType
public final int transactionType -
richmansMansConflictScan
public boolean richmansMansConflictScan -
abortOnly
public boolean abortOnly -
retryListener
-
listeners
-
commitConflict
public boolean commitConflict -
evaluatingCommute
public boolean evaluatingCommute
-
-
Constructor Details
-
GammaTxn
-
-
Method Details
-
notifyListeners
-
newRetryError
-
isLean
public final boolean isLean() -
abortIfAlive
public final void abortIfAlive() -
abortPrepareOnAbortOnly
-
abortCommitOnAbortOnly
-
abortOnReadWriteConflict
-
failAbortOnAlreadyCommitted
-
abortOpenForReadOrWriteOnExplicitLockingDetected
public SpeculativeConfigurationError abortOpenForReadOrWriteOnExplicitLockingDetected(BaseGammaTxnRef ref) -
abortOpenForReadOnNonRefTypeDetected
-
abortOpenForReadOnBadStm
-
abortOpenForReadOnNullLockMode
-
abortOpenForReadOnBadStatus
-
abortOpenForWriteOnReadonly
-
abortRetryOnNoRetryPossible
-
abortRetryOnNoBlockingAllowed
-
abortRetryOnBadStatus
-
abortOpenForConstructionOnBadReference
-
abortOpenForConstructionOnBadStatus
-
abortOpenForConstructionOnBadStm
-
abortOpenForConstructionOnReadonly
-
abortOpenForConstructionRequired
-
abortCommuteOnCommuteDetected
-
abortCommuteOnBadStatus
-
abortCommuteOnBadStm
-
abortCommuteOnReadonly
-
abortCommuteOnNullFunction
-
abortLocateOnBadStatus
-
abortLocateOnNullArgument
-
abortRegisterOnNullListener
-
abortRegisterOnBadStatus
-
abortRegisterOnListenerRequired
-
abortPrepareOnBadStatus
-
abortCommitOnBadStatus
-
abortOnOpenForConstructionWhileEvaluatingCommute
-
abortOnOpenForReadWhileEvaluatingCommute
-
abortOnOpenForCommuteWhileEvaluatingCommute
-
abortEnsureOnBadStatus
-
abortOnTransactionTooSmall
-
abortOnRichmanConflictScanDetected
-
abortEnsureOnEnsureDetected
-
abortAcquireOnNullLockMode
-
hasWrites
public final boolean hasWrites() -
commit
public abstract void commit()Description copied from interface:TxnCommits this Txn. If the Txn is:- active: it is prepared for commit and then committed
- prepared: it is committed. Once it is prepared, the commit is guaranteed to succeed.
- aborted: a DeadTxnException is thrown
- committed: the call is ignored
Txn will always be aborted if the commit does not succeed.
Commit will not throw a
ReadWriteConflictafter the transaction is prepared. So if prepared successfully, a commit will always succeed.If there are TxnListeners (either normal ones or permanent ones) and they thrown a
RuntimeExceptionorError, this will be re-thrown. If a listener fails after the prepare/commit the transaction still is committed. -
abort
public abstract void abort()Description copied from interface:TxnAborts this Txn. This means that the changes made in this transaction are not committed. It depends on the implementation if this operation is simple (ditching objects for example), or if changes need to be rolled back. If an exception is thrown while executing the abort, the transaction is still aborted. And example of such a situation is a pre-abort task that fails. So the transaction always is aborted (unless it is committed).If the Txn already is aborted, the call is ignored.
-
locate
-
getConfig
Description copied from interface:TxnReturns the TxnConfig used by this Txn.Because the Txn can be reused, the TxnConfig used by this Txn doesn't need to be constant.
-
getAttempt
public final int getAttempt()Description copied from interface:TxnGets the current attempt (so the number of tries this transaction already had). Value will always be equal or larger than 1 (the first attempt returns 1). The maximum number of attempts for retrying is determined based on theTxnConfig.getMaxRetries()- Specified by:
getAttemptin interfaceTxn- Returns:
- the current attempt.
-
getRemainingTimeoutNs
public final long getRemainingTimeoutNs()Description copied from interface:TxnGets the remaining timeout in nanoseconds. Long.MAX_VALUE indicates that no timeout is used.The remaining timeout only is decreased if a transaction blocks on a retry or when doing a backoff.
- Specified by:
getRemainingTimeoutNsin interfaceTxn- Returns:
- the remaining timeout.
-
isAbortOnly
public boolean isAbortOnly()Description copied from interface:TxnChecks if this Txn is abort only (so will always fail when committing or preparing).This method is not threadsafe, so can only be called by the thread that used the transaction.
- Specified by:
isAbortOnlyin interfaceTxn- Returns:
- true if abort only, false otherwise.
-
setAbortOnly
public final void setAbortOnly()Description copied from interface:TxnSignals that the only possible outcome of the Txn is one that aborts. When the transaction prepares or commits it checks if the transaction is marked as abort only. If so, it will automatically aborted and anAbortOnlyExceptionis thrown.This method is not threadsafe, so can only be called by the thread that used the transaction.
- Specified by:
setAbortOnlyin interfaceTxn
-
register
Description copied from interface:TxnRegisters a TxnListener. Every time a transaction is retried, the listener needs to be registered again if you want the task to be executed again. If you want a permanent listener, have a look at theTxnFactoryBuilder.addPermanentListener(org.multiverse.api.lifecycle.TxnListener).If a TxnListener is added more than once, it is executed more than once. No checks are made. The permanent listeners are executed in the order they are added.
If a TxnListener throws an Error/RuntimeException and the transaction still is alive, it is aborted. For compensating and deferred actions this is not an issue, but for the PrePrepare state or the state it could since the transaction is aborted.
-
hardReset
public abstract void hardReset()Does a hard reset of an aborted/committed transaction. This means that it is made ready to be used by another transaction configuration. -
softReset
public abstract boolean softReset()Does a soft reset of an aborted/committed transaction. This method is called when the execution of a transaction fails, but needs to be retried again.- Returns:
- if another attempt can be made, false otherwise.
-
getRefTranlocal
Gets the Tranlocal for a specific AbstractGammaTxnRef. This method doesn't care about the state of a transaction.- Parameters:
ref- the AbstractGammaTxnRef- Returns:
- the found Tranlocal or null if not found.
-
isAlive
public final boolean isAlive() -
awaitUpdate
public final void awaitUpdate() -
copyForSpeculativeFailure
-
init
-
isReadConsistent
-
getStatus
-
skipPrepare
public final boolean skipPrepare() -
initLocalConflictCounter
public abstract void initLocalConflictCounter()Initializes the local conflict counter if the transaction has a need for it. It should only be initialized if there are no reads.
-