Class TransactionLogAppender

java.lang.Object
bitronix.tm.journal.TransactionLogAppender

public class TransactionLogAppender extends Object
Used to write TransactionLogRecord objects to a log file.
Author:
lorban
  • Field Details

    • END_RECORD

      public static final int END_RECORD
      int-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

      public TransactionLogAppender(File file, long maxFileLength) throws IOException
      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

      public TransactionLogHeader getHeader()
      Return a TransactionLogHeader that allows reading and controlling the log file's header.
      Returns:
      this log file's TransactionLogHeader
    • writeLog

      public boolean writeLog(TransactionLogRecord tlog) throws IOException
      Write a TransactionLogRecord to 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

      public void close() throws IOException
      Close the appender and the underlying file.
      Throws:
      IOException - if an I/O error occurs.
    • getCursor

      public TransactionLogCursor getCursor() throws IOException
      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

      public void force() throws IOException
      Force flushing the logs to disk
      Throws:
      IOException - if an I/O error occurs.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • doForce

      protected void doForce() throws IOException
      Throws:
      IOException