util: MultiChildLB children know if they are active

No need to look up in the map to see if they are still a child.
This commit is contained in:
Eric Anderson 2024-07-29 11:31:18 -07:00
parent 01389774d5
commit 4cb6465194
2 changed files with 4 additions and 4 deletions

View File

@ -414,7 +414,7 @@ public abstract class MultiChildLoadBalancer extends LoadBalancer {
@Override @Override
public void updateBalancingState(final ConnectivityState newState, public void updateBalancingState(final ConnectivityState newState,
final SubchannelPicker newPicker) { final SubchannelPicker newPicker) {
if (!childLbStates.containsKey(key)) { if (currentState == SHUTDOWN) {
return; return;
} }

View File

@ -260,9 +260,7 @@ class ClusterManagerLoadBalancer extends MultiChildLoadBalancer {
@Override @Override
public void updateBalancingState(final ConnectivityState newState, public void updateBalancingState(final ConnectivityState newState,
final SubchannelPicker newPicker) { final SubchannelPicker newPicker) {
// If we are already in the process of resolving addresses, the overall balancing state if (getCurrentState() == ConnectivityState.SHUTDOWN) {
// will be updated at the end of it, and we don't need to trigger that update here.
if (getChildLbState(getKey()) == null) {
return; return;
} }
@ -270,6 +268,8 @@ class ClusterManagerLoadBalancer extends MultiChildLoadBalancer {
// when the child instance exits deactivated state. // when the child instance exits deactivated state.
setCurrentState(newState); setCurrentState(newState);
setCurrentPicker(newPicker); setCurrentPicker(newPicker);
// If we are already in the process of resolving addresses, the overall balancing state
// will be updated at the end of it, and we don't need to trigger that update here.
if (deletionTimer == null && !resolvingAddresses) { if (deletionTimer == null && !resolvingAddresses) {
updateOverallBalancingState(); updateOverallBalancingState();
} }