Class RaftLogBuilder
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()withDirectory(File directory) Sets the log directory, returning the builder for method chaining.withFlushExplicitly(boolean flushExplicitly) Sets whether or not to flush buffered I/O explicitly at various points, returning the builder for chaining.withFreeDiskSpace(long freeDiskSpace) Sets the minimum free disk space to leave when allocating a new segmentwithJournalIndexDensity(int journalIndexDensity) Sets the index density of the journal.withLastWrittenIndex(long lastWrittenIndex) withMaxSegmentSize(int maxSegmentSize) Sets the maximum segment size in bytes, returning the builder for method chaining.Sets the storage name.
-
Constructor Details
-
RaftLogBuilder
protected RaftLogBuilder()
-
-
Method Details
-
withName
Sets the storage name.- Parameters:
name- The storage name.- Returns:
- The storage builder.
-
withDirectory
Sets the log directory, returning the builder for method chaining.The log will write segment files into the provided directory.
- Parameters:
directory- The log directory.- Returns:
- The storage builder.
- Throws:
NullPointerException- If thedirectoryisnull
-
withMaxSegmentSize
Sets the maximum segment size in bytes, returning the builder for method chaining.The maximum segment size dictates when logs should roll over to new segments. As entries are written to a segment of the log, once the size of the segment surpasses the configured maximum segment size, the log will create a new segment and append new entries to that segment.
By default, the maximum segment size is
1024 * 1024 * 32.- Parameters:
maxSegmentSize- The maximum segment size in bytes.- Returns:
- The storage builder.
- Throws:
IllegalArgumentException- If themaxSegmentSizeis not positive
-
withFreeDiskSpace
Sets the minimum free disk space to leave when allocating a new segment- Parameters:
freeDiskSpace- free disk space in bytes- Returns:
- the storage builder
- Throws:
IllegalArgumentException- if thefreeDiskSpaceis not positive
-
withFlushExplicitly
Sets whether or not to flush buffered I/O explicitly at various points, returning the builder for chaining.Enabling this ensures that entries are flushed on followers before acknowledging a write, and are flushed on the leader before marking an entry as committed. This guarantees the correctness of various Raft properties.
- Parameters:
flushExplicitly- whether to flush explicitly or not- Returns:
- this builder for chaining
-
withJournalIndexDensity
Sets the index density of the journal.When journalIndexDensity is set to n, every n'th record is indexed. So higher this value, longer a seek operation takes. Lower this value more memory is required to store the index mappings.
- Parameters:
journalIndexDensity- the journal index density- Returns:
- this builder for chaining
-
withLastWrittenIndex
-
build
-