Package io.atomix.raft.storage.log
Class RaftLogBuilder
java.lang.Object
io.atomix.raft.storage.log.RaftLogBuilder
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRaftLogBuilder(io.micrometer.core.instrument.MeterRegistry meterRegistry) -
Method Summary
Modifier and TypeMethodDescriptionbuild()withDirectory(File directory) Sets the log directory, returning the builder for method chaining.withFlusher(RaftLogFlusher flusher) Sets the flushing strategy.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.withMaxSegmentSize(int maxSegmentSize) Sets the maximum segment size in bytes, returning the builder for method chaining.withMetaStore(JournalMetaStore metaStore) Sets the storage name.withPartitionId(int partitionId) The ID of the partition on which this log resides.withPreallocateSegmentFiles(boolean preallocateSegmentFiles) Sets whether segment files are pre-allocated at creation.
-
Constructor Details
-
RaftLogBuilder
protected RaftLogBuilder(io.micrometer.core.instrument.MeterRegistry meterRegistry)
-
-
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
-
withFlusher
Sets the flushing strategy. See implementations ofRaftLogFlusherfor which to use. Each strategy provides different guarantees to allow for a trade-off between performance and safety.- Parameters:
flusher- the flushing strategy, defaults toRaftLogFlusher.DirectFlusher- 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
-
withPreallocateSegmentFiles
Sets whether segment files are pre-allocated at creation. If true, segment files are pre-allocated to the maximum segment size (seewithMaxSegmentSize(int)}) at creation before any writes happen.- Parameters:
preallocateSegmentFiles- true to preallocate files, false otherwise- Returns:
- this builder for chaining
-
withPartitionId
The ID of the partition on which this log resides.- Parameters:
partitionId- the log's partition ID- Returns:
- this builder for chaining
-
withMetaStore
- Parameters:
metaStore- A persisted JournalMetaStore that can store lastFlushedIndex.- Returns:
- this builder for chaining
-
build
-