Class SegmentedByteBufJournal.Builder

java.lang.Object
io.atomix.storage.journal.SegmentedByteBufJournal.Builder
Enclosing class:
SegmentedByteBufJournal

public static final class SegmentedByteBufJournal.Builder extends Object
Segmented byte journal builder.
  • Method Details

    • withName

      public SegmentedByteBufJournal.Builder withName(String name)
      Sets the journal name.
      Parameters:
      name - The journal name.
      Returns:
      The builder instance
    • withStorageLevel

      public SegmentedByteBufJournal.Builder withStorageLevel(StorageLevel storageLevel)
      Sets the storage level.
      Parameters:
      storageLevel - The storage level.
      Returns:
      The builder instance
    • withDirectory

      public SegmentedByteBufJournal.Builder withDirectory(String directory)
      Sets the journal directory.
      Parameters:
      directory - The log directory.
      Returns:
      The builder instance
      Throws:
      NullPointerException - If the directory is null
    • withDirectory

      public SegmentedByteBufJournal.Builder withDirectory(File directory)
      Sets the journal directory.
      Parameters:
      directory - The log directory.
      Returns:
      The builder instance
      Throws:
      NullPointerException - If the directory is null
    • withMaxSegmentSize

      public SegmentedByteBufJournal.Builder withMaxSegmentSize(int maxSegmentSize)
      Sets the maximum segment size in bytes. By default, the maximum segment size is 1024 * 1024 * 32.
      Parameters:
      maxSegmentSize - The maximum segment size in bytes.
      Returns:
      The builder instance
      Throws:
      IllegalArgumentException - If the maxSegmentSize is not positive
    • withMaxEntrySize

      public SegmentedByteBufJournal.Builder withMaxEntrySize(int maxEntrySize)
      Sets the maximum entry size in bytes.
      Parameters:
      maxEntrySize - the maximum entry size in bytes
      Returns:
      the builder instance
      Throws:
      IllegalArgumentException - if the maxEntrySize is not positive
    • withMaxEntriesPerSegment

      @Deprecated(forRemoval=true, since="9.0.3") public SegmentedByteBufJournal.Builder withMaxEntriesPerSegment(int maxEntriesPerSegment)
      Deprecated, for removal: This API element is subject to removal in a future version.
      This option has no effect and is scheduled for removal.
      Sets the maximum number of allows entries per segment, returning the builder for method chaining.

      The maximum entry count dictates when logs should roll over to new segments. As entries are written to a segment of the log, if the entry count in that segment meets the configured maximum entry count, the log will create a new segment and append new entries to that segment.

      By default, the maximum entries per segment is 1024 * 1024.

      Parameters:
      maxEntriesPerSegment - The maximum number of entries allowed per segment.
      Returns:
      The storage builder.
      Throws:
      IllegalArgumentException - If the maxEntriesPerSegment not greater than the default max entries per segment
    • withIndexDensity

      public SegmentedByteBufJournal.Builder withIndexDensity(double indexDensity)
      Sets the journal index density.

      The index density is the frequency at which the position of entries written to the journal will be recorded in an in-memory index for faster seeking.

      Parameters:
      indexDensity - the index density
      Returns:
      the builder instance
      Throws:
      IllegalArgumentException - if the density is not between 0 and 1
    • withFlushOnCommit

      public SegmentedByteBufJournal.Builder withFlushOnCommit()
      Enables flushing buffers to disk when entries are committed to a segment.

      When flush-on-commit is enabled, log entry buffers will be automatically flushed to disk each time an entry is committed in a given segment.

      Returns:
      The builder instance
    • withFlushOnCommit

      public SegmentedByteBufJournal.Builder withFlushOnCommit(boolean flushOnCommit)
      Sets whether to flush buffers to disk when entries are committed to a segment.

      When flush-on-commit is enabled, log entry buffers will be automatically flushed to disk each time an entry is committed in a given segment.

      Parameters:
      flushOnCommit - Whether to flush buffers to disk when entries are committed to a segment.
      Returns:
      The builder instance
    • withByteBufAllocator

      public SegmentedByteBufJournal.Builder withByteBufAllocator(io.netty.buffer.ByteBufAllocator byteBufAllocator)
      Sets the ByteBufAllocator to use for allocating various buffers.
      Parameters:
      byteBufAllocator - the allocator to use
      Returns:
      The builder instance
    • build

      public SegmentedByteBufJournal build()
      Returns:
      SegmentedByteBufJournal instance built.