Package bitronix.tm.journal
Class TransactionLogAppender
java.lang.Object
bitronix.tm.journal.TransactionLogAppender
Used to write
TransactionLogRecord objects to a log file.- Author:
- lorban
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTransactionLogAppender(File file, long maxFileLength) Create an appender that will write to specified file up to the specified maximum length. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the appender and the underlying file.protected voiddoForce()voidforce()Force flushing the logs to diskCreates a cursor on this journal file allowing iteration of its records.Return aTransactionLogHeaderthat allows reading and controlling the log file's header.toString()booleanwriteLog(TransactionLogRecord tlog) Write aTransactionLogRecordto disk.
-
Field Details
-
END_RECORD
public static final int END_RECORDint-encoded "xntB" ASCII string. This will be useful after swapping log files since we will potentially overwrite old logs not necessarily of the same size. Very useful when debugging and eventually restoring broken log files.- See Also:
-
-
Constructor Details
-
TransactionLogAppender
Create an appender that will write to specified file up to the specified maximum length. All disk access are synchronized arround the RandomAccessFile object, including header calls.- Parameters:
file- the underlying File used to write to disk.maxFileLength- size of the file on disk that can never be bypassed.- Throws:
IOException- if an I/O error occurs.
-
-
Method Details
-
getHeader
Return aTransactionLogHeaderthat allows reading and controlling the log file's header.- Returns:
- this log file's TransactionLogHeader
-
writeLog
Write aTransactionLogRecordto disk.- Parameters:
tlog- the record to write to disk.- Returns:
- true if there was room in the log file and the log was written, false otherwise.
- Throws:
IOException- if an I/O error occurs.
-
close
Close the appender and the underlying file.- Throws:
IOException- if an I/O error occurs.
-
getCursor
Creates a cursor on this journal file allowing iteration of its records. This opens a new read-only file descriptor independent of the write-only one still used for writing transaction logs.- Returns:
- a TransactionLogCursor.
- Throws:
IOException- if an I/O error occurs.
-
force
Force flushing the logs to disk- Throws:
IOException- if an I/O error occurs.
-
toString
-
doForce
- Throws:
IOException
-