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
public void updateBalancingState(final ConnectivityState newState,
final SubchannelPicker newPicker) {
if (!childLbStates.containsKey(key)) {
if (currentState == SHUTDOWN) {
return;
}

View File

@ -260,9 +260,7 @@ class ClusterManagerLoadBalancer extends MultiChildLoadBalancer {
@Override
public void updateBalancingState(final ConnectivityState newState,
final SubchannelPicker 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 (getChildLbState(getKey()) == null) {
if (getCurrentState() == ConnectivityState.SHUTDOWN) {
return;
}
@ -270,6 +268,8 @@ class ClusterManagerLoadBalancer extends MultiChildLoadBalancer {
// when the child instance exits deactivated state.
setCurrentState(newState);
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) {
updateOverallBalancingState();
}