Class DelegatingLoadBalancerBuilder<ResolvedAddress,C extends LoadBalancedConnection>
- Type Parameters:
ResolvedAddress- The resolved address type.C- The type of connection.
- All Implemented Interfaces:
LoadBalancerBuilder<ResolvedAddress,C>
LoadBalancerBuilder that delegates all methods to another LoadBalancerBuilder.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbackgroundExecutor(Executor backgroundExecutor) Set the backgroundExecutorto use for determining time and scheduling background tasks such as those associated with outlier detection.build()Builds theLoadBalancerFactoryconfigured by this builder.connectionSelectorPolicy(ConnectionSelectorPolicy<C> connectionSelectorPolicy) Set theConnectionSelectorPolicyto use with this load balancer.protected final LoadBalancerBuilder<ResolvedAddress,C> delegate()Returns theDelegatingLoadBalancerBuilderdelegate.loadBalancerObserver(LoadBalancerObserverFactory loadBalancerObserverFactory) Set theLoadBalancerObserverFactoryto use with this load balancer.loadBalancingPolicy(LoadBalancingPolicy<ResolvedAddress, C> loadBalancingPolicy) Set theloadBalancingPolicyto use with this load balancer.maxRandomSubsetSize(int maxUsed) Set the maximum number of healthy backends to load balance against using a random-subsetting strategy.minConnectionsPerHost(int minConnectionsPerHost) Set the minimum number of connections an active host should maintain in its pool.outlierDetectorConfig(OutlierDetectorConfig outlierDetectorConfig) Set theOutlierDetectorConfigto use with this load balancer.toString()
-
Constructor Details
-
DelegatingLoadBalancerBuilder
Creates a new builder which delegates to the providedLoadBalancerBuilder.- Parameters:
delegate- the delegate builder.
-
-
Method Details
-
delegate
Returns theDelegatingLoadBalancerBuilderdelegate.- Returns:
- Delegate
DelegatingLoadBalancerBuilder.
-
loadBalancingPolicy
public LoadBalancerBuilder<ResolvedAddress,C> loadBalancingPolicy(LoadBalancingPolicy<ResolvedAddress, C> loadBalancingPolicy) Description copied from interface:LoadBalancerBuilderSet theloadBalancingPolicyto use with this load balancer.- Specified by:
loadBalancingPolicyin interfaceLoadBalancerBuilder<ResolvedAddress,C extends LoadBalancedConnection> - Parameters:
loadBalancingPolicy- theloadBalancingPolicyto use- Returns:
this
-
loadBalancerObserver
public LoadBalancerBuilder<ResolvedAddress,C> loadBalancerObserver(@Nullable LoadBalancerObserverFactory loadBalancerObserverFactory) Description copied from interface:LoadBalancerBuilderSet theLoadBalancerObserverFactoryto use with this load balancer.- Specified by:
loadBalancerObserverin interfaceLoadBalancerBuilder<ResolvedAddress,C extends LoadBalancedConnection> - Parameters:
loadBalancerObserverFactory- theLoadBalancerObserverFactoryto use, ornullto not use an observer.- Returns:
- {code this}
-
outlierDetectorConfig
public LoadBalancerBuilder<ResolvedAddress,C> outlierDetectorConfig(OutlierDetectorConfig outlierDetectorConfig) Description copied from interface:LoadBalancerBuilderSet theOutlierDetectorConfigto use with this load balancer.The outlier detection system works in conjunction with the load balancing policy to attempt to avoid hosts that have been determined to be unhealthy or slow. The details of the selection process are determined by the
LoadBalancingPolicywhile the health status is determined by the outlier detection configuration.- Specified by:
outlierDetectorConfigin interfaceLoadBalancerBuilder<ResolvedAddress,C extends LoadBalancedConnection> - Parameters:
outlierDetectorConfig- theOutlierDetectorConfigto use, ornullto use the default outlier detection.- Returns:
- {code this}
- See Also:
-
maxRandomSubsetSize
Description copied from interface:LoadBalancerBuilderSet the maximum number of healthy backends to load balance against using a random-subsetting strategy. Note: If a backend within the subset is found to be unhealthy, another endpoint will be added until the unhealthy backend recovers, after which the subset will return to its original state.- Specified by:
maxRandomSubsetSizein interfaceLoadBalancerBuilder<ResolvedAddress,C extends LoadBalancedConnection> - Parameters:
maxUsed- the maximum number of healthy backends to use.- Returns:
this
-
backgroundExecutor
Description copied from interface:LoadBalancerBuilderSet the backgroundExecutorto use for determining time and scheduling background tasks such as those associated with outlier detection.- Specified by:
backgroundExecutorin interfaceLoadBalancerBuilder<ResolvedAddress,C extends LoadBalancedConnection> - Parameters:
backgroundExecutor-Executorto use as a time source and for scheduling background tasks.- Returns:
this.
-
connectionSelectorPolicy
public LoadBalancerBuilder<ResolvedAddress,C> connectionSelectorPolicy(ConnectionSelectorPolicy<C> connectionSelectorPolicy) Description copied from interface:LoadBalancerBuilderSet theConnectionSelectorPolicyto use with this load balancer.- Specified by:
connectionSelectorPolicyin interfaceLoadBalancerBuilder<ResolvedAddress,C extends LoadBalancedConnection> - Parameters:
connectionSelectorPolicy- the factory of connection selection strategies to use.- Returns:
this
-
minConnectionsPerHost
Description copied from interface:LoadBalancerBuilderSet the minimum number of connections an active host should maintain in its pool.Setting a minimum number of connections can help reduce the occurrences where connection establishment happens on the request path, thereby reducing tail latencies, particularly for links which are prone idle-connection closure. The tradeoff is that it may require tuning and will create more connection overhead overall.
Note: this is a best-effort setting. There are inherent uncertainties, race conditions, and assumptions that will cause the number of connections to transiently fall below the specified minimum. Currently, these include:
- At startup: implementations do not try to warm never-used pools to prevent unexpected resource usage.
- When warming fails: implementations do not attempt to recover from connection establishment failures to prevent infinite retry loops.
- Specified by:
minConnectionsPerHostin interfaceLoadBalancerBuilder<ResolvedAddress,C extends LoadBalancedConnection> - Parameters:
minConnectionsPerHost- the minimum number of connections a host should maintain.- Returns:
this
-
build
Description copied from interface:LoadBalancerBuilderBuilds theLoadBalancerFactoryconfigured by this builder.- Specified by:
buildin interfaceLoadBalancerBuilder<ResolvedAddress,C extends LoadBalancedConnection> - Returns:
- a new instance of
LoadBalancerFactorywith settings from this builder.
-
toString
-