Skip to content

Commit 4cb6465

Browse files
committed
util: MultiChildLB children know if they are active
No need to look up in the map to see if they are still a child.
1 parent 0138977 commit 4cb6465

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

util/src/main/java/io/grpc/util/MultiChildLoadBalancer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ protected class ChildLbStateHelper extends ForwardingLoadBalancerHelper {
414414
@Override
415415
public void updateBalancingState(final ConnectivityState newState,
416416
final SubchannelPicker newPicker) {
417-
if (!childLbStates.containsKey(key)) {
417+
if (currentState == SHUTDOWN) {
418418
return;
419419
}
420420

xds/src/main/java/io/grpc/xds/ClusterManagerLoadBalancer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,16 +260,16 @@ private class ClusterManagerChildHelper extends ChildLbStateHelper {
260260
@Override
261261
public void updateBalancingState(final ConnectivityState newState,
262262
final SubchannelPicker newPicker) {
263-
// If we are already in the process of resolving addresses, the overall balancing state
264-
// will be updated at the end of it, and we don't need to trigger that update here.
265-
if (getChildLbState(getKey()) == null) {
263+
if (getCurrentState() == ConnectivityState.SHUTDOWN) {
266264
return;
267265
}
268266

269267
// Subchannel picker and state are saved, but will only be propagated to the channel
270268
// when the child instance exits deactivated state.
271269
setCurrentState(newState);
272270
setCurrentPicker(newPicker);
271+
// If we are already in the process of resolving addresses, the overall balancing state
272+
// will be updated at the end of it, and we don't need to trigger that update here.
273273
if (deletionTimer == null && !resolvingAddresses) {
274274
updateOverallBalancingState();
275275
}

0 commit comments

Comments
 (0)