java.lang.Object
me.ahoo.cosid.segment.BatchPolicy.Builder
- Enclosing class:
BatchPolicy
Builds a
BatchPolicy; build() checks the fields.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the policy.initialOffset(long initialOffset) Sets where the first range of a new key starts.Sets how long the ids at hand should last.maxBatch(long maxBatch) Sets the largest reservation.Sets how long a range may stay unused before it is dropped (4.x segment ttl).reserveTimeout(Duration reserveTimeout) Sets how long a caller waits for a refill.step(long step) Sets the smallest reservation.
-
Method Details
-
step
Sets the smallest reservation.- Parameters:
step- the step, positive; default 100L- Returns:
- this builder
-
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
Sets how long the ids at hand should last.- Parameters:
lookahead- the lookahead, not negative; default 1s;Duration.ZEROdisables prefetching- Returns:
- this builder
-
maxBatch
Sets the largest reservation.- Parameters:
maxBatch- a positive multiple of the step; defaultBatchPolicy.defaultMaxBatch(long)of the step- Returns:
- this builder
-
reserveTimeout
Sets how long a caller waits for a refill.- Parameters:
reserveTimeout- the timeout, positive; default 3s- Returns:
- this builder
-
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
Builds the policy.- Returns:
- the policy
- Throws:
IllegalArgumentException- if a field is out of range
-