org.multiverse.stms.gamma.transactions.lean
Class LeanMonoGammaTxn

java.lang.Object
  extended by org.multiverse.stms.gamma.transactions.GammaTxn
      extended by org.multiverse.stms.gamma.transactions.lean.LeanMonoGammaTxn
All Implemented Interfaces:
Txn, MultiverseConstants, GammaConstants

public final class LeanMonoGammaTxn
extends GammaTxn

A Lean GammaTxn implementation that is optimized for dealing with only a single transactional reference.


Field Summary
 Tranlocal tranlocal
           
 
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
LeanMonoGammaTxn(GammaStm stm)
           
LeanMonoGammaTxn(GammaTxnConfig config)
           
 
Method Summary
 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.
 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tranlocal

public final Tranlocal tranlocal
Constructor Detail

LeanMonoGammaTxn

public LeanMonoGammaTxn(GammaStm stm)

LeanMonoGammaTxn

public LeanMonoGammaTxn(GammaTxnConfig config)
Method Detail

locate

public final Tranlocal locate(BaseGammaTxnRef o)
Specified by:
locate in class GammaTxn

commit

public final void commit()
Description copied from interface: Txn
Commits this Txn. If the Txn is:
  1. active: it is prepared for commit and then committed
  2. prepared: it is committed. Once it is prepared, the commit is guaranteed to succeed.
  3. aborted: a DeadTxnException is thrown
  4. 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 or Error, this will be re-thrown. If a listener fails after the prepare/commit the transaction still is committed.

Specified by:
commit in interface Txn
Specified by:
commit in class GammaTxn

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.

Specified by:
abort in interface Txn
Specified by:
abort in class GammaTxn

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.


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 class GammaTxn
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 a RetryError is thrown which is caught by the TxnExecutor.


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.

Specified by:
softReset in class GammaTxn
Returns:
if another attempt can be made, false otherwise.

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.

Specified by:
hardReset in class GammaTxn

isReadConsistent

public final boolean isReadConsistent(Tranlocal justAdded)
Specified by:
isReadConsistent in class GammaTxn

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 class GammaTxn


Copyright © 2012. All Rights Reserved.