com.sleepycat.je.txn
Class TxnManager

java.lang.Object
  extended by com.sleepycat.je.txn.TxnManager

public class TxnManager
extends Object

Class to manage transactions. Basically a Set of all transactions with add and remove methods and a latch around the set.


Field Summary
(package private) static long NULL_TXN_ID
           
 
Constructor Summary
TxnManager(EnvironmentImpl envImpl)
           
 
Method Summary
 boolean areOtherSerializableTransactionsActive(Locker excludeLocker)
          Returns whether there are any active serializable transactions, excluding the transaction given (if non-null).
 long getFirstActiveLsn()
          Get the earliest LSN of all the active transactions, for checkpoint.
 long getLastLocalTxnId()
          Get the last used id, for checkpoint info.
 long getLastReplicatedTxnId()
           
 LockManager getLockManager()
          Give transactions and environment access to lock manager.
 long getNextReplicatedTxnId()
           
(package private)  long getNextTxnId()
          Get the next transaction id for a non-replicated transaction.
 Transaction getTxnForThread()
          Retrieve a Txn object for this Thread.
 Txn getTxnFromXid(Xid xid)
          Retrieve a Txn object from an Xid.
static boolean isReplicatedTxn(long txnId)
           
 StatGroup loadStats(StatsConfig config)
           
 LockStats lockStat(StatsConfig config)
          Collect lock related stats.
 void notePrepare()
          Called when XATransaction is prepared.
(package private)  void registerTxn(Txn txn)
          Called when txn is created.
 void registerXATxn(Xid xid, Txn txn, boolean isPrepare)
          Called when txn is created.
 void setLastTxnId(long lastReplicatedTxnId, long lastLocalId)
          Set the txn id sequence.
 void setTxnForThread(Transaction txn)
          Called when txn is assoc'd with this thread.
 Txn txnBegin(Transaction parent, TransactionConfig txnConfig)
          Create a new transaction.
 TransactionStats txnStat(StatsConfig config)
          Collect transaction related stats.
(package private)  void unRegisterTxn(Txn txn, boolean isCommit)
          Called when txn ends.
(package private)  void unRegisterXATxn(Xid xid, boolean isCommit)
          Called when txn ends.
 Transaction unsetTxnForThread()
          Called when txn is assoc'd with this thread.
 void updateFromReplay(long replayTxnId)
           
 Xid[] XARecover()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL_TXN_ID

static final long NULL_TXN_ID
See Also:
Constant Field Values
Constructor Detail

TxnManager

public TxnManager(EnvironmentImpl envImpl)
Method Detail

setLastTxnId

public void setLastTxnId(long lastReplicatedTxnId,
                         long lastLocalId)
Set the txn id sequence.


getLastLocalTxnId

public long getLastLocalTxnId()
Get the last used id, for checkpoint info.


getLastReplicatedTxnId

public long getLastReplicatedTxnId()

getNextReplicatedTxnId

public long getNextReplicatedTxnId()

isReplicatedTxn

public static boolean isReplicatedTxn(long txnId)

getNextTxnId

long getNextTxnId()
Get the next transaction id for a non-replicated transaction. Note than in the future, a replicated node could conceivable issue an application level, non-replicated transaction.


updateFromReplay

public void updateFromReplay(long replayTxnId)

txnBegin

public Txn txnBegin(Transaction parent,
                    TransactionConfig txnConfig)
             throws DatabaseException
Create a new transaction.

Parameters:
parent - for nested transactions, not yet supported
txnConfig - specifies txn attributes
Returns:
the new txn
Throws:
DatabaseException

getLockManager

public LockManager getLockManager()
Give transactions and environment access to lock manager.


registerTxn

void registerTxn(Txn txn)
Called when txn is created.


unRegisterTxn

void unRegisterTxn(Txn txn,
                   boolean isCommit)
Called when txn ends.


registerXATxn

public void registerXATxn(Xid xid,
                          Txn txn,
                          boolean isPrepare)
Called when txn is created.


notePrepare

public void notePrepare()
Called when XATransaction is prepared.


unRegisterXATxn

void unRegisterXATxn(Xid xid,
                     boolean isCommit)
               throws DatabaseException
Called when txn ends.

Throws:
IllegalStateException - via XAResource
DatabaseException

getTxnFromXid

public Txn getTxnFromXid(Xid xid)
Retrieve a Txn object from an Xid.


setTxnForThread

public void setTxnForThread(Transaction txn)
Called when txn is assoc'd with this thread.


unsetTxnForThread

public Transaction unsetTxnForThread()
Called when txn is assoc'd with this thread.


getTxnForThread

public Transaction getTxnForThread()
Retrieve a Txn object for this Thread.


XARecover

public Xid[] XARecover()

areOtherSerializableTransactionsActive

public boolean areOtherSerializableTransactionsActive(Locker excludeLocker)
Returns whether there are any active serializable transactions, excluding the transaction given (if non-null). This is intentionally returned without latching, since latching would not make the act of reading an integer more atomic than it already is.


getFirstActiveLsn

public long getFirstActiveLsn()
Get the earliest LSN of all the active transactions, for checkpoint. Returns NULL_LSN is no transaction is currently active.


txnStat

public TransactionStats txnStat(StatsConfig config)
Collect transaction related stats.


loadStats

public StatGroup loadStats(StatsConfig config)

lockStat

public LockStats lockStat(StatsConfig config)
                   throws DatabaseException
Collect lock related stats.

Throws:
DatabaseException


Copyright (c) 2004-2010 Oracle. All rights reserved.