Class LogWriter

java.lang.Object
org.apache.camel.component.wal.LogWriter
All Implemented Interfaces:
AutoCloseable

public final class LogWriter extends Object implements AutoCloseable
A writer for write-ahead log files
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The default buffer capacity: 512 KiB
  • Constructor Summary

    Constructors
    Constructor
    Description
    LogWriter(File logFile, LogSupervisor logSupervisor)
    Constructs a new log writer with the default capacity DEFAULT_CAPACITY (512 KiB).
  • Method Summary

    Modifier and Type
    Method
    Description
    append(org.apache.camel.component.wal.LogEntry entry)
    Appends an entry to the transaction log file
    void
     
    void
     
    void
    updateState(EntryInfo.CachedEntryInfo entryInfo, org.apache.camel.component.wal.LogEntry.EntryState state)
    Updates the state of af entry (i.e.: to mark them after they have seen successfully processed)
    void
    updateState(org.apache.camel.component.wal.PersistedLogEntry entry, org.apache.camel.component.wal.LogEntry.EntryState state)
    Updates the state of af entry that has been already persisted to disk.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_CAPACITY

      public static final int DEFAULT_CAPACITY
      The default buffer capacity: 512 KiB
      See Also:
  • Constructor Details

    • LogWriter

      public LogWriter(File logFile, LogSupervisor logSupervisor) throws IOException
      Constructs a new log writer with the default capacity DEFAULT_CAPACITY (512 KiB). If the file already exists, it will be truncated.
      Parameters:
      logFile - the transaction log file
      logSupervisor - the log supervisor LogSupervisor for the writer
      Throws:
      IOException - in case of I/O errors
  • Method Details

    • reset

      public void reset() throws IOException
      Throws:
      IOException
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • append

      public EntryInfo.CachedEntryInfo append(org.apache.camel.component.wal.LogEntry entry) throws IOException
      Appends an entry to the transaction log file
      Parameters:
      entry - the entry to write to the transaction log
      Returns:
      An entry info instance with the metadata for the appended log entry
      Throws:
      IOException - for lower-level I/O errors
    • updateState

      public void updateState(EntryInfo.CachedEntryInfo entryInfo, org.apache.camel.component.wal.LogEntry.EntryState state) throws IOException
      Updates the state of af entry (i.e.: to mark them after they have seen successfully processed)
      Parameters:
      entryInfo - the entry information about the entry being updated
      state - the state to update the entry to
      Throws:
      IOException - in case of lower-level I/O errors
    • updateState

      public void updateState(org.apache.camel.component.wal.PersistedLogEntry entry, org.apache.camel.component.wal.LogEntry.EntryState state) throws IOException
      Updates the state of af entry that has been already persisted to disk. Wraps any lower-level I/O errors in runtime exceptions
      Parameters:
      entry - the entry to update
      state - the state to update the entry to
      Throws:
      IOException - if the buffer is too small for the entry or in case of lower-level I/O errors