Interface EntryJournal

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
EntryJournalV1

@NonNullByDefault public interface EntryJournal extends AutoCloseable
Interface for RAFT log entry persistence implementations. This is rather opinionated take with RaftJournal acting as the backing implementation.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
    A handle to a LogEntry stored in the journal.
    static interface 
    A reader-side interface to log entries being stored in this journal.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    A friendly constant to centralize the places where we assume counting from 1.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Append an entry at the current journalIndex.
    long
    Returns the journalIndex of the last entry which is to be applied.
    void
     
    void
    discardHead(long firstRetainedIndex)
    Discard all entries starting from the beginning of journal up to, but excluding, firstRetainedIndex.
    void
    discardTail(long firstRemovedIndex)
    Discard all entries starting from firstRemovedIndex.
    Returns a new EntryJournal.Reader.
    void
    setApplyTo(long newApplyTo)
    Update the journalIndex to report from applyToJournalIndex().
  • Field Details

    • FIRST_JOURNAL_INDEX

      static final int FIRST_JOURNAL_INDEX
      A friendly constant to centralize the places where we assume counting from 1.
      See Also:
  • Method Details

    • applyToJournalIndex

      long applyToJournalIndex()
      Returns the journalIndex of the last entry which is to be applied.
      Returns:
      the journalIndex of the last entry which is to be applied
    • openReader

      EntryJournal.Reader openReader()
      Returns a new EntryJournal.Reader.
      Returns:
      a new EntryJournal.Reader
    • appendEntry

      long appendEntry(LogEntry entry) throws IOException
      Append an entry at the current journalIndex.
      Parameters:
      entry - the journal entry to append
      Returns:
      the serialized size of LogEntry.command()
      Throws:
      IOException - if an I/O error occurs
    • discardHead

      void discardHead(long firstRetainedIndex) throws IOException
      Discard all entries starting from the beginning of journal up to, but excluding, firstRetainedIndex. The journal will be updated such that the next openReader() invocation will result in the reader reporting firstRetainedIndex as the initial EntryJournal.Reader.nextJournalIndex().
      Parameters:
      firstRetainedIndex - the index of the first entry to retain
      Throws:
      IOException - if an I/O error occurs
    • discardTail

      void discardTail(long firstRemovedIndex) throws IOException
      Discard all entries starting from firstRemovedIndex. The journal will be positioned such that the next appendEntry(LogEntry) will return firstRemovedIndex.
      Parameters:
      firstRemovedIndex - the index of the first entry to remove
      Throws:
      IOException - if an I/O error occurs
    • setApplyTo

      void setApplyTo(long newApplyTo) throws IOException
      Update the journalIndex to report from applyToJournalIndex().
      Parameters:
      newApplyTo - the new journalIndex to return
      Throws:
      IOException - if an I/O error occurs
    • close

      void close()
      Specified by:
      close in interface AutoCloseable