Skip to content

Commit 778a00b

Browse files
committed
util: Remove MultiChildLB.getImmutableChildMap()
No usages actually needed a map nor a copy.
1 parent c120e36 commit 778a00b

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
import com.google.common.annotations.VisibleForTesting;
2828
import com.google.common.collect.ImmutableList;
29-
import com.google.common.collect.ImmutableMap;
3029
import io.grpc.Attributes;
3130
import io.grpc.ConnectivityState;
3231
import io.grpc.EquivalentAddressGroup;
@@ -281,11 +280,6 @@ protected final Helper getHelper() {
281280
return helper;
282281
}
283282

284-
@VisibleForTesting
285-
public final ImmutableMap<Object, ChildLbState> getImmutableChildMap() {
286-
return ImmutableMap.copyOf(childLbStates);
287-
}
288-
289283
@VisibleForTesting
290284
public final Collection<ChildLbState> getChildLbStates() {
291285
return childLbStates.values();

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
import com.google.common.base.MoreObjects;
2929
import com.google.common.collect.HashMultiset;
30-
import com.google.common.collect.ImmutableMap;
3130
import com.google.common.collect.Multiset;
3231
import com.google.common.primitives.UnsignedInteger;
3332
import io.grpc.Attributes;
@@ -42,6 +41,7 @@
4241
import io.grpc.xds.client.XdsLogger.XdsLogLevel;
4342
import java.net.SocketAddress;
4443
import java.util.ArrayList;
44+
import java.util.Collection;
4545
import java.util.Collections;
4646
import java.util.HashMap;
4747
import java.util.HashSet;
@@ -213,7 +213,7 @@ protected void updateOverallBalancingState() {
213213
overallState = TRANSIENT_FAILURE;
214214
}
215215

216-
RingHashPicker picker = new RingHashPicker(syncContext, ring, getImmutableChildMap());
216+
RingHashPicker picker = new RingHashPicker(syncContext, ring, getChildLbStates());
217217
getHelper().updateBalancingState(overallState, picker);
218218
this.currentConnectivityState = overallState;
219219
}
@@ -345,13 +345,12 @@ private static final class RingHashPicker extends SubchannelPicker {
345345

346346
private RingHashPicker(
347347
SynchronizationContext syncContext, List<RingEntry> ring,
348-
ImmutableMap<Object, ChildLbState> subchannels) {
348+
Collection<ChildLbState> children) {
349349
this.syncContext = syncContext;
350350
this.ring = ring;
351-
pickableSubchannels = new HashMap<>(subchannels.size());
352-
for (Map.Entry<Object, ChildLbState> entry : subchannels.entrySet()) {
353-
ChildLbState childLbState = entry.getValue();
354-
pickableSubchannels.put((Endpoint)entry.getKey(),
351+
pickableSubchannels = new HashMap<>(children.size());
352+
for (ChildLbState childLbState : children) {
353+
pickableSubchannels.put((Endpoint)childLbState.getKey(),
355354
new SubchannelView(childLbState, childLbState.getCurrentState()));
356355
}
357356
}

0 commit comments

Comments
 (0)