Skip to content

Commit

Permalink
util: MultiChildLB children know if they are active
Browse files Browse the repository at this point in the history
No need to look up in the map to see if they are still a child.
  • Loading branch information
ejona86 committed Aug 29, 2024
1 parent 0138977 commit 4cb6465
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ protected class ChildLbStateHelper extends ForwardingLoadBalancerHelper {
@Override
public void updateBalancingState(final ConnectivityState newState,
final SubchannelPicker newPicker) {
if (!childLbStates.containsKey(key)) {
if (currentState == SHUTDOWN) {
return;
}

Expand Down
6 changes: 3 additions & 3 deletions xds/src/main/java/io/grpc/xds/ClusterManagerLoadBalancer.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,16 +260,16 @@ private class ClusterManagerChildHelper extends ChildLbStateHelper {
@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;
}

// Subchannel picker and state are saved, but will only be propagated to the channel
// 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();
}
Expand Down

0 comments on commit 4cb6465

Please sign in to comment.