Class GammaTxnConfig
java.lang.Object
org.multiverse.stms.gamma.transactions.GammaTxnConfig
- All Implemented Interfaces:
TxnConfig
,MultiverseConstants
,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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionboolean
boolean
boolean
final GlobalConflictCounter
static final AtomicLong
boolean
boolean
boolean
boolean
int
int
int
int
int
boolean
boolean
int
final GammaStm
long
boolean
boolean
int
boolean
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
ConstructorsModifierConstructorDescriptionGammaTxnConfig
(GammaStm stm) GammaTxnConfig
(GammaStm stm, int maxFixedLengthTransactionSize) GammaTxnConfig
(GammaStm stm, GammaStmConfig config) private
GammaTxnConfig
(GammaTxnConfig config) Makes a clone of the given GammaTxnConfig. -
Method Summary
Modifier and TypeMethodDescriptionaddPermanentListener
(TxnListener listener) Returns the BackoffPolicy used by the Stm when a transaction conflicts with another transaction.Returns the family name of this Txn.Gets the IsolationLevel used.int
Returns the maximum number of times this Txn be retried before failing.Returns an unmodifiable list containing all permanent TxnListener.Returns the PropagationLevel used.Gets the current LockMode for all reads.int
Returns the maximum number of times the transaction is allowed to spin on a read to become readable (perhaps it is locked).getStm()
Returns the Stm that creates transactions based on this configuration.long
Returns the total timeout in nanoseconds.Returns the TraceLevel.Gets the current LockMode for all writes.init()
boolean
If an explicit retry (so a blocking transaction) is allowed.boolean
Checks if theControlFlowError
is cached or a new one is used.boolean
Checks if dirty check is enabled on writes when a transaction commits.private boolean
isFat()
boolean
Checks if the Txn can be interrupted if it is blocking.boolean
Checks if this Txn is readonly.boolean
Checks if this transaction does automatic read tracking.boolean
Checks if speculative configuration is enabled.setBackoffPolicy
(BackoffPolicy backoffPolicy) setBlockingAllowed
(boolean blockingAllowed) setControlFlowErrorsReused
(boolean controlFlowErrorsReused) setDirtyCheckEnabled
(boolean dirtyCheck) setFamilyName
(String familyName) setFat()
setInterruptible
(boolean interruptible) setIsolationLevel
(IsolationLevel isolationLevel) setMaximumPoorMansConflictScanLength
(int maximumPoorMansConflictScanLength) setMaxRetries
(int maxRetries) setPropagationLevel
(PropagationLevel propagationLevel) setReadLockMode
(LockMode readLockMode) setReadonly
(boolean readonly) setReadTrackingEnabled
(boolean trackReads) setSpeculative
(boolean speculativeConfigEnabled) setSpinCount
(int spinCount) setTimeoutNs
(long timeoutNs) setTraceLevel
(TraceLevel traceLevel) setWriteLockMode
(LockMode writeLockMode) toString()
void
void
void
void
void
void
updateSpeculativeConfigurationToUseMinimalTransactionLength
(int newLength) void
void
void
-
Field Details
-
idGenerator
-
speculativeConfiguration
-
stm
-
globalConflictCounter
-
propagationLevel
-
isolationLevel
-
writeSkewAllowed
public boolean writeSkewAllowed -
inconsistentReadAllowed
public boolean inconsistentReadAllowed -
readLockMode
-
writeLockMode
-
readLockModeAsInt
public int readLockModeAsInt -
writeLockModeAsInt
public int writeLockModeAsInt -
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
-
timeoutNs
public long timeoutNs -
traceLevel
-
controlFlowErrorsReused
public boolean controlFlowErrorsReused -
isFat
public boolean isFat -
maximumPoorMansConflictScanLength
public int maximumPoorMansConflictScanLength -
permanentListeners
-
unrepeatableReadAllowed
public boolean unrepeatableReadAllowed
-
-
Constructor Details
-
GammaTxnConfig
-
GammaTxnConfig
-
GammaTxnConfig
Makes a clone of the given GammaTxnConfig.- Parameters:
config
- the GammaTxnConfig to clone.
-
GammaTxnConfig
-
-
Method Details
-
getReadLockMode
Description copied from interface:TxnConfig
Gets the current LockMode for all reads.- Specified by:
getReadLockMode
in interfaceTxnConfig
- Returns:
- the current LockMode for all reads.
- See Also:
-
getWriteLockMode
Description copied from interface:TxnConfig
Gets the current LockMode for all writes.- Specified by:
getWriteLockMode
in interfaceTxnConfig
- Returns:
- the current LockMode for all writes.
- See Also:
-
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 interfaceTxnConfig
- Returns:
- the IsolationLevel.
- See Also:
-
isControlFlowErrorsReused
public boolean isControlFlowErrorsReused()Description copied from interface:TxnConfig
Checks if theControlFlowError
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 interfaceTxnConfig
- Returns:
- true if the ControlFlowError is reused.
- See Also:
-
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 interfaceTxnConfig
- Returns:
- the total remaining timeout.
- See Also:
-
getTraceLevel
Description copied from interface:TxnConfig
Returns the TraceLevel. With the TraceLevel you have control on the logging.- Specified by:
getTraceLevel
in interfaceTxnConfig
- Returns:
- the TraceLevel.
- See Also:
-
isInterruptible
public boolean isInterruptible()Description copied from interface:TxnConfig
Checks if the Txn can be interrupted if it is blocking.- Specified by:
isInterruptible
in interfaceTxnConfig
- Returns:
- true if the Txn can be interrupted if it is blocking, false otherwise.
- See Also:
-
getBackoffPolicy
Description copied from interface:TxnConfig
Returns the BackoffPolicy used by the Stm when a transaction conflicts with another transaction.- Specified by:
getBackoffPolicy
in interfaceTxnConfig
- Returns:
- the BackoffPolicy used.
- See Also:
-
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 someSpeculativeConfigurationError
. 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 interfaceTxnConfig
- Returns:
- true if speculative configuration is enabled.
- See Also:
-
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 interfaceTxnConfig
- Returns:
- the familyName. The returned value can be null.
- See Also:
-
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 interfaceTxnConfig
- Returns:
- true if readonly, false otherwise.
- See Also:
-
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 interfaceTxnConfig
- Returns:
- the maximum number of spins
- See Also:
-
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 interfaceTxnConfig
- Returns:
- true of dirty check is enabled.
- See Also:
-
getStm
Description copied from interface:TxnConfig
Returns the Stm that creates transactions based on this configuration. -
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 interfaceTxnConfig
- Returns:
- true if the transaction does automatic read tracking, false otherwise.
- See Also:
-
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 interfaceTxnConfig
- Returns:
- true if explicit retry is allowed, false otherwise.
- See Also:
-
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 interfaceTxnConfig
- Returns:
- the maxRetries.
- See Also:
-
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 interfaceTxnConfig
- Returns:
- the PropagationLevel used.
- See Also:
-
getPermanentListeners
Description copied from interface:TxnConfig
Returns an unmodifiable list containing all permanent TxnListener.- Specified by:
getPermanentListeners
in interfaceTxnConfig
- Returns:
- unmodifiable List containing all permanent TxnListeners.
- See Also:
-
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
-
isFat
private boolean isFat() -
setTimeoutNs
-
setFamilyName
-
setMaxRetries
-
setMaximumPoorMansConflictScanLength
-
setReadTrackingEnabled
-
setSpeculative
-
setReadonly
-
setDirtyCheckEnabled
-
setBlockingAllowed
-
setInterruptible
-
setControlFlowErrorsReused
-
setSpinCount
-
setBackoffPolicy
-
setTraceLevel
-
setPropagationLevel
-
setIsolationLevel
-
setWriteLockMode
-
setReadLockMode
-
setFat
-
addPermanentListener
-
toString
-