Class WeightRampingUpStrategyBuilder

java.lang.Object
com.linecorp.armeria.client.endpoint.WeightRampingUpStrategyBuilder

@UnstableApi public final class WeightRampingUpStrategyBuilder extends Object
Builds a weight ramping up EndpointSelectionStrategy which ramps the weight of newly added Endpoints. The Endpoint is selected using weighted random distribution.
  • Constructor Details

    • WeightRampingUpStrategyBuilder

      public WeightRampingUpStrategyBuilder()
  • Method Details

    • transition

      Sets the EndpointWeightTransition which will be used to compute the weight at each step while ramping up. EndpointWeightTransition.linear() is used by default.
    • executor

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

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

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

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

      public WeightRampingUpStrategyBuilder rampingUpTaskWindow(Duration rampingUpTaskWindow)
      Sets the window for combining weight update tasks. If more than one Endpoint are added within the rampingUpTaskWindow, the weights of them are ramped up together. If there's already a scheduled job and new Endpoints 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 WeightRampingUpStrategyBuilder rampingUpTaskWindowMillis(long rampingUpTaskWindowMillis)
      Sets the window for combining weight update tasks. If more than one Endpoint are added within the rampingUpTaskWindowMillis, the weights of them are ramped up together. If there's already a scheduled job and new Endpoints 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.
    • build

      public EndpointSelectionStrategy build()
      Returns a newly-created weight ramping up EndpointSelectionStrategy which ramps the weight of newly added Endpoints. The Endpoint is selected using weighted random distribution.