Class RaftLog

java.lang.Object
io.atomix.raft.storage.log.RaftLog
All Implemented Interfaces:
Closeable, AutoCloseable

public final class RaftLog extends Object implements Closeable
Raft log.
  • Method Details

    • builder

      public static RaftLogBuilder builder()
      Returns a new Raft log builder.
      Returns:
      A new Raft log builder.
    • openUncommittedReader

      public RaftLogReader openUncommittedReader()
      Opens the reader that can read both committed and uncommitted entries.
      Returns:
      the reader
    • openCommittedReader

      public RaftLogReader openCommittedReader()
      Opens the reader that can only read committed entries.
      Returns:
      the reader
    • isOpen

      public boolean isOpen()
    • deleteUntil

      public boolean deleteUntil(long index)
      Compacts the journal up to the given index.

      The semantics of compaction are not specified by this interface.

      Parameters:
      index - The index up to which to compact the journal.
      Returns:
      true if anything was deleted, false otherwise
    • getCommitIndex

      public long getCommitIndex()
      Returns the Raft log commit index.
      Returns:
      The Raft log commit index.
    • setCommitIndex

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

      public boolean flushesDirectly()
    • getFirstIndex

      public long getFirstIndex()
    • getLastIndex

      public long getLastIndex()
    • getLastEntry

      public IndexedRaftLogEntry getLastEntry()
    • isEmpty

      public boolean isEmpty()
    • append

      public IndexedRaftLogEntry append(RaftLogEntry entry)
    • append

    • append

    • reset

      public void reset(long index)
    • deleteAfter

      public void deleteAfter(long index) throws CheckedJournalException.FlushException
      Throws:
      CheckedJournalException.FlushException
    • flush

      public void flush() throws CheckedJournalException.FlushException
      Flushes the underlying journal using the configured flushing strategy. For guarantees, refer to the configured RaftLogFlusher.
      Throws:
      CheckedJournalException.FlushException
    • forceFlush

      public void forceFlush() throws CheckedJournalException.FlushException
      Flushes the underlying journal in a blocking, synchronous way. When this returns, it is guaranteed that any appended data since the last flush is persisted on disk.

      NOTE: this bypasses the configured flushing strategy, and is meant to be used when certain guarantees are required.

      Throws:
      CheckedJournalException.FlushException
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getTailSegments

      public SortedMap<Long,Path> getTailSegments(long index)