Interface GammaTxnFactoryBuilder
- All Superinterfaces:
TxnFactoryBuilder
- All Known Implementing Classes:
GammaStm.GammaTxnFactoryBuilderImpl
TxnFactoryBuilder
tailored for the GammaStm
.-
Method Summary
Modifier and TypeMethodDescriptionaddPermanentListener
(TxnListener listener) Adds a permanentTxn
TxnListener
.Returns theTxnConfig
used by this TxnFactoryBuilder.Builds a newTxnFactory
.Builds a newTxnExecutor
optimized for executing transactions created by this TxnFactoryBuilder.setBackoffPolicy
(BackoffPolicy backoffPolicy) Sets theTxn
BackoffPolicy
.setBlockingAllowed
(boolean blockingAllowed) Sets if theTxn
is allowed to do an explicit retry (needed for a blocking operation).setControlFlowErrorsReused
(boolean reused) Sets if theControlFlowError
is reused.setDirtyCheckEnabled
(boolean dirtyCheckEnabled) Sets if theTxn
dirty check is enabled.setFamilyName
(String familyName) Sets theTxn
familyname.setFat()
setInterruptible
(boolean interruptible) Sets if theTxn
can be interrupted while doing blocking operations.setIsolationLevel
(IsolationLevel isolationLevel) Sets theIsolationLevel
on theTxn
.setMaxRetries
(int maxRetries) Sets the the maximum count aTxn
can be retried.setPropagationLevel
(PropagationLevel propagationLevel) Sets thePropagationLevel
used.setReadLockMode
(LockMode lockMode) setReadonly
(boolean readonly) Sets the readonly property on aTxn
.setReadTrackingEnabled
(boolean enabled) Sets if theTxn
should automatically track all reads that have been done.setSpeculative
(boolean enabled) setSpinCount
(int spinCount) Sets the maximum number of spins that are allowed when aTxn
can't be read/written/locked because it is locked by another transaction.setTimeoutNs
(long timeoutNs) Sets the timeout (the maximum time aTxn
is allowed to block.setTraceLevel
(TraceLevel traceLevel) Sets theTxn
TraceLevel
.setWriteLockMode
(LockMode lockMode)
-
Method Details
-
getConfig
GammaTxnConfig getConfig()Description copied from interface:TxnFactoryBuilder
Returns theTxnConfig
used by this TxnFactoryBuilder.- Specified by:
getConfig
in interfaceTxnFactoryBuilder
- Returns:
- the used TxnConfig.
-
setFat
GammaTxnFactoryBuilder setFat() -
setControlFlowErrorsReused
Description copied from interface:TxnFactoryBuilder
Sets if theControlFlowError
is reused. Normally you don't want to reuse them because they can be expensive to create (especially the stacktrace) and they could be created very often. But for debugging purposes it can be quite annoying because you want to see the stacktrace.- Specified by:
setControlFlowErrorsReused
in interfaceTxnFactoryBuilder
- Parameters:
reused
- true if ControlFlowErrors should be reused.- Returns:
- the updated TxnFactoryBuilder.
- See Also:
-
setReadLockMode
Description copied from interface:TxnFactoryBuilder
Sets theTxn
LockMode
for all reads. If a LockMode is set higher thanLockMode.None
, this transaction will locks all reads (and writes since a read is needed for a write) and the transaction automatically becomes serialized.- Specified by:
setReadLockMode
in interfaceTxnFactoryBuilder
- Parameters:
lockMode
- the LockMode to set.- Returns:
- the updated TxnFactoryBuilder.
- See Also:
-
setWriteLockMode
Description copied from interface:TxnFactoryBuilder
Sets theTxn
LockMode
for all writes. For a write, always a read needs to be done, so if the read LockMode isFreshly constructed objects that are not committed, automatically are locked with
LockMode.Exclusive
.If the write LockMode is set after the read LockMode and the write LockMode is lower than the read LockMode, an
IllegalTxnFactoryException
will be thrown when aTxnFactory
is created.If the write LockMode is set before the read LockMode and the write LockMode is lower than the read LockMode, the write LockMode automatically is upgraded to that of the read LockMode. This makes setting the readLock mode less of a nuisance.
- Specified by:
setWriteLockMode
in interfaceTxnFactoryBuilder
- Parameters:
lockMode
- the LockMode to set.- Returns:
- the updated TxnFactoryBuilder.
- See Also:
-
setFamilyName
Description copied from interface:TxnFactoryBuilder
Sets theTxn
familyname. If anTxnExecutor
is used inside a method, a useful familyname could be the full name of the class and the method. The transaction familyName is useful debugging purposes, but has not other meaning.- Specified by:
setFamilyName
in interfaceTxnFactoryBuilder
- Parameters:
familyName
- the familyName of the transaction.- Returns:
- the updated TxnFactoryBuilder
- See Also:
-
setPropagationLevel
Description copied from interface:TxnFactoryBuilder
Sets thePropagationLevel
used. With the PropagationLevel you have control on how the transaction deals with transaction nesting. The default isPropagationLevel.Requires
which automatically starts a transaction is one is missing, or lifts on a transaction if available.- Specified by:
setPropagationLevel
in interfaceTxnFactoryBuilder
- Parameters:
propagationLevel
- the new PropagationLevel- Returns:
- the updated TxnFactoryBuilder
- See Also:
-
addPermanentListener
Description copied from interface:TxnFactoryBuilder
Adds a permanentTxn
TxnListener
. All permanent listeners are always executed after all normal listeners are executed. If the same listener is added multiple times, it will be executed multiple times.This method is very useful for integrating Multiverse in other JVM based environments because with this approach you have a callback when transaction aborts/commit and can add your own logic. See the
TxnListener
for more information about normal vs permanent listeners.- Specified by:
addPermanentListener
in interfaceTxnFactoryBuilder
- Parameters:
listener
- the permanent listener to add.- Returns:
- the updated TxnFactoryBuilder.
- See Also:
-
setTraceLevel
Description copied from interface:TxnFactoryBuilder
Sets theTxn
TraceLevel
. With tracing it is possible to see what is happening inside a transaction.- Specified by:
setTraceLevel
in interfaceTxnFactoryBuilder
- Parameters:
traceLevel
- the new traceLevel.- Returns:
- the updated TxnFactoryBuilder.
- See Also:
-
setTimeoutNs
Description copied from interface:TxnFactoryBuilder
Sets the timeout (the maximum time aTxn
is allowed to block. Long.MAX_VALUE indicates that an unbound timeout should be used.- Specified by:
setTimeoutNs
in interfaceTxnFactoryBuilder
- Parameters:
timeoutNs
- the timeout specified in nano seconds- Returns:
- the updated TxnFactoryBuilder
- See Also:
-
setInterruptible
Description copied from interface:TxnFactoryBuilder
Sets if theTxn
can be interrupted while doing blocking operations.- Specified by:
setInterruptible
in interfaceTxnFactoryBuilder
- Parameters:
interruptible
- if the transaction can be interrupted while doing blocking operations.- Returns:
- the updated TxnFactoryBuilder
- See Also:
-
setBackoffPolicy
Description copied from interface:TxnFactoryBuilder
Sets theTxn
BackoffPolicy
. Policy is used to backoff when a transaction conflicts with anotherTxn
. See theBackoffPolicy
for more information.- Specified by:
setBackoffPolicy
in interfaceTxnFactoryBuilder
- Parameters:
backoffPolicy
- the backoff policy to use.- Returns:
- the updated TxnFactoryBuilder
- See Also:
-
setDirtyCheckEnabled
Description copied from interface:TxnFactoryBuilder
Sets if theTxn
dirty check is enabled. Dirty check is that something only needs to be written, if there really is a change (else it will be interpreted as a read). If it is disabled, it will always write, and this could prevent the aba isolation anomaly, but causes more conflicts so more contention. In most cases enabling it is the best option.- Specified by:
setDirtyCheckEnabled
in interfaceTxnFactoryBuilder
- Parameters:
dirtyCheckEnabled
- true if dirty check should be executed, false otherwise.- Returns:
- the updated TxnFactoryBuilder.
- See Also:
-
setSpinCount
Description copied from interface:TxnFactoryBuilder
Sets the maximum number of spins that are allowed when aTxn
can't be read/written/locked because it is locked by another transaction.Setting the value to a very high value, could lead to more an increased chance of a live locking.
- Specified by:
setSpinCount
in interfaceTxnFactoryBuilder
- Parameters:
spinCount
- the maximum number of spins- Returns:
- the updated TxnFactoryBuilder.
- See Also:
-
setReadonly
Description copied from interface:TxnFactoryBuilder
Sets the readonly property on aTxn
. If a transaction is configured as readonly, no write operations (also no construction of new transactional objects making use of that transaction) is allowed- Specified by:
setReadonly
in interfaceTxnFactoryBuilder
- Parameters:
readonly
- true if the transaction should be readonly, false otherwise.- Returns:
- the updated TxnFactoryBuilder
- See Also:
-
setReadTrackingEnabled
Description copied from interface:TxnFactoryBuilder
Sets if theTxn
should automatically track all reads that have been done. This is needed for blocking operations, but also for other features like writeskew detection.Tracking reads puts more pressure on the transaction since it needs to store all reads, but it reduces the chance of read conflicts, since once read from main memory, it can be retrieved from the transaction. The transaction is free to track reads even though this property is disabled.
- Specified by:
setReadTrackingEnabled
in interfaceTxnFactoryBuilder
- Parameters:
enabled
- true if read tracking enabled, false otherwise.- Returns:
- the updated TxnFactoryBuilder
- See Also:
-
setSpeculative
Description copied from interface:TxnFactoryBuilder
With the speculative configuration enabled, theStm
is allowed to determine optimal settings for aTxn
.Some behavior like readonly or the need for tracking reads can be determined runtime. The system can start with a readonly non readtracking transaction and upgrade to an update or a read tracking once a write or retry happens.
It depends on the
Stm
implementation on which properties it is going to speculate.Enabling it can cause a few unexpected 'retries' of transactions, but it can seriously improve performance.
- Specified by:
setSpeculative
in interfaceTxnFactoryBuilder
- Parameters:
enabled
- indicates if speculative configuration should be enabled.- Returns:
- the updated TxnFactoryBuilder
- See Also:
-
setMaxRetries
Description copied from interface:TxnFactoryBuilder
Sets the the maximum count aTxn
can be retried. The default is 1000. Setting it to a very low value could mean that a transaction can't complete. Setting it to a very high value could lead to live-locking.If the speculative configuration mechanism is enabled (
TxnFactoryBuilder.setSpeculative(boolean)
), a few retries are done in the beginning to figure out the best settings.- Specified by:
setMaxRetries
in interfaceTxnFactoryBuilder
- Parameters:
maxRetries
- the maximum number of times a transaction can be tried.- Returns:
- the updated TxnFactoryBuilder
- See Also:
-
setIsolationLevel
Description copied from interface:TxnFactoryBuilder
Sets theIsolationLevel
on theTxn
.The
Txn
is free to upgraded to a higherIsolationLevel
. This is essentially the same behavior you get when Oracle is used, where a read uncommitted is upgraded to a read committed and a repeatable read is upgraded to the Oracle version of serialized (so with the writeskew problem still there).- Specified by:
setIsolationLevel
in interfaceTxnFactoryBuilder
- Parameters:
isolationLevel
- the new IsolationLevel- Returns:
- the updated TxnFactoryBuilder
- See Also:
-
setBlockingAllowed
Description copied from interface:TxnFactoryBuilder
Sets if theTxn
is allowed to do an explicit retry (needed for a blocking operation). One use case for disallowing it, it when the transaction is used inside an actor, and you don't want that inside the logic executed by the agent a blocking operations is done (e.g. taking an item of a blocking queue).- Specified by:
setBlockingAllowed
in interfaceTxnFactoryBuilder
- Parameters:
blockingAllowed
- true if explicit retry is allowed, false otherwise.- Returns:
- the updated TxnFactoryBuilder
-
newTransactionFactory
GammaTxnFactory newTransactionFactory()Description copied from interface:TxnFactoryBuilder
Builds a newTxnFactory
.- Specified by:
newTransactionFactory
in interfaceTxnFactoryBuilder
- Returns:
- the build TxnFactory.
-
newTxnExecutor
GammaTxnExecutor newTxnExecutor()Description copied from interface:TxnFactoryBuilder
Builds a newTxnExecutor
optimized for executing transactions created by this TxnFactoryBuilder.- Specified by:
newTxnExecutor
in interfaceTxnFactoryBuilder
- Returns:
- the created TxnExecutor.
-