org.multiverse.stms.alpha.transactions.readonly
Class NonTrackingReadonlyAlphaTransaction

java.lang.Object
  extended by org.multiverse.stms.AbstractTransaction<C,S>
      extended by org.multiverse.stms.alpha.transactions.AbstractAlphaTransaction<ReadonlyConfiguration,org.multiverse.stms.AbstractTransactionSnapshot>
          extended by org.multiverse.stms.alpha.transactions.readonly.AbstractReadonlyAlphaTransaction
              extended by org.multiverse.stms.alpha.transactions.readonly.NonTrackingReadonlyAlphaTransaction
All Implemented Interfaces:
org.multiverse.api.Transaction, org.multiverse.MultiverseConstants, AlphaTransaction

public class NonTrackingReadonlyAlphaTransaction
extends AbstractReadonlyAlphaTransaction

A readonly AlphaTransaction implementation that doesn't track reads.

Unlike the MapUpdateAlphaTransaction a readonly transaction doesn't need track any reads done. This has the advantage that a readonly transaction consumes a lot less resources (so no collection needed to track all the reads) and commits are also a lot quicker (no dirtyness checking).

A disadvantage of not tracking reads, is that the retry/orelse functionality is not available in reaodnly transactions because the transaction has no clue which objects were loaded. So it also has no clue about the objects to listen to on a retry.

Although readonly transactions are isolated from update transactions from a correctness point of view, from a practical point of view a readonly transaction could be obstructed by an update transaction:

in the following scenario, the second load will fail with a LoadTooOldVersionException:

 T1 (ro): |load_X-----------------load_X|
 T2 (up):         |write_X|
 
In the future a version history will be added for previous committed data. So the chance that a old version is not available is going to decrease.

Author:
Peter Veentjer.

Nested Class Summary
static class NonTrackingReadonlyAlphaTransaction.Factory
           
 
Field Summary
 
Fields inherited from class org.multiverse.stms.AbstractTransaction
config
 
Fields inherited from interface org.multiverse.MultiverseConstants
___SANITY_CHECKS_ENABLED
 
Constructor Summary
NonTrackingReadonlyAlphaTransaction(ReadonlyConfiguration config)
           
 
Method Summary
protected  void attach(AlphaTranlocal tranlocal)
           
protected  boolean dodoRegisterRetryLatch(org.multiverse.api.latches.Latch latch, long wakeupVersion)
           
protected  AlphaTranlocal findAttached(AlphaTransactionalObject txObject)
           
 
Methods inherited from class org.multiverse.stms.alpha.transactions.readonly.AbstractReadonlyAlphaTransaction
createLoadUncommittedException, doOpenForCommutingWrite, doOpenForConstruction, doOpenForRead, doOpenForWrite
 
Methods inherited from class org.multiverse.stms.alpha.transactions.AbstractAlphaTransaction
doRegisterRetryLatch, load, openForCommutingWrite, openForConstruction, openForRead, openForWrite
 
Methods inherited from class org.multiverse.stms.AbstractTransaction
abort, commit, doAbortActive, doAbortPrepared, doClear, doInit, doPrepare, endOr, endOrAndStartElse, getAttempt, getConfiguration, getReadVersion, getRemainingTimeoutNs, getSnapshot, getStatus, init, makeChangesPermanent, prepare, registerLifecycleListener, registerRetryLatch, restart, setAttempt, setRemainingTimeoutNs, startOr, storeSnapshot, takeSnapshot
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.multiverse.api.Transaction
abort, commit, getAttempt, getConfiguration, getReadVersion, getRemainingTimeoutNs, getStatus, prepare, registerLifecycleListener, registerRetryLatch, restart, setAttempt, setRemainingTimeoutNs
 

Constructor Detail

NonTrackingReadonlyAlphaTransaction

public NonTrackingReadonlyAlphaTransaction(ReadonlyConfiguration config)
Method Detail

dodoRegisterRetryLatch

protected boolean dodoRegisterRetryLatch(org.multiverse.api.latches.Latch latch,
                                         long wakeupVersion)
Specified by:
dodoRegisterRetryLatch in class AbstractAlphaTransaction<ReadonlyConfiguration,org.multiverse.stms.AbstractTransactionSnapshot>

findAttached

protected AlphaTranlocal findAttached(AlphaTransactionalObject txObject)
Specified by:
findAttached in class AbstractReadonlyAlphaTransaction

attach

protected void attach(AlphaTranlocal tranlocal)
Specified by:
attach in class AbstractReadonlyAlphaTransaction


Copyright © 2008-2010 Multiverse. All Rights Reserved.