org.multiverse.stms.gamma.transactions
Class GammaTxnConfig

java.lang.Object
  extended by org.multiverse.stms.gamma.transactions.GammaTxnConfig
All Implemented Interfaces:
TxnConfig, MultiverseConstants, GammaConstants

public final class GammaTxnConfig
extends Object
implements TxnConfig, GammaConstants

A configuration object that contains the configuration for a GammaTxn.

GammaTxnConfig object is considered to be immutable. The only mutable part if the speculative configuration that can get upgraded if enabled and speculations failed.

Author:
Peter Veentjer.

Field Summary
 BackoffPolicy backoffPolicy
           
 boolean blockingAllowed
           
 boolean controlFlowErrorsReused
           
 boolean dirtyCheck
           
 String familyName
           
 GlobalConflictCounter globalConflictCounter
           
static AtomicLong idGenerator
           
 boolean inconsistentReadAllowed
           
 boolean interruptible
           
 boolean isAnonymous
           
 boolean isFat
           
 IsolationLevel isolationLevel
           
 int maxFixedLengthTransactionSize
           
 int maximumPoorMansConflictScanLength
           
 int maxRetries
           
 int minimalArrayTreeSize
           
 ArrayList<TxnListener> permanentListeners
           
 PropagationLevel propagationLevel
           
 LockMode readLockMode
           
 int readLockModeAsInt
           
 boolean readonly
           
 boolean speculative
           
 AtomicReference<SpeculativeGammaConfiguration> speculativeConfiguration
           
 int spinCount
           
 GammaStm stm
           
 long timeoutNs
           
 TraceLevel traceLevel
           
 boolean trackReads
           
 boolean unrepeatableReadAllowed
           
 LockMode writeLockMode
           
 int writeLockModeAsInt
           
 boolean writeSkewAllowed
           
 
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
GammaTxnConfig(GammaStm stm)
           
GammaTxnConfig(GammaStm stm, GammaStmConfig config)
           
GammaTxnConfig(GammaStm stm, int maxFixedLengthTransactionSize)
           
 
Method Summary
 GammaTxnConfig addPermanentListener(TxnListener listener)
           
 BackoffPolicy getBackoffPolicy()
          Returns the BackoffPolicy used by the Stm when a transaction conflicts with another transaction.
 String getFamilyName()
          Returns the family name of this Txn.
 GlobalConflictCounter getGlobalConflictCounter()
           
 IsolationLevel getIsolationLevel()
          Gets the IsolationLevel used.
 int getMaxRetries()
          Returns the maximum number of times this Txn be retried before failing.
 List<TxnListener> getPermanentListeners()
          Returns an unmodifiable list containing all permanent TxnListener.
 PropagationLevel getPropagationLevel()
          Returns the PropagationLevel used.
 LockMode getReadLockMode()
          Gets the current LockMode for all reads.
 SpeculativeGammaConfiguration getSpeculativeConfiguration()
           
 int getSpinCount()
          Returns the maximum number of times the transaction is allowed to spin on a read to become readable (perhaps it is locked).
 GammaStm getStm()
          Returns the Stm that creates transactions based on this configuration.
 long getTimeoutNs()
          Returns the total timeout in nanoseconds.
 TraceLevel getTraceLevel()
          Returns the TraceLevel.
 LockMode getWriteLockMode()
          Gets the current LockMode for all writes.
 GammaTxnConfig init()
           
 boolean isBlockingAllowed()
          If an explicit retry (so a blocking transaction) is allowed.
 boolean isControlFlowErrorsReused()
          Checks if the ControlFlowError is cached or a new one is used.
 boolean isDirtyCheckEnabled()
          Checks if dirty check is enabled on writes when a transaction commits.
 boolean isInterruptible()
          Checks if the Txn can be interrupted if it is blocking.
 boolean isReadonly()
          Checks if this Txn is readonly.
 boolean isReadTrackingEnabled()
          Checks if this transaction does automatic read tracking.
 boolean isSpeculative()
          Checks if speculative configuration is enabled.
 GammaTxnConfig setBackoffPolicy(BackoffPolicy backoffPolicy)
           
 GammaTxnConfig setBlockingAllowed(boolean blockingAllowed)
           
 GammaTxnConfig setControlFlowErrorsReused(boolean controlFlowErrorsReused)
           
 GammaTxnConfig setDirtyCheckEnabled(boolean dirtyCheck)
           
 GammaTxnConfig setFamilyName(String familyName)
           
 GammaTxnConfig setFat()
           
 GammaTxnConfig setInterruptible(boolean interruptible)
           
 GammaTxnConfig setIsolationLevel(IsolationLevel isolationLevel)
           
 GammaTxnConfig setMaximumPoorMansConflictScanLength(int maximumPoorMansConflictScanLength)
           
 GammaTxnConfig setMaxRetries(int maxRetries)
           
 GammaTxnConfig setPropagationLevel(PropagationLevel propagationLevel)
           
 GammaTxnConfig setReadLockMode(LockMode readLockMode)
           
 GammaTxnConfig setReadonly(boolean readonly)
           
 GammaTxnConfig setReadTrackingEnabled(boolean trackReads)
           
 GammaTxnConfig setSpeculative(boolean speculativeConfigEnabled)
           
 GammaTxnConfig setSpinCount(int spinCount)
           
 GammaTxnConfig setTimeoutNs(long timeoutNs)
           
 GammaTxnConfig setTraceLevel(TraceLevel traceLevel)
           
 GammaTxnConfig setWriteLockMode(LockMode writeLockMode)
           
 String toString()
           
 void updateSpeculativeConfigurationToUseCommute()
           
 void updateSpeculativeConfigurationToUseConstructedObjects()
           
 void updateSpeculativeConfigurationToUseEnsure()
           
 void updateSpeculativeConfigurationToUseExplicitLocking()
           
 void updateSpeculativeConfigurationToUseListeners()
           
 void updateSpeculativeConfigurationToUseMinimalTransactionLength(int newLength)
           
 void updateSpeculativeConfigurationToUseNonRefType()
           
 void updateSpeculativeConfigurationToUseRichMansConflictScan()
           
 void updateSpeculativeConfigureToUseAbortOnly()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

