Package org.apache.camel.component.wal
Class LogWriter
java.lang.Object
org.apache.camel.component.wal.LogWriter
- All Implemented Interfaces:
AutoCloseable
A writer for write-ahead log files
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default buffer capacity: 512 KiB -
Constructor Summary
ConstructorsConstructorDescriptionLogWriter(File logFile, LogSupervisor logSupervisor) Constructs a new log writer with the default capacityDEFAULT_CAPACITY(512 KiB). -
Method Summary
Modifier and TypeMethodDescriptionappend(org.apache.camel.component.wal.LogEntry entry) Appends an entry to the transaction log filevoidclose()voidreset()voidupdateState(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)voidupdateState(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.
-
Field Details
-
DEFAULT_CAPACITY
public static final int DEFAULT_CAPACITYThe default buffer capacity: 512 KiB- See Also:
-
-
Constructor Details
-
LogWriter
Constructs a new log writer with the default capacityDEFAULT_CAPACITY(512 KiB). If the file already exists, it will be truncated.- Parameters:
logFile- the transaction log filelogSupervisor- the log supervisorLogSupervisorfor the writer- Throws:
IOException- in case of I/O errors
-
-
Method Details
-
reset
- Throws:
IOException
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
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 updatedstate- 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 updatestate- 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
-