Interface JournalFileWriter

  • All Superinterfaces:
    java.lang.AutoCloseable, java.io.Closeable

    public interface JournalFileWriter
    extends java.io.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 Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void batchWriteLines​(java.util.List<java.lang.String> lines)
      Write new lines to the journal file as a batch.
      void truncate()
      Truncates the journal file.
      void writeLine​(java.lang.String line)
      Write a new line to the journal file.
      • Methods inherited from interface java.io.Closeable

        close
    • Method Detail

      • truncate

        void truncate()
               throws java.io.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:
        java.io.IOException
      • writeLine

        void writeLine​(java.lang.String line)
                throws java.io.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:
        java.io.IOException
      • batchWriteLines

        void batchWriteLines​(java.util.List<java.lang.String> lines)
                      throws java.io.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:
        java.io.IOException