Package bitronix.tm.journal
Class DiskJournal
java.lang.Object
bitronix.tm.journal.DiskJournal
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.
- Author:
- lorban
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the disk journal and the underlying files.Collect all dangling records of the active log file.voidforce()Force active log file to synchronize with the underlying disk device.voidLog a new transaction status to journal.voidopen()Open the disk journal.voidshutdown()Shutdown the service and free all held resources.
-
Constructor Details
-
DiskJournal
public DiskJournal()Create an uninitialized disk journal. You must call open() prior you can use it.
-
-
Method Details
-
log
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:
login interfaceJournal- Parameters:
status- transaction status to log. SeeStatusconstants.gtrid- raw GTRID of the transaction.uniqueNames- unique names of theResourceBeans participating in this transaction.- Throws:
IOException- in case of disk IO failure or if the disk journal is not open.
-
force
Force active log file to synchronize with the underlying disk device.- Specified by:
forcein interfaceJournal- Throws:
IOException- in case of disk IO failure or if the disk journal is not open.
-
open
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:
openin interfaceJournal- Throws:
IOException- in case of disk IO failure.
-
close
Close the disk journal and the underlying files.- Specified by:
closein interfaceJournal- Throws:
IOException- in case of disk IO failure.
-
shutdown
public void shutdown()Description copied from interface:ServiceShutdown the service and free all held resources. -
collectDanglingRecords
Collect all dangling records of the active log file.- Specified by:
collectDanglingRecordsin interfaceJournal- Returns:
- a Map using Uid objects GTRID as key and
TransactionLogRecordas value - Throws:
IOException- in case of disk IO failure or if the disk journal is not open.
-