idGenerator

public static final AtomicLong idGenerator

speculativeConfiguration

public final AtomicReference<SpeculativeGammaConfiguration> speculativeConfiguration

stm

public final GammaStm stm

globalConflictCounter

public final GlobalConflictCounter globalConflictCounter

propagationLevel

public PropagationLevel propagationLevel

isolationLevel

public IsolationLevel isolationLevel

writeSkewAllowed

public boolean writeSkewAllowed

inconsistentReadAllowed

public boolean inconsistentReadAllowed

readLockMode

public LockMode readLockMode

writeLockMode

public LockMode writeLockMode

readLockModeAsInt

public int readLockModeAsInt

writeLockModeAsInt

public int writeLockModeAsInt

familyName

public String familyName

isAnonymous

public boolean isAnonymous

interruptible

public boolean interruptible

readonly

public boolean readonly

spinCount

public int spinCount

dirtyCheck

public boolean dirtyCheck

minimalArrayTreeSize

public int minimalArrayTreeSize

trackReads

public boolean trackReads

blockingAllowed

public boolean blockingAllowed

maxRetries

public int maxRetries

speculative

public boolean speculative

maxFixedLengthTransactionSize

public int maxFixedLengthTransactionSize

backoffPolicy

public BackoffPolicy backoffPolicy

timeoutNs

public long timeoutNs

traceLevel

public TraceLevel traceLevel

controlFlowErrorsReused

public boolean controlFlowErrorsReused

isFat

public boolean isFat

maximumPoorMansConflictScanLength

public int maximumPoorMansConflictScanLength

permanentListeners

public ArrayList<TxnListener> permanentListeners

unrepeatableReadAllowed

public boolean unrepeatableReadAllowed
Constructor Detail

GammaTxnConfig

public GammaTxnConfig(GammaStm stm)

GammaTxnConfig

public GammaTxnConfig(GammaStm stm,
                      GammaStmConfig config)

GammaTxnConfig

public GammaTxnConfig(GammaStm stm,
                      int maxFixedLengthTransactionSize)
Method Detail

getReadLockMode

public LockMode getReadLockMode()
Description copied from interface: TxnConfig
Gets the current LockMode for all reads.

Specified by:
getReadLockMode in interface TxnConfig
Returns:
the current LockMode for all reads.
See Also:
TxnFactoryBuilder.setReadLockMode(LockMode)

getWriteLockMode

public LockMode getWriteLockMode()
Description copied from interface: TxnConfig
Gets the current LockMode for all writes.

Specified by:
getWriteLockMode in interface TxnConfig
Returns:
the current LockMode for all writes.
See Also:
TxnFactoryBuilder.setWriteLockMode(LockMode)

getIsolationLevel

public IsolationLevel getIsolationLevel()
Description copied from interface: TxnConfig
Gets the IsolationLevel used. With the IsolationLevel you have control on the isolated behavior between transactions.

Specified by:
getIsolationLevel in interface TxnConfig
Returns:
the IsolationLevel.
See Also:
TxnFactoryBuilder.setIsolationLevel(IsolationLevel)

isControlFlowErrorsReused

public boolean isControlFlowErrorsReused()
Description copied from interface: TxnConfig
Checks if the ControlFlowError is cached or a new one is used.

Exception creation can be very expensive, so by default the ControlFlowError is reused, but this can be problematic when debugging.

