Interface EntryWriter


@NonNullByDefault public interface EntryWriter
A writer of RaftJournal entries.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> int
    append(ToByteBufMapper<T> mapper, T entry)
    Appends an entry to the journal.
    void
    Checkpoints current state so that it can be easily trimmed in the future.
    void
    commit(long index)
    Commits entries up to the given index.
    void
    Flushes written entries to disk.
    long
    Returns the next index to be written.
    void
    reset(long index)
    Resets the head of the journal to the given index.
  • Method Details

    • nextIndex

      long nextIndex()
      Returns the next index to be written.
      Returns:
      The next index to be written
    • append

      <T> int append(ToByteBufMapper<T> mapper, T entry) throws IOException
      Appends an entry to the journal.
      Type Parameters:
      T - Internal representation type
      Parameters:
      mapper - a ToByteBufMapper to use with entry
      entry - entry to append
      Returns:
      the on-disk size of the entry
      Throws:
      IOException - if an I/O error occurs
    • commit

      void commit(long index)
      Commits entries up to the given index.
      Parameters:
      index - The index up to which to commit entries.
    • reset

      void reset(long index)
      Resets the head of the journal to the given index.
      Parameters:
      index - the next index to write
      Throws:
      IndexOutOfBoundsException - if the journal cannot be reset to specified index
    • flush

      void flush() throws IOException
      Flushes written entries to disk.
      Throws:
      IOException - when an I/O error occurs
    • checkpoint

      void checkpoint() throws IOException
      Checkpoints current state so that it can be easily trimmed in the future.
      Throws:
      IOException - when an I/O error occurs