public class DiskJournal extends Object implements Journal, MigratableJournal, ReadableJournal
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.
Configuration,
XA Exposed, Part III: The Implementor's Notebook| Constructor and Description |
|---|
DiskJournal()
Create an uninitialized disk journal.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the disk journal and the underlying files.
|
Map<Uid,JournalRecord> |
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,
Set<String> uniqueNames)
Log a new transaction status to journal.
|
void |
migrateTo(Journal other)
Can be called at any point in time to migrate all unfinished transactions into the given
journal.
|
void |
open()
Open the disk journal.
|
void |
shutdown()
Shutdown the service and free all held resources.
|
void |
unsafeReadRecordsInto(Collection<JournalRecord> target,
boolean includeInvalid)
Reads all raw journal records and and adds them to the given collection.
|
public DiskJournal()
public void log(int status,
Uid gtrid,
Set<String> uniqueNames)
throws IOException
log in interface Journalstatus - transaction status to log. See Status constants.gtrid - raw GTRID of the transaction.uniqueNames - unique names of the ResourceBeans participating in
this transaction.IOException - in case of disk IO failure or if the disk journal is not open.public void force()
throws IOException
force in interface JournalIOException - in case of disk IO failure or if the disk journal is not open.public void open()
throws IOException
open in interface JournalIOException - in case of disk IO failure.public void close()
throws IOException
close in interface JournalIOException - in case of disk IO failure.public void shutdown()
Servicepublic Map<Uid,JournalRecord> collectDanglingRecords() throws IOException
collectDanglingRecords in interface JournalTransactionLogRecord as valueIOException - in case of disk IO failure or if the disk journal is not open.public void migrateTo(Journal other) throws IOException, IllegalArgumentException
migrateTo in interface MigratableJournalother - the journal to migrate all unfinished transactions to.IOException - In case of not all entries could be written into the other journal.IllegalArgumentException - If other is the same instance as 'this'.public void unsafeReadRecordsInto(Collection<JournalRecord> target, boolean includeInvalid) throws IOException
Notes:
unsafeReadRecordsInto in interface ReadableJournaltarget - the target collection to read the records into.includeInvalid - specified whether broken records are attempted to be included.IOException - In case of reading the first record fails.Copyright © 2006-2016 Bitronix Software. All Rights Reserved.