Interface JournalFileWriter

  • All Superinterfaces:
    AutoCloseable, Closeable

    public interface JournalFileWriter
    extends Closeable
    The JournalFile 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:

    • Method Detail

      • truncate

        void truncate()
               throws IOException
        Truncates the journal file. This is a maintenance operation, which may break existing JournalFileReader 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 using JournalFile.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 using JournalFile.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