org.multiverse.api

## Interface TxnConfig

All Known Implementing Classes:
  GammaTxnConfig

    public interface TxnConfig

Contains the transaction configuration used by a `Txn`. In the beginning this was all placed in the Txn, adding a lot of 'informational' methods to the transaction and therefor complicating its usage. So all the configurational properties of the transaction are contained in this structure.

The same TxnConfig is used for multiple transactions. Each TxnFactory has just a single configuration and all Transactions created by that TxnFactory, share that configuration.

### Method Summary

Methods
`BackoffPolicy` `getBackoffPolicy()` Returns the BackoffPolicy used by the Stm when a transaction conflicts with another transaction.
`java.lang.String` `getFamilyName()` Returns the family name of this Txn.
`IsolationLevel` `getIsolationLevel()` Gets the IsolationLevel used.
`int` `getMaxRetries()` Returns the maximum number of times this Txn be retried before failing.
`java.util.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.
`int` `getSpinCount()` Returns the maximum number of times the transaction is allowed to spin on a read to become readable (perhaps it is locked).
`Stm` `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.
`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.

### Method Detail

#### getStm

    Stm getStm()

Returns the Stm that creates transactions based on this configuration.

Returns:
  the stm.

#### isControlFlowErrorsReused

    boolean isControlFlowErrorsReused()

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.

Returns:
  true if the ControlFlowError is reused.
See Also:
  `TxnFactoryBuilder.setControlFlowErrorsReused(boolean)`

#### getIsolationLevel

    IsolationLevel getIsolationLevel()

Gets the IsolationLevel used. With the IsolationLevel you have control on the isolated behavior between transactions.

Returns:
  the IsolationLevel.
See Also:
  `TxnFactoryBuilder.setIsolationLevel(IsolationLevel)`

#### getTimeoutNs

    long getTimeoutNs()

Returns the total timeout in nanoseconds. Long.MAX_VALUE indicates that there is no timeout.

Returns:
  the total remaining timeout.
See Also:
  `TxnFactoryBuilder.setTimeoutNs(long)`

#### getPropagationLevel

    PropagationLevel getPropagationLevel()

Returns the PropagationLevel used. With the PropagationLevel you have control on how the transaction is dealing with nesting of transactions.

Returns:
  the PropagationLevel used.
See Also:
  `TxnFactoryBuilder.setPropagationLevel(PropagationLevel)`

#### getTraceLevel

    TraceLevel getTraceLevel()

Returns the TraceLevel. With the TraceLevel you have control on the logging.

Returns:
  the TraceLevel.
See Also:
  `TxnFactoryBuilder.setTraceLevel(TraceLevel)`

#### getBackoffPolicy

    BackoffPolicy getBackoffPolicy()

Returns the BackoffPolicy used by the Stm when a transaction conflicts with another transaction.

Returns:
  the BackoffPolicy used.
See Also:
  `TxnFactoryBuilder.setBackoffPolicy(BackoffPolicy)`

#### isSpeculative

    boolean isSpeculative()

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.

Returns:
  true if speculative configuration is enabled.
See Also:
  `TxnFactoryBuilder.setSpeculative(boolean)`

#### getFamilyName

    java.lang.String getFamilyName()

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.

Returns:
  the familyName. The returned value can be null.
See Also:
  `TxnFactoryBuilder.setFamilyName(String)`

#### isReadonly

    boolean isReadonly()

Checks if this Txn is readonly. With a readonly transaction you can prevent any updates or new objects being created.

Returns:
  true if readonly, false otherwise.
See Also:
  `TxnFactoryBuilder.setReadonly(boolean)`

#### getSpinCount

    int getSpinCount()

Returns the maximum number of times the transaction is allowed to spin on a read to become readable (perhaps it is locked).

Returns:
  the maximum number of spins
See Also:
  `TxnFactoryBuilder.setSpinCount(int)`

#### getReadLockMode

    LockMode getReadLockMode()

Gets the current LockMode for all reads.

Returns:
  the current LockMode for all reads.
See Also:
  `TxnFactoryBuilder.setReadLockMode(LockMode)`

#### getWriteLockMode

    LockMode getWriteLockMode()

Gets the current LockMode for all writes.

Returns:
  the current LockMode for all writes.
See Also:
  `TxnFactoryBuilder.setWriteLockMode(LockMode)`

#### isDirtyCheckEnabled

    boolean isDirtyCheckEnabled()

Checks if dirty check is enabled on writes when a transaction commits. Turning of saves time, but forces writes that cause no change.

Returns:
  true of dirty check is enabled.
See Also:
  `TxnFactoryBuilder.setDirtyCheckEnabled(boolean)`

#### isReadTrackingEnabled

    boolean isReadTrackingEnabled()

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.

Returns:
  true if the transaction does automatic read tracking, false otherwise.
See Also:
  `TxnFactoryBuilder.setReadTrackingEnabled(boolean)`

#### isBlockingAllowed

    boolean isBlockingAllowed()

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.

Returns:
  true if explicit retry is allowed, false otherwise.
See Also:
  `TxnFactoryBuilder.setBlockingAllowed(boolean)`

#### isInterruptible

    boolean isInterruptible()

Checks if the Txn can be interrupted if it is blocking.

Returns:
  true if the Txn can be interrupted if it is blocking, false otherwise.
See Also:
  `TxnFactoryBuilder.setInterruptible(boolean)`

#### getPermanentListeners

    java.util.List<TxnListener> getPermanentListeners()

Returns an unmodifiable list containing all permanent TxnListener.

Returns:
  unmodifiable List containing all permanent TxnListeners.
See Also:
  `TxnFactoryBuilder.addPermanentListener(org.multiverse.api.lifecycle.TxnListener)`

#### getMaxRetries

    int getMaxRetries()

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.

Returns:
  the maxRetries.
See Also:
  `TxnFactoryBuilder.setMaxRetries(int)`