Specified by:
isControlFlowErrorsReused in interface TxnConfig
Returns:
true if the ControlFlowError is reused.
See Also:
TxnFactoryBuilder.setControlFlowErrorsReused(boolean)

getSpeculativeConfiguration

public SpeculativeGammaConfiguration getSpeculativeConfiguration()

getTimeoutNs

public long getTimeoutNs()
Description copied from interface: TxnConfig
Returns the total timeout in nanoseconds. Long.MAX_VALUE indicates that there is no timeout.

Specified by:
getTimeoutNs in interface TxnConfig
Returns:
the total remaining timeout.
See Also:
TxnFactoryBuilder.setTimeoutNs(long)

getTraceLevel

public TraceLevel getTraceLevel()
Description copied from interface: TxnConfig
Returns the TraceLevel. With the TraceLevel you have control on the logging.

Specified by:
getTraceLevel in interface TxnConfig
Returns:
the TraceLevel.
See Also:
TxnFactoryBuilder.setTraceLevel(TraceLevel)

isInterruptible

public boolean isInterruptible()
Description copied from interface: TxnConfig
Checks if the Txn can be interrupted if it is blocking.

Specified by:
isInterruptible in interface TxnConfig
Returns:
true if the Txn can be interrupted if it is blocking, false otherwise.
See Also:
TxnFactoryBuilder.setInterruptible(boolean)

getBackoffPolicy

public BackoffPolicy getBackoffPolicy()
Description copied from interface: TxnConfig
Returns the BackoffPolicy used by the Stm when a transaction conflicts with another transaction.

Specified by:
getBackoffPolicy in interface TxnConfig
Returns:
the BackoffPolicy used.
See Also:
TxnFactoryBuilder.setBackoffPolicy(BackoffPolicy)

isSpeculative

public boolean isSpeculative()
Description copied from interface: TxnConfig
Checks if speculative configuration is enabled. When enabled the STM is able to select better performing/scalable implementations at the cost of some SpeculativeConfigurationError. This will be caught by the TxnExecutor and the transaction will be retried, so in most cases this is not something to worry about, but it can be confusing in the beginning because of unexpected failures in the execution of transactions.

Specified by:
isSpeculative in interface TxnConfig
Returns:
true if speculative configuration is enabled.
See Also:
TxnFactoryBuilder.setSpeculative(boolean)

getFamilyName

public String getFamilyName()
Description copied from interface: TxnConfig
Returns the family name of this Txn. Every transaction in principle should have a family name. This information can be used for debugging/logging purposes but also other techniques that rely to know something about similar types of transactions like profiling.

Specified by:
getFamilyName in interface TxnConfig
Returns:
the familyName. The returned value can be null.
See Also:
TxnFactoryBuilder.setFamilyName(String)

isReadonly

public boolean isReadonly()
Description copied from interface: TxnConfig
Checks if this Txn is readonly. With a readonly transaction you can prevent any updates or new objects being created.

Specified by:
isReadonly in interface TxnConfig
Returns:
true if readonly, false otherwise.
See Also:
TxnFactoryBuilder.setReadonly(boolean)

getSpinCount

public int getSpinCount()
Description copied from interface: TxnConfig
Returns the maximum number of times the transaction is allowed to spin on a read to become readable (perhaps it is locked).

Specified by:
getSpinCount in interface TxnConfig
Returns:
the maximum number of spins
See Also:
TxnFactoryBuilder.setSpinCount(int)

isDirtyCheckEnabled

public boolean isDirtyCheckEnabled()
Description copied from interface: TxnConfig
Checks if dirty check is enabled on writes when a transaction commits. Turning of saves time, but forces writes that cause no change.

Specified by:
isDirtyCheckEnabled in interface TxnConfig
Returns:
true of dirty check is enabled.
See Also:
TxnFactoryBuilder.setDirtyCheckEnabled(boolean)

getStm

public GammaStm getStm()
Description copied from interface: TxnConfig
Returns the Stm that creates transactions based on this configuration.

Specified by:
getStm in interface TxnConfig
Returns:
the stm.

getGlobalConflictCounter

public GlobalConflictCounter getGlobalConflictCounter()

isReadTrackingEnabled

public boolean isReadTrackingEnabled()
Description copied from interface: TxnConfig
Checks if this transaction does automatic read tracking. Read tracking is needed for blocking transactions, but also for writeskew detection. Disadvantage of read tracking is that it is more expensive because the reads not to be registered on some datastructure so that they are tracked.

Specified by:
isReadTrackingEnabled in interface TxnConfig
Returns:
true if the transaction does automatic read tracking, false otherwise.
See Also:
TxnFactoryBuilder.setReadTrackingEnabled(boolean)

isBlockingAllowed

