Class BatchPolicy.Builder

java.lang.Object
me.ahoo.cosid.segment.BatchPolicy.Builder
Enclosing class:
BatchPolicy

public static final class BatchPolicy.Builder extends Object
Builds a BatchPolicy; build() checks the fields.
  • Method Details

    • step

      public BatchPolicy.Builder step(long step)
      Sets the smallest reservation.
      Parameters:
      step - the step, positive; default 100L
      Returns:
      this builder
    • initialOffset

      public BatchPolicy.Builder initialOffset(long initialOffset)
      Sets where the first range of a new key starts.
      Parameters:
      initialOffset - the offset, not negative; default 1L, so a generator never issues 0
      Returns:
      this builder
    • lookahead

      public BatchPolicy.Builder lookahead(Duration lookahead)
      Sets how long the ids at hand should last.
      Parameters:
      lookahead - the lookahead, not negative; default 1s; Duration.ZERO disables prefetching
      Returns:
      this builder
    • maxBatch

      public BatchPolicy.Builder maxBatch(long maxBatch)
      Sets the largest reservation.
      Parameters:
      maxBatch - a positive multiple of the step; default BatchPolicy.defaultMaxBatch(long) of the step
      Returns:
      this builder
    • reserveTimeout

      public BatchPolicy.Builder reserveTimeout(Duration reserveTimeout)
      Sets how long a caller waits for a refill.
      Parameters:
      reserveTimeout - the timeout, positive; default 3s
      Returns:
      this builder
    • rangeTtl

      public BatchPolicy.Builder rangeTtl(Duration rangeTtl)
      Sets how long a range may stay unused before it is dropped (4.x segment ttl).
      Parameters:
      rangeTtl - the range ttl, positive; default none
      Returns:
      this builder
    • build

      public BatchPolicy build()
      Builds the policy.
      Returns:
      the policy
      Throws:
      IllegalArgumentException - if a field is out of range