Class AbstractRampingUpLoadBalancerBuilder<T,SELF extends AbstractRampingUpLoadBalancerBuilder<T,SELF>>

java.lang.Object
com.linecorp.armeria.common.loadbalancer.AbstractRampingUpLoadBalancerBuilder<T,SELF>
Direct Known Subclasses:
RampingUpLoadBalancerBuilder, WeightRampingUpStrategyBuilder

@UnstableApi public abstract class AbstractRampingUpLoadBalancerBuilder<T,SELF extends AbstractRampingUpLoadBalancerBuilder<T,SELF>> extends Object
A skeletal builder implementation for building a ramping up LoadBalancer.
  • Constructor Details

    • AbstractRampingUpLoadBalancerBuilder

      protected AbstractRampingUpLoadBalancerBuilder()
      Creates a new instance.
  • Method Details

    • weightTransition

      public final SELF weightTransition(WeightTransition<T> transition)
      Sets the WeightTransition which will be used to compute the weight at each step while ramping up. WeightTransition.linear() is used by default.
    • weightTransition

      protected final WeightTransition<T> weightTransition()
      Returns the WeightTransition which will be used to compute the weight at each step while ramping up.
    • executor

      public SELF executor(EventExecutor executor)
      Sets the EventExecutor to use to execute tasks for computing new weights. An EventLoop from CommonPools.workerGroup() is used by default.
    • executor

      @Nullable protected final @Nullable EventExecutor executor()
      Returns the EventExecutor to use to execute tasks for computing new weights.
    • rampingUpInterval

      public SELF rampingUpInterval(Duration rampingUpInterval)
      Sets the interval between weight updates during ramp up. 2000L millis is used by default.
    • rampingUpIntervalMillis

      public SELF rampingUpIntervalMillis(long rampingUpIntervalMillis)
      Sets the interval between weight updates during ramp up. 2000L millis is used by default.
    • rampingUpIntervalMillis

      protected final long rampingUpIntervalMillis()
      Returns the interval between weight updates during ramp up.
    • totalSteps

      public SELF totalSteps(int totalSteps)
      Sets the total number of steps to compute weights for a given candidate while ramping up. 10 is used by default.
    • totalSteps

      protected final int totalSteps()
      Returns the total number of steps to compute weights for a given candidate while ramping up.
    • rampingUpTaskWindow

      public SELF rampingUpTaskWindow(Duration rampingUpTaskWindow)
      Sets the window for combining weight update tasks. If more than one candidate are added within the rampingUpTaskWindow, the weights of them are ramped up together. If there's already a scheduled job and new candidates are added within the rampingUpTaskWindow, they are also ramped up together. This is an example of how it works when rampingUpTaskWindow is 500 milliseconds and rampingUpIntervalMillis is 2000 milliseconds:
      
       ----------------------------------------------------------------------------------------------------
           A         B                             C                                       D
           t0        t1                            t2                                      t3         t4
       ----------------------------------------------------------------------------------------------------
           0ms       t0 + 200ms                    t0 + 1000ms                          t0 + 1800ms  t0 + 2000ms
       
      A and B are ramped up right away when they are added and they are ramped up together at t4. C is ramped up alone every 2000 milliseconds. D is ramped up together with A and B at t4.
    • rampingUpTaskWindowMillis

      public SELF rampingUpTaskWindowMillis(long rampingUpTaskWindowMillis)
      Sets the window for combining weight update tasks. If more than one candidate are added within the rampingUpTaskWindowMillis, the weights of them are ramped up together. If there's already a scheduled job and new candidates are added within the rampingUpTaskWindow, they are also ramped up together. This is an example of how it works when rampingUpTaskWindowMillis is 500 milliseconds and rampingUpIntervalMillis is 2000 milliseconds:
      
       ----------------------------------------------------------------------------------------------------
           A         B                             C                                       D
           t0        t1                            t2                                      t3         t4
       ----------------------------------------------------------------------------------------------------
           0ms       t0 + 200ms                    t0 + 1000ms                          t0 + 1800ms  t0 + 2000ms
       
      A and B are ramped up right away when they are added and they are ramped up together at t4. C is ramped up alone every 2000 milliseconds. D is ramped up together with A and B at t4.
    • rampingUpTaskWindowMillis

      protected final long rampingUpTaskWindowMillis()
      Returns the window for combining weight update tasks.
    • timestampFunction

      public SELF timestampFunction(Function<? super T,@Nullable Long> timestampFunction)
      Sets the timestamp function to use to get the creation time of the given candidate. The timestamp is used to calculate the ramp up weight of the candidate. If null is returned or the timestamp function is not set, the timestamp is set to the current time when the candidate is added.
    • timestampFunction

      protected final Function<T,Long> timestampFunction()
      Returns the timestamp function to use to get the creation time of the given candidate.
    • ticker

      public SELF ticker(Ticker ticker)
      Sets the Ticker to use to measure time. Ticker.systemTicker() is used by default.
    • ticker

      protected final Ticker ticker()
      Returns the Ticker to use to measure time.
    • validate

      protected final void validate()
      Validates the properties of this builder.