Class MultiChildLoadBalancer
java.lang.Object
io.grpc.LoadBalancer
io.grpc.util.MultiChildLoadBalancer
- Direct Known Subclasses:
RoundRobinLoadBalancer
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 TypeClassDescriptionprotected static classclassThis represents the state of load balancer children.protected static classEndpoint is an optimization to quickly lookup and compare EquivalentAddressGroup address sets.Nested classes/interfaces inherited from class 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 TypeFieldDescriptionprivate List<MultiChildLoadBalancer.ChildLbState> protected ConnectivityStateprivate final LoadBalancer.Helperprivate static final Loggerprotected final LoadBalancerProviderprotected boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionacceptResolvedAddresses(LoadBalancer.ResolvedAddresses resolvedAddresses) Override to completely replace the default logic or to do additional activities.protected final MultiChildLoadBalancer.AcceptResolvedAddrRetValacceptResolvedAddressesInternal(LoadBalancer.ResolvedAddresses resolvedAddresses) This does the work to update the child map and calculate which children have been removed.protected static ConnectivityStateaggregateState(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.ChildLbStatecreateChildLbState(Object key) Override to create an instance of a subclass.getChildLbState(Object key) protected final LoadBalancer.Helperprotected final List<MultiChildLoadBalancer.ChildLbState> Filters out non-ready child load balancers (subchannels).voidhandleNameResolutionError(Status error) Handle the name resolution error.voidshutdown()The channel asks the load-balancer to shutdown.protected final voidshutdownRemoved(List<MultiChildLoadBalancer.ChildLbState> removedChildren) private List<MultiChildLoadBalancer.ChildLbState> updateChildrenWithResolvedAddresses(Map<Object, LoadBalancer.ResolvedAddresses> newChildAddresses) Returns removed children.protected abstract voidUsing 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 LoadBalancer
canHandleEmptyAddressListFromNameResolution, handleResolvedAddresses, handleSubchannelState, requestConnection
-
Field Details
-
logger
-
childLbStates
-
helper
-
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:
acceptResolvedAddressesin classLoadBalancer- Parameters:
resolvedAddresses- the resolved server addresses, attributes, and config.- Returns:
trueif the resolved addresses were accepted.falseif rejected.
-
handleNameResolutionError
Handle the name resolution error. Override if you need special handling.- Specified by:
handleNameResolutionErrorin classLoadBalancer- Parameters:
error- a non-OK status
-
shutdown
public void shutdown()Description copied from class:LoadBalancerThe 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:
shutdownin classLoadBalancer
-
acceptResolvedAddressesInternal
protected final MultiChildLoadBalancer.AcceptResolvedAddrRetVal acceptResolvedAddressesInternal(LoadBalancer.ResolvedAddresses resolvedAddresses) This does the work to update the child map and calculate which children have been removed. You must callupdateOverallBalancingState()to update the picker and callshutdownRemoved(List)to shutdown the endpoints that have been removed. -
updateChildrenWithResolvedAddresses
private List<MultiChildLoadBalancer.ChildLbState> updateChildrenWithResolvedAddresses(Map<Object, LoadBalancer.ResolvedAddresses> newChildAddresses) Returns removed children. -
shutdownRemoved
-
aggregateState
@Nullable protected static ConnectivityState aggregateState(@Nullable ConnectivityState overallState, ConnectivityState childState) -
getHelper
-
getChildLbStates
-
getChildLbState
-
getChildLbStateEag
-
getReadyChildren
Filters out non-ready child load balancers (subchannels).
-