org.multiverse.stms
Class AbstractTransactionConfiguration

java.lang.Object
  extended by org.multiverse.stms.AbstractTransactionConfiguration
All Implemented Interfaces:
TransactionConfiguration

public class AbstractTransactionConfiguration
extends java.lang.Object
implements TransactionConfiguration

Contains the configuration for the AbstractTransaction.

One advantage of this class is that it is a lot easier to add additional fields without having to change all constructors. It also reduces the need for constructors with a lot of arguments.`

Author:
Peter Veentjer.

Field Summary
 BackoffPolicy backoffPolicy
           
 PrimitiveClock clock
           
 boolean explicitRetryAllowed
           
 java.lang.String familyName
           
 boolean interruptible
           
 int maxReadSpinCount
           
 int maxRetries
           
 boolean readOnly
           
 boolean readTrackingEnabled
           
 long timeoutNs
           
 boolean writeSkewAllowed
           
 
Constructor Summary
AbstractTransactionConfiguration()
          This method should be removed, only used for testing purposes.
AbstractTransactionConfiguration(PrimitiveClock clock, BackoffPolicy backoffPolicy, java.lang.String familyName, boolean readOnly, int maxRetries, boolean interruptible, boolean writeSkewAllowed, boolean readTrackingEnabled, boolean explicitRetryAllowed, long timeoutNs, int maxReadSpinCount)
           
 
Method Summary
 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 Transaction.
 int getMaxRetries()
          Returns the maximum number of times this Transaction be retried before failing.
 long getTimeoutNs()
          Returns the total timeout in nanoseconds.
 boolean isExplicitRetryAllowed()
          If an explicit retry (so a blocking transaction) is allowed.
 boolean isInterruptible()
          Checks if the Transaction can be interrupted if it is blocking.
 boolean isReadonly()
          Checks if this Transaction is readonly.
 boolean isReadTrackingEnabled()
          Checks if this transaction does automatic read tracking.
 boolean isWriteSkewAllowed()
          Checks if this Transaction allows writeskew.
 int maxReadSpinCount()
          Returns the maximum number of times the transaction is allowed to spin on a read to become readable (perhaps it is locked).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

clock

public final PrimitiveClock clock

backoffPolicy

public final BackoffPolicy backoffPolicy

familyName

public final java.lang.String familyName

readOnly

public final boolean readOnly

maxRetries

public final int maxRetries

interruptible

public final boolean interruptible

writeSkewAllowed

public final boolean writeSkewAllowed

readTrackingEnabled

public final boolean readTrackingEnabled

timeoutNs

public final long timeoutNs

explicitRetryAllowed

public final boolean explicitRetryAllowed

maxReadSpinCount

public final int maxReadSpinCount
Constructor Detail

AbstractTransactionConfiguration

public AbstractTransactionConfiguration()
This method should be removed, only used for testing purposes.


AbstractTransactionConfiguration

public AbstractTransactionConfiguration(PrimitiveClock clock,
                                        BackoffPolicy backoffPolicy,
                                        java.lang.String familyName,
                                        boolean readOnly,
                                        int maxRetries,
                                        boolean interruptible,
                                        boolean writeSkewAllowed,
                                        boolean readTrackingEnabled,
                                        boolean explicitRetryAllowed,
                                        long timeoutNs,
                                        int maxReadSpinCount)
Method Detail

maxReadSpinCount

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

Specified by:
maxReadSpinCount in interface TransactionConfiguration
Returns:
the maximum number of spins

isExplicitRetryAllowed

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

Specified by:
isExplicitRetryAllowed in interface TransactionConfiguration
Returns:
true if explicit retry is allowed, false otherwise.
See Also:
TransactionFactoryBuilder.setExplicitRetryAllowed(boolean)

getFamilyName

public final java.lang.String getFamilyName()
Description copied from interface: TransactionConfiguration
Returns the family name of this Transaction. 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 TransactionConfiguration
Returns:
the familyName. The returned value can be null.
See Also:
TransactionFactoryBuilder.setFamilyName(String)

getMaxRetries

public final int getMaxRetries()
Description copied from interface: TransactionConfiguration
Returns the maximum number of times this Transaction be retried before failing. The returned value will always be equal or larger than 0. If the value is set 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 TransactionConfiguration
Returns:
the maxRetries.
See Also:
TransactionFactoryBuilder.setMaxRetries(int)

isInterruptible

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

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

isReadonly

public final boolean isReadonly()
Description copied from interface: TransactionConfiguration
Checks if this Transaction is readonly.

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

isWriteSkewAllowed

public final boolean isWriteSkewAllowed()
Description copied from interface: TransactionConfiguration
Checks if this Transaction allows writeskew. This is an isolation anomaly and could lead to an execution of transactions that doesn't match any sequential execution. Writeskew detection can be expensive because more checks needs to be done. It also leads to lower concurrency because certain executions of transactions are not allowed and are aborted and retried.

If the transaction is readonly, the value is undefined since a readonly transaction can't suffer from the writeskew problem.

Specified by:
isWriteSkewAllowed in interface TransactionConfiguration
Returns:
true if the writeskew problem is allowed, false otherwise.
See Also:
TransactionFactoryBuilder.setWriteSkewAllowed(boolean)

isReadTrackingEnabled

public final boolean isReadTrackingEnabled()
Description copied from interface: TransactionConfiguration
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 TransactionConfiguration
Returns:
true if the transaction does automatic read tracking, false otherwise.
See Also:
TransactionFactoryBuilder.setReadTrackingEnabled(boolean)

getBackoffPolicy

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

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

getTimeoutNs

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

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


Copyright © 2008-2010 Multiverse. All Rights Reserved.