bitronix.tm.journal
Class DiskJournal

java.lang.Object
  extended by bitronix.tm.journal.DiskJournal
All Implemented Interfaces:
Journal, Service

public class DiskJournal
extends java.lang.Object
implements Journal

Simple implementation of a journal that writes on a two-files disk log.

Files are pre-allocated in size, never grow and when the first one is full, dangling records are copied to the second file and logging starts again on the latter.

This implementation is not highly efficient but quite robust and simple. It is based on one of the implementations proposed by Mike Spille.

Configurable properties are all starting with bitronix.tm.journal.disk.

© Bitronix Software

Author:
lorban
See Also:
Configuration, XA Exposed, Part III: The Implementor's Notebook

Constructor Summary
DiskJournal()
          Create an uninitialized disk journal.
 
Method Summary
 void close()
          Close the disk journal and the underlying files.
 java.util.Map collectDanglingRecords()
          Collect all dangling records of the active log file.
 void force()
          Force active log file to synchronize with the underlying disk device.
 void log(int status, Uid gtrid, java.util.Set uniqueNames)
          Log a new transaction status to journal.
 void open()
          Open the disk journal.
 void shutdown()
          Shutdown the service and free all held resources.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DiskJournal

public DiskJournal()
Create an uninitialized disk journal. You must call open() prior you can use it.

Method Detail

log

public void log(int status,
                Uid gtrid,
                java.util.Set uniqueNames)
         throws java.io.IOException
Log a new transaction status to journal. Note that the DiskJournal will not check the flow of the transaction. If you call this method with erroneous data, it will be added to the journal anyway.

Specified by:
log in interface Journal
Parameters:
status - transaction status to log. See Status constants
gtrid - raw GTRID of the transaction
uniqueNames - unique names of the XADataSources participating in this transaction
Throws:
java.io.IOException

force

public void force()
           throws java.io.IOException
Force active log file to synchronize with the underlying disk device.

Specified by:
force in interface Journal
Throws:
java.io.IOException

open

public void open()
          throws java.io.IOException
Open the disk journal. Files are checked for integrity and DiskJournal will refuse to open corrupted log files. If files are not present on disk, this method will create and pre-allocate them.

Specified by:
open in interface Journal
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Close the disk journal and the underlying files.

Specified by:
close in interface Journal
Throws:
java.io.IOException

shutdown

public void shutdown()
Description copied from interface: Service
Shutdown the service and free all held resources.

Specified by:
shutdown in interface Service

collectDanglingRecords

public java.util.Map collectDanglingRecords()
                                     throws java.io.IOException
Collect all dangling records of the active log file.

Specified by:
collectDanglingRecords in interface Journal
Returns:
a Map using Uid objects GTRID as key and TransactionLogRecord as value
Throws:
java.io.IOException