Package io.grpc.util
Class MultiChildLoadBalancer
java.lang.Object
io.grpc.LoadBalancer
io.grpc.util.MultiChildLoadBalancer
A base load balancing policy for those policies which has multiple children such as
ClusterManager or the petiole policies. For internal use only.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
This represents the state of load balancer children.protected static class
Endpoint is an optimization to quickly lookup and compare EquivalentAddressGroup address sets.Nested classes/interfaces inherited from class io.grpc.LoadBalancer
LoadBalancer.CreateSubchannelArgs, LoadBalancer.ErrorPicker, LoadBalancer.Factory, LoadBalancer.FixedResultPicker, LoadBalancer.Helper, LoadBalancer.PickDetailsConsumer, LoadBalancer.PickResult, LoadBalancer.PickSubchannelArgs, LoadBalancer.ResolvedAddresses, LoadBalancer.Subchannel, LoadBalancer.SubchannelPicker, LoadBalancer.SubchannelStateListener
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ConnectivityState
protected final LoadBalancerProvider
protected boolean
Fields inherited from class io.grpc.LoadBalancer
ATTR_HEALTH_CHECKING_CONFIG, DISABLE_SUBCHANNEL_RECONNECT_KEY, EMPTY_PICKER, HAS_HEALTH_PRODUCER_LISTENER_KEY, HEALTH_CONSUMER_LISTENER_ARG_KEY, IS_PETIOLE_POLICY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionacceptResolvedAddresses
(LoadBalancer.ResolvedAddresses resolvedAddresses) Override to completely replace the default logic or to do additional activities.protected static ConnectivityState
aggregateState
(ConnectivityState overallState, ConnectivityState childState) protected Map
<Object, LoadBalancer.ResolvedAddresses> createChildAddressesMap
(LoadBalancer.ResolvedAddresses resolvedAddresses) Override to utilize parsing of the policy configuration or alternative helper/lb generation.protected MultiChildLoadBalancer.ChildLbState
createChildLbState
(Object key) Override to create an instance of a subclass.protected final LoadBalancer.Helper
protected final List
<MultiChildLoadBalancer.ChildLbState> Filters out non-ready child load balancers (subchannels).void
handleNameResolutionError
(Status error) Handle the name resolution error.void
shutdown()
The channel asks the load-balancer to shutdown.protected abstract void
Using the state of all children will calculate the current connectivity state, update fields, generate a picker and then callLoadBalancer.Helper.updateBalancingState(ConnectivityState, SubchannelPicker)
.Methods inherited from class io.grpc.LoadBalancer
canHandleEmptyAddressListFromNameResolution, handleResolvedAddresses, handleSubchannelState, requestConnection
-
Field Details
-
resolvingAddresses
protected boolean resolvingAddresses -
pickFirstLbProvider
-
currentConnectivityState
-
-
Constructor Details
-
MultiChildLoadBalancer
-
-
Method Details
-
updateOverallBalancingState
protected abstract void updateOverallBalancingState()Using the state of all children will calculate the current connectivity state, update fields, generate a picker and then callLoadBalancer.Helper.updateBalancingState(ConnectivityState, SubchannelPicker)
. -
createChildAddressesMap
protected Map<Object,LoadBalancer.ResolvedAddresses> createChildAddressesMap(LoadBalancer.ResolvedAddresses resolvedAddresses) Override to utilize parsing of the policy configuration or alternative helper/lb generation. Override this if keys are not Endpoints or if child policies have configuration. Null map values preserve the child without delivering the child an update. -
createChildLbState
Override to create an instance of a subclass. -
acceptResolvedAddresses
Override to completely replace the default logic or to do additional activities.- Overrides:
acceptResolvedAddresses
in classLoadBalancer
- Parameters:
resolvedAddresses
- the resolved server addresses, attributes, and config.- Returns:
true
if the resolved addresses were accepted.false
if rejected.
-
handleNameResolutionError
Handle the name resolution error. Override if you need special handling.- Specified by:
handleNameResolutionError
in classLoadBalancer
- Parameters:
error
- a non-OK status
-
shutdown
public void shutdown()Description copied from class:LoadBalancer
The channel asks the load-balancer to shutdown. No more methods on this class will be called after this method. The implementation should shutdown all Subchannels and OOB channels, and do any other cleanup as necessary.- Specified by:
shutdown
in classLoadBalancer
-
aggregateState
@Nullable protected static ConnectivityState aggregateState(@Nullable ConnectivityState overallState, ConnectivityState childState) -
getHelper
-
getChildLbStates
-
getReadyChildren
Filters out non-ready child load balancers (subchannels).
-