public boolean isBlockingAllowed()
Description copied from interface: TxnConfig
If an explicit retry (so a blocking transaction) is allowed. With this property one can prevent that a Txn is able to block waiting for some change.

Specified by:
isBlockingAllowed in interface TxnConfig
Returns:
true if explicit retry is allowed, false otherwise.
See Also:
TxnFactoryBuilder.setBlockingAllowed(boolean)

getMaxRetries

public int getMaxRetries()
Description copied from interface: TxnConfig
Returns the maximum number of times this Txn be retried before failing. The returned value will always be equal or larger than 0. If the value is getAndSet high and you are encountering a lot of TooManyRetryExceptions it could be that the objects are just not concurrent enough.

Specified by:
getMaxRetries in interface TxnConfig
Returns:
the maxRetries.
See Also:
TxnFactoryBuilder.setMaxRetries(int)

getPropagationLevel

public PropagationLevel getPropagationLevel()
Description copied from interface: TxnConfig
Returns the PropagationLevel used. With the PropagationLevel you have control on how the transaction is dealing with nesting of transactions.

Specified by:
getPropagationLevel in interface TxnConfig
Returns:
the PropagationLevel used.
See Also:
TxnFactoryBuilder.setPropagationLevel(PropagationLevel)

getPermanentListeners

public List<TxnListener> getPermanentListeners()
Description copied from interface: TxnConfig
Returns an unmodifiable list containing all permanent TxnListener.

Specified by:
getPermanentListeners in interface TxnConfig
Returns:
unmodifiable List containing all permanent TxnListeners.
See Also:
TxnFactoryBuilder.addPermanentListener(org.multiverse.api.lifecycle.TxnListener)

updateSpeculativeConfigurationToUseNonRefType

public void updateSpeculativeConfigurationToUseNonRefType()

updateSpeculativeConfigurationToUseListeners

public void updateSpeculativeConfigurationToUseListeners()

updateSpeculativeConfigureToUseAbortOnly

public void updateSpeculativeConfigureToUseAbortOnly()

updateSpeculativeConfigurationToUseCommute

public void updateSpeculativeConfigurationToUseCommute()

updateSpeculativeConfigurationToUseExplicitLocking

public void updateSpeculativeConfigurationToUseExplicitLocking()

updateSpeculativeConfigurationToUseConstructedObjects

public void updateSpeculativeConfigurationToUseConstructedObjects()

updateSpeculativeConfigurationToUseRichMansConflictScan

public void updateSpeculativeConfigurationToUseRichMansConflictScan()

updateSpeculativeConfigurationToUseMinimalTransactionLength

public void updateSpeculativeConfigurationToUseMinimalTransactionLength(int newLength)

updateSpeculativeConfigurationToUseEnsure

public void updateSpeculativeConfigurationToUseEnsure()

init

public GammaTxnConfig init()

setTimeoutNs

public GammaTxnConfig setTimeoutNs(long timeoutNs)

setFamilyName

public GammaTxnConfig setFamilyName(String familyName)

setMaxRetries

public GammaTxnConfig setMaxRetries(int maxRetries)

setMaximumPoorMansConflictScanLength

public GammaTxnConfig setMaximumPoorMansConflictScanLength(int maximumPoorMansConflictScanLength)

setReadTrackingEnabled

public GammaTxnConfig setReadTrackingEnabled(boolean trackReads)

setSpeculative

public GammaTxnConfig setSpeculative(boolean speculativeConfigEnabled)

setReadonly

public GammaTxnConfig setReadonly(boolean readonly)

setDirtyCheckEnabled

public GammaTxnConfig setDirtyCheckEnabled(boolean dirtyCheck)

setBlockingAllowed

public GammaTxnConfig setBlockingAllowed(boolean blockingAllowed)

setInterruptible

public GammaTxnConfig setInterruptible(boolean interruptible)

setControlFlowErrorsReused

public GammaTxnConfig setControlFlowErrorsReused(boolean controlFlowErrorsReused)

setSpinCount

public GammaTxnConfig setSpinCount(int spinCount)

setBackoffPolicy

public GammaTxnConfig setBackoffPolicy(BackoffPolicy backoffPolicy)

setTraceLevel

public GammaTxnConfig setTraceLevel(TraceLevel traceLevel)

setPropagationLevel

public GammaTxnConfig setPropagationLevel(PropagationLevel propagationLevel)

setIsolationLevel

public GammaTxnConfig setIsolationLevel(IsolationLevel isolationLevel)

setWriteLockMode

public GammaTxnConfig setWriteLockMode(LockMode writeLockMode)

setReadLockMode

public GammaTxnConfig setReadLockMode(LockMode readLockMode)

setFat

public GammaTxnConfig setFat()

addPermanentListener

public GammaTxnConfig addPermanentListener(TxnListener listener)

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2012. All Rights Reserved.