Interface JournalFileWriter
-
- All Superinterfaces:
AutoCloseable
,Closeable
public interface JournalFileWriter extends Closeable
TheJournalFile
writer. It allows to append a record to the journal file (or create a new one, if it doesn't exist).The implementation doesn't need to be thread-safe (eg. the caller has to take care of synchronizing the
writeLine(String)
method calls), but the method should be:- atomic with regards to the
JournalFileReader
, - flushed to the storage.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
batchWriteLines(List<String> lines)
Write new lines to the journal file as a batch.void
truncate()
Truncates the journal file.void
writeLine(String line)
Write a new line to the journal file.
-
-
-
Method Detail
-
truncate
void truncate() throws IOException
Truncates the journal file. This is a maintenance operation, which may break existingJournalFileReader
and shouldn't be used in the concurrent environment.- Throws:
IOException
-
writeLine
void writeLine(String line) throws IOException
Write a new line to the journal file. This operation should be atomic, eg. it's should be possible to open a new reader usingJournalFile.openJournalReader()
in the way that it'll have access to an incomplete record line.If this method returns successfully it means that the line was persisted on the non-volatile storage. For instance, on the local disk the
flush()
should be called by the implementation.- Parameters:
line
- the journal record to be written- Throws:
IOException
-
batchWriteLines
void batchWriteLines(List<String> lines) throws IOException
Write new lines to the journal file as a batch. Methods allows for optimized batch implementations. This operation should be atomic, eg. it's should be possible to open a new reader usingJournalFile.openJournalReader()
in the way that it'll have access to an incomplete record line.If this method returns successfully it means that the line was persisted on the non-volatile storage. For instance, on the local disk the
flush()
should be called by the implementation.- Parameters:
lines
- List of journal records to be written- Throws:
IOException
-
-