Class SegmentedJournalBuilder

java.lang.Object
io.camunda.zeebe.journal.file.SegmentedJournalBuilder

public class SegmentedJournalBuilder extends Object
Raft log builder.
  • Field Details

    • name

      protected String name
    • directory

      protected File directory
    • maxSegmentSize

      protected int maxSegmentSize
  • Constructor Details

    • SegmentedJournalBuilder

      protected SegmentedJournalBuilder()
  • Method Details

    • withName

      public SegmentedJournalBuilder withName(String name)
      Sets the storage name.
      Parameters:
      name - The storage name.
      Returns:
      The storage builder.
    • withDirectory

      public SegmentedJournalBuilder withDirectory(String directory)
      Sets the journal directory, returning the builder for method chaining.

      The journal will write segment files into the provided directory.

      Parameters:
      directory - The log directory.
      Returns:
      The storage builder.
      Throws:
      NullPointerException - If the directory is null
    • withDirectory

      public SegmentedJournalBuilder withDirectory(File directory)
      Sets the journal directory, returning the builder for method chaining.

      The journal will write segment files into the provided directory.

      Parameters:
      directory - The journal directory.
      Returns:
      The journal builder.
      Throws:
      NullPointerException - If the directory is null
    • withMaxSegmentSize

      public SegmentedJournalBuilder withMaxSegmentSize(int maxSegmentSize)
      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 journal builder.
      Throws:
      IllegalArgumentException - If the maxSegmentSize is not positive
    • withFreeDiskSpace

      public SegmentedJournalBuilder withFreeDiskSpace(long freeDiskSpace)
      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 the freeDiskSpace is not positive
    • withJournalIndexDensity

      public SegmentedJournalBuilder withJournalIndexDensity(int journalIndexDensity)
    • withPreallocateSegmentFiles

      public SegmentedJournalBuilder withPreallocateSegmentFiles(boolean preallocateSegmentFiles)
      Sets whether segment files are pre-allocated at creation. If true, segment files are pre-allocated to the maximum segment size (see withMaxSegmentSize(int)}) at creation before any writes happen.
      Parameters:
      preallocateSegmentFiles - true to preallocate files, false otherwise
      Returns:
      this builder for chaining
    • withPartitionId

      public SegmentedJournalBuilder withPartitionId(int partitionId)
      The ID of the partition on which this journal resides. This is used primarily for observability, e.g. in JournalMetrics.
      Parameters:
      partitionId - the journal's partition ID
      Returns:
      this builder for chaining
    • withMetaStore

      public SegmentedJournalBuilder withMetaStore(JournalMetaStore metaStore)
      Parameters:
      metaStore - journal metastore to update lastFlushedIndex
      Returns:
      this builder for chaining
    • build

      public SegmentedJournal build()