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 Summary
ConstructorsModifierConstructorDescriptionprotected
Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected final @Nullable EventExecutor
executor()
Returns theEventExecutor
to use to execute tasks for computing new weights.executor
(EventExecutor executor) Sets theEventExecutor
to use to execute tasks for computing new weights.rampingUpInterval
(Duration rampingUpInterval) Sets the interval between weight updates during ramp up.protected final long
Returns the interval between weight updates during ramp up.rampingUpIntervalMillis
(long rampingUpIntervalMillis) Sets the interval between weight updates during ramp up.rampingUpTaskWindow
(Duration rampingUpTaskWindow) Sets the window for combining weight update tasks.protected final long
Returns the window for combining weight update tasks.rampingUpTaskWindowMillis
(long rampingUpTaskWindowMillis) Sets the window for combining weight update tasks.protected final Ticker
ticker()
Returns theTicker
to use to measure time.Sets theTicker
to use to measure time.Returns the timestamp function to use to get the creation time of the given candidate.timestampFunction
(Function<? super T, @Nullable Long> timestampFunction) Sets the timestamp function to use to get the creation time of the given candidate.protected final int
Returns the total number of steps to compute weights for a given candidate while ramping up.totalSteps
(int totalSteps) Sets the total number of steps to compute weights for a given candidate while ramping up.protected final void
validate()
Validates the properties of this builder.protected final WeightTransition
<T> Returns theWeightTransition
which will be used to compute the weight at each step while ramping up.final SELF
weightTransition
(WeightTransition<T> transition) Sets theWeightTransition
which will be used to compute the weight at each step while ramping up.
-
Constructor Details
-
AbstractRampingUpLoadBalancerBuilder
protected AbstractRampingUpLoadBalancerBuilder()Creates a new instance.
-
-
Method Details
-
weightTransition
Sets theWeightTransition
which will be used to compute the weight at each step while ramping up.WeightTransition.linear()
is used by default. -
weightTransition
Returns theWeightTransition
which will be used to compute the weight at each step while ramping up. -
executor
Sets theEventExecutor
to use to execute tasks for computing new weights. AnEventLoop
fromCommonPools.workerGroup()
is used by default. -
executor
Returns theEventExecutor
to use to execute tasks for computing new weights. -
rampingUpInterval
Sets the interval between weight updates during ramp up. 2000L millis is used by default. -
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
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
Sets the window for combining weight update tasks. If more than one candidate are added within therampingUpTaskWindow
, the weights of them are ramped up together. If there's already a scheduled job and new candidates are added within therampingUpTaskWindow
, they are also ramped up together. This is an example of how it works whenrampingUpTaskWindow
is 500 milliseconds andrampingUpIntervalMillis
is 2000 milliseconds:
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.---------------------------------------------------------------------------------------------------- A B C D t0 t1 t2 t3 t4 ---------------------------------------------------------------------------------------------------- 0ms t0 + 200ms t0 + 1000ms t0 + 1800ms t0 + 2000ms
-
rampingUpTaskWindowMillis
Sets the window for combining weight update tasks. If more than one candidate are added within therampingUpTaskWindowMillis
, the weights of them are ramped up together. If there's already a scheduled job and new candidates are added within therampingUpTaskWindow
, they are also ramped up together. This is an example of how it works whenrampingUpTaskWindowMillis
is 500 milliseconds andrampingUpIntervalMillis
is 2000 milliseconds:
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.---------------------------------------------------------------------------------------------------- A B C D t0 t1 t2 t3 t4 ---------------------------------------------------------------------------------------------------- 0ms t0 + 200ms t0 + 1000ms t0 + 1800ms t0 + 2000ms
-
rampingUpTaskWindowMillis
protected final long rampingUpTaskWindowMillis()Returns the window for combining weight update tasks. -
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. Ifnull
is returned or the timestamp function is not set, the timestamp is set to the current time when the candidate is added. -
timestampFunction
Returns the timestamp function to use to get the creation time of the given candidate. -
ticker
Sets theTicker
to use to measure time.Ticker.systemTicker()
is used by default. -
ticker
Returns theTicker
to use to measure time. -
validate
protected final void validate()Validates the properties of this builder.
-