Package io.atomix.raft.storage.log
Class RaftLog
java.lang.Object
io.atomix.raft.storage.log.RaftLog
- All Implemented Interfaces:
Closeable,AutoCloseable
Raft log.
-
Method Summary
Modifier and TypeMethodDescriptionappend(PersistedRaftRecord entry) append(RaftLogEntry entry) static RaftLogBuilderbuilder()Returns a new Raft log builder.voidclose()voiddeleteAfter(long index) booleandeleteUntil(long index) Compacts the journal up to the given index.voidflush()Flushes the underlying journal using the configured flushing strategy.booleanvoidFlushes the underlying journal in a blocking, synchronous way.longReturns the Raft log commit index.longlongbooleanisEmpty()booleanisOpen()Opens the reader that can only read committed entries.Opens the reader that can read both committed and uncommitted entries.voidreset(long index) voidsetCommitIndex(long index) Commits entries up to the given index.toString()
-
Method Details
-
builder
Returns a new Raft log builder.- Returns:
- A new Raft log builder.
-
openUncommittedReader
Opens the reader that can read both committed and uncommitted entries.- Returns:
- the reader
-
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
-
isEmpty
public boolean isEmpty() -
append
-
append
-
reset
public void reset(long index) -
deleteAfter
public void deleteAfter(long index) -
flush
public void flush()Flushes the underlying journal using the configured flushing strategy. For guarantees, refer to the configuredRaftLogFlusher. -
forceFlush
public void forceFlush()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.
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
toString
-