Class AimdLimitConfig.BuilderBase<BUILDER extends AimdLimitConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends AimdLimitConfig>

java.lang.Object
io.helidon.common.concurrency.limits.AimdLimitConfig.BuilderBase<BUILDER,PROTOTYPE>
Type Parameters:
BUILDER - type of the builder extending this abstract builder
PROTOTYPE - type of the prototype interface that would be built by Prototype.Builder.buildPrototype()
All Implemented Interfaces:
Prototype.Builder<BUILDER,PROTOTYPE>, ConfigBuilderSupport.ConfiguredBuilder<BUILDER,PROTOTYPE>
Direct Known Subclasses:
AimdLimitConfig.Builder
Enclosing interface:
AimdLimitConfig

public abstract static class AimdLimitConfig.BuilderBase<BUILDER extends AimdLimitConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends AimdLimitConfig> extends Object implements ConfigBuilderSupport.ConfiguredBuilder<BUILDER,PROTOTYPE>
Fluent API builder base for AimdLimit.
  • Constructor Details

    • BuilderBase

      protected BuilderBase()
      Protected to support extensibility.
  • Method Details

    • from

      public BUILDER from(AimdLimitConfig prototype)
      Update this builder from an existing prototype instance. This method disables automatic service discovery.
      Parameters:
      prototype - existing prototype to update this builder from
      Returns:
      updated builder instance
    • from

      public BUILDER from(AimdLimitConfig.BuilderBase<?,?> builder)
      Update this builder from an existing prototype builder instance.
      Parameters:
      builder - existing builder prototype to update this builder from
      Returns:
      updated builder instance
    • config

      public BUILDER config(Config config)
      Update builder from configuration (node of this type). If a value is present in configuration, it would override currently configured values.
      Specified by:
      config in interface ConfigBuilderSupport.ConfiguredBuilder<BUILDER extends AimdLimitConfig.BuilderBase<BUILDER,PROTOTYPE>,PROTOTYPE extends AimdLimitConfig>
      Parameters:
      config - configuration instance used to obtain values to update this builder
      Returns:
      updated builder instance
    • backoffRatio

      public BUILDER backoffRatio(double backoffRatio)
      Backoff ratio to use for the algorithm. The value must be within [0.5, 1.0).
      Parameters:
      backoffRatio - backoff ratio
      Returns:
      updated builder instance
      See Also:
    • initialLimit

      public BUILDER initialLimit(int initialLimit)
      Initial limit. The value must be within [minLimit(), maxLimit()].
      Parameters:
      initialLimit - initial limit
      Returns:
      updated builder instance
      See Also:
    • maxLimit

      public BUILDER maxLimit(int maxLimit)
      Maximal limit. The value must be same or higher than minLimit().
      Parameters:
      maxLimit - maximal limit
      Returns:
      updated builder instance
      See Also:
    • minLimit

      public BUILDER minLimit(int minLimit)
      Minimal limit. The value must be same or lower than maxLimit().
      Parameters:
      minLimit - minimal limit
      Returns:
      updated builder instance
      See Also:
    • timeout

      public BUILDER timeout(Duration timeout)
      Timeout that when exceeded is the same as if the task failed.
      Parameters:
      timeout - task timeout, defaults to 5 seconds
      Returns:
      updated builder instance
      See Also:
    • clearClock

      public BUILDER clearClock()
      Clear existing value of this property.
      Returns:
      updated builder instance
      See Also:
    • clock

      public BUILDER clock(Supplier<Long> clock)
      A clock that supplies nanosecond time.
      Parameters:
      clock - supplier of current nanoseconds, defaults to System.nanoTime()
      Returns:
      updated builder instance
      See Also:
    • name

      public BUILDER name(String name)
      Name of this instance.
      Parameters:
      name - name of the instance
      Returns:
      updated builder instance
      See Also:
    • queueLength

      public BUILDER queueLength(int queueLength)
      How many requests can be enqueued waiting for a permit after the max limit is reached. Note that this may not be an exact behavior due to concurrent invocations. We use Semaphore.getQueueLength() in the AimdLimit implementation. Default value is 0. If set to {code 0}, there is no queueing.
      Parameters:
      queueLength - number of requests to enqueue
      Returns:
      updated builder instance
      See Also:
    • queueTimeout

      public BUILDER queueTimeout(Duration queueTimeout)
      How long to wait for a permit when enqueued. Defaults to "PT1S"
      Parameters:
      queueTimeout - duration of the timeout
      Returns:
      updated builder instance
      See Also:
    • fair

      public BUILDER fair(boolean fair)
      Whether the Semaphore should be Semaphore.isFair(). Defaults to false.
      Parameters:
      fair - whether this should be a fair semaphore
      Returns:
      updated builder instance
      See Also:
    • enableMetrics

      public BUILDER enableMetrics(boolean enableMetrics)
      Whether to collect metrics for the AIMD implementation.
      Parameters:
      enableMetrics - metrics flag
      Returns:
      updated builder instance
      See Also:
    • backoffRatio

      public double backoffRatio()
      Backoff ratio to use for the algorithm. The value must be within [0.5, 1.0).
      Returns:
      the backoff ratio
    • initialLimit

      public int initialLimit()
      Initial limit. The value must be within [minLimit(), maxLimit()].
      Returns:
      the initial limit
    • maxLimit

      public int maxLimit()
      Maximal limit. The value must be same or higher than minLimit().
      Returns:
      the max limit
    • minLimit

      public int minLimit()
      Minimal limit. The value must be same or lower than maxLimit().
      Returns:
      the min limit
    • timeout

      public Duration timeout()
      Timeout that when exceeded is the same as if the task failed.
      Returns:
      the timeout
    • clock

      public Optional<Supplier<Long>> clock()
      A clock that supplies nanosecond time.
      Returns:
      the clock
    • name

      public String name()
      Name of this instance.
      Returns:
      the name
    • queueLength

      public int queueLength()
      How many requests can be enqueued waiting for a permit after the max limit is reached. Note that this may not be an exact behavior due to concurrent invocations. We use Semaphore.getQueueLength() in the AimdLimit implementation. Default value is 0. If set to {code 0}, there is no queueing.
      Returns:
      the queue length
    • queueTimeout

      public Duration queueTimeout()
      How long to wait for a permit when enqueued. Defaults to "PT1S"
      Returns:
      the queue timeout
    • fair

      public boolean fair()
      Whether the Semaphore should be Semaphore.isFair(). Defaults to false.
      Returns:
      the fair
    • enableMetrics

      public boolean enableMetrics()
      Whether to collect metrics for the AIMD implementation.
      Returns:
      the enable metrics
    • config

      public Optional<Config> config()
      If this instance was configured, this would be the config instance used.
      Returns:
      config node used to configure this builder, or empty if not configured
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • preBuildPrototype

      protected void preBuildPrototype()
      Handles providers and decorators.
    • validatePrototype

      protected void validatePrototype()
      Validates required properties.