Class SegmentedRaftJournal.Builder

java.lang.Object
org.opendaylight.raft.journal.SegmentedRaftJournal.Builder
Enclosing class:
SegmentedRaftJournal

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

    • withName

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

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

      public SegmentedRaftJournal.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 SegmentedRaftJournal.Builder withDirectory(Path directory)
      Sets the journal directory.
      Parameters:
      directory - The log directory.
      Returns:
      The builder instance
      Throws:
      NullPointerException - If the directory is null
    • withDirectory

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

      public SegmentedRaftJournal.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 SegmentedRaftJournal.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 SegmentedRaftJournal.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 SegmentedRaftJournal.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
    • withByteBufAllocator

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

      public SegmentedRaftJournal build() throws IOException
      Returns:
      SegmentedRaftJournal instance built.
      Throws:
      IOException - when an I/O error occurs