jdbm.recman
Class TransactionManager

java.lang.Object
  extended by jdbm.recman.TransactionManager

public final class TransactionManager
extends java.lang.Object

This class manages the transaction log that belongs to every RecordFile. The transaction log is either clean, or in progress. In the latter case, the transaction manager takes care of a roll forward.

Implementation note: this is a proof-of-concept implementation which hasn't been optimized for speed. For instance, all sorts of streams are created for every transaction.


Nested Class Summary
static class TransactionManager.BlockIoComparator
          INNER CLASS.
 
Field Summary
(package private) static int DEFAULT_TXNS_IN_LOG
          By default, we keep 10 transactions in the log file before synchronizing it with the main database file.
(package private) static java.lang.String extension
          Extension of a log file.
 
Constructor Summary
TransactionManager(RecordFile owner)
          Instantiates a transaction manager instance.
 
Method Summary
(package private)  void add(BlockIo block)
          Indicates the block is part of the transaction.
(package private)  void commit()
          Commits the transaction to the log file.
(package private)  void forceClose()
          Force closing the file without synchronizing pending transaction data.
 void setMaximumTransactionsInLog(int maxTxns)
          Set the maximum number of transactions to record in the log (and keep in memory) before the log is synchronized with the main database file.
(package private)  void shutdown()
          Shutdowns the transaction manager.
(package private)  void start()
          Starts a transaction.
 void synchronizeLog()
          Synchronize log file data with the main database file.
(package private)  void synchronizeLogFromDisk()
          Use the disk-based transaction log to synchronize the data file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TXNS_IN_LOG

static final int DEFAULT_TXNS_IN_LOG
By default, we keep 10 transactions in the log file before synchronizing it with the main database file.

See Also:
Constant Field Values

extension

static final java.lang.String extension
Extension of a log file.

See Also:
Constant Field Values
Constructor Detail

TransactionManager

TransactionManager(RecordFile owner)
             throws java.io.IOException
Instantiates a transaction manager instance. If recovery needs to be performed, it is done.

Parameters:
owner - the RecordFile instance that owns this transaction mgr.
Throws:
java.io.IOException
Method Detail

synchronizeLog

public void synchronizeLog()
                    throws java.io.IOException
Synchronize log file data with the main database file.

After this call, the main database file is guaranteed to be consistent and guaranteed to be the only file needed for backup purposes.

Throws:
java.io.IOException

setMaximumTransactionsInLog

public void setMaximumTransactionsInLog(int maxTxns)
                                 throws java.io.IOException
Set the maximum number of transactions to record in the log (and keep in memory) before the log is synchronized with the main database file.

This method must be called while there are no pending transactions in the log.

Throws:
java.io.IOException

start

void start()
     throws java.io.IOException
Starts a transaction. This can block if all slots have been filled with full transactions, waiting for the synchronization thread to clean out slots.

Throws:
java.io.IOException

add

void add(BlockIo block)
   throws java.io.IOException
Indicates the block is part of the transaction.

Throws:
java.io.IOException

commit

void commit()
      throws java.io.IOException
Commits the transaction to the log file.

Throws:
java.io.IOException

shutdown

void shutdown()
        throws java.io.IOException
Shutdowns the transaction manager. Resynchronizes outstanding logs.

Throws:
java.io.IOException

forceClose

void forceClose()
          throws java.io.IOException
Force closing the file without synchronizing pending transaction data. Used for testing purposes only.

Throws:
java.io.IOException

synchronizeLogFromDisk

void synchronizeLogFromDisk()
                      throws java.io.IOException
Use the disk-based transaction log to synchronize the data file. Outstanding memory logs are discarded because they are believed to be inconsistent.

Throws:
java.io.IOException


Cees de Groot (C) 2000-2001. All rights reserved http://jdbm.sourceforge.net