Class LeanFixedLengthGammaTxn
- java.lang.Object
-
- org.multiverse.stms.gamma.transactions.GammaTxn
-
- org.multiverse.stms.gamma.transactions.lean.LeanFixedLengthGammaTxn
-
- All Implemented Interfaces:
Txn
,MultiverseConstants
,GammaConstants
public final class LeanFixedLengthGammaTxn extends GammaTxn
A Lean GammaTxn that is optimized for a fixed number of GammaTxnRefs.
-
-
Field Summary
Fields Modifier and Type Field Description boolean
hasReads
Tranlocal
head
Listeners[]
listenersArray
int
size
-
Fields inherited from class org.multiverse.stms.gamma.transactions.GammaTxn
abortOnly, attempt, commitConflict, config, evaluatingCommute, hasWrites, listeners, pool, remainingTimeoutNs, retryListener, richmansMansConflictScan, status, transactionType
-
Fields inherited from interface org.multiverse.stms.gamma.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_UNCOMMITTED
-
Fields inherited from interface org.multiverse.MultiverseConstants
LOCKMODE_EXCLUSIVE, LOCKMODE_NONE, LOCKMODE_READ, LOCKMODE_WRITE, SHAKE_BUGS, SPIN_YIELD, TRACING_ENABLED
-
-
Constructor Summary
Constructors Constructor Description LeanFixedLengthGammaTxn(GammaStm stm)
LeanFixedLengthGammaTxn(GammaTxnConfig config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
abort()
Aborts this Txn.void
commit()
Commits this Txn.Tranlocal
getRefTranlocal(BaseGammaTxnRef ref)
Gets the Tranlocal for a specific AbstractGammaTxnRef.void
hardReset()
Does a hard reset of an aborted/committed transaction.void
initLocalConflictCounter()
Initializes the local conflict counter if the transaction has a need for it.boolean
isReadConsistent(Tranlocal justAdded)
Tranlocal
locate(BaseGammaTxnRef o)
void
prepare()
Prepares this transaction to be committed.void
retry()
Retries the transaction.void
shiftInFront(Tranlocal newHead)
boolean
softReset()
Does a soft reset of an aborted/committed transaction.-
Methods inherited from class org.multiverse.stms.gamma.transactions.GammaTxn
abortAcquireOnNullLockMode, abortCommitOnAbortOnly, abortCommitOnBadStatus, abortCommuteOnBadStatus, abortCommuteOnBadStm, abortCommuteOnCommuteDetected, abortCommuteOnNullFunction, abortCommuteOnReadonly, abortEnsureOnBadStatus, abortEnsureOnEnsureDetected, abortIfAlive, abortLocateOnBadStatus, abortLocateOnNullArgument, abortOnOpenForCommuteWhileEvaluatingCommute, abortOnOpenForConstructionWhileEvaluatingCommute, abortOnOpenForReadWhileEvaluatingCommute, abortOnReadWriteConflict, abortOnRichmanConflictScanDetected, abortOnTransactionTooSmall, abortOpenForConstructionOnBadReference, abortOpenForConstructionOnBadStatus, abortOpenForConstructionOnBadStm, abortOpenForConstructionOnReadonly, abortOpenForConstructionRequired, abortOpenForReadOnBadStatus, abortOpenForReadOnBadStm, abortOpenForReadOnNonRefTypeDetected, abortOpenForReadOnNullLockMode, abortOpenForReadOrWriteOnExplicitLockingDetected, abortOpenForWriteOnReadonly, abortPrepareOnAbortOnly, abortPrepareOnBadStatus, abortRegisterOnListenerRequired, abortRetryOnBadStatus, abortRetryOnNoBlockingAllowed, abortRetryOnNoRetryPossible, awaitUpdate, copyForSpeculativeFailure, failAbortOnAlreadyCommitted, getAttempt, getConfig, getRemainingTimeoutNs, getStatus, hasWrites, init, isAbortOnly, isAlive, isLean, newRetryError, notifyListeners, register, setAbortOnly, skipPrepare
-
-
-
-
Constructor Detail
-
LeanFixedLengthGammaTxn
public LeanFixedLengthGammaTxn(GammaStm stm)
-
LeanFixedLengthGammaTxn
public LeanFixedLengthGammaTxn(GammaTxnConfig config)
-
-
Method Detail
-
isReadConsistent
public final boolean isReadConsistent(Tranlocal justAdded)
- Specified by:
isReadConsistent
in classGammaTxn
-
commit
public final void commit()
Description copied from interface:Txn
Commits 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
ReadWriteConflict
after 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
RuntimeException
orError
, this will be re-thrown. If a listener fails after the prepare/commit the transaction still is committed.
-
prepare
public final void prepare()
Description copied from interface:Txn
Prepares this transaction to be committed. It can lock resources to make sure that no conflicting changes are made after the transaction has been prepared. If the transaction already is prepared, the call is ignored. If the prepare fails, the transaction automatically is aborted. Once a transaction is prepared, the commit will always succeed.It is very important that the transaction eventually commits or aborts, if it doesn't no other transaction reading/writing the committed resources, can't commit.
-
abort
public final void abort()
Description copied from interface:Txn
Aborts 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.
-
getRefTranlocal
public final Tranlocal getRefTranlocal(BaseGammaTxnRef ref)
Description copied from class:GammaTxn
Gets the Tranlocal for a specific AbstractGammaTxnRef. This method doesn't care about the state of a transaction.- Specified by:
getRefTranlocal
in classGammaTxn
- Parameters:
ref
- the AbstractGammaTxnRef- Returns:
- the found Tranlocal or null if not found.
-
retry
public final void retry()
Description copied from interface:Txn
Retries the transaction. This call doesn't block, but if all goes well aRetryError
is thrown which is caught by theTxnExecutor
.
-
locate
public final Tranlocal locate(BaseGammaTxnRef o)
-
hardReset
public final void hardReset()
Description copied from class:GammaTxn
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 final boolean softReset()
Description copied from class:GammaTxn
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.
-
shiftInFront
public final void shiftInFront(Tranlocal newHead)
-
initLocalConflictCounter
public void initLocalConflictCounter()
Description copied from class:GammaTxn
Initializes the local conflict counter if the transaction has a need for it. It should only be initialized if there are no reads.- Specified by:
initLocalConflictCounter
in classGammaTxn
-
-