Skip to content

Commit

Permalink
util: Remove MultiChildLB.getImmutableChildMap()
Browse files Browse the repository at this point in the history
No usages actually needed a map nor a copy.
  • Loading branch information
ejona86 committed Aug 17, 2024
1 parent c120e36 commit 778a00b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
6 changes: 0 additions & 6 deletions util/src/main/java/io/grpc/util/MultiChildLoadBalancer.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import io.grpc.Attributes;
import io.grpc.ConnectivityState;
import io.grpc.EquivalentAddressGroup;
Expand Down Expand Up @@ -281,11 +280,6 @@ protected final Helper getHelper() {
return helper;
}

@VisibleForTesting
public final ImmutableMap<Object, ChildLbState> getImmutableChildMap() {
return ImmutableMap.copyOf(childLbStates);
}

@VisibleForTesting
public final Collection<ChildLbState> getChildLbStates() {
return childLbStates.values();
Expand Down
13 changes: 6 additions & 7 deletions xds/src/main/java/io/grpc/xds/RingHashLoadBalancer.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

import com.google.common.base.MoreObjects;
import com.google.common.collect.HashMultiset;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Multiset;
import com.google.common.primitives.UnsignedInteger;
import io.grpc.Attributes;
Expand All @@ -42,6 +41,7 @@
import io.grpc.xds.client.XdsLogger.XdsLogLevel;
import java.net.SocketAddress;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -213,7 +213,7 @@ protected void updateOverallBalancingState() {
overallState = TRANSIENT_FAILURE;
}

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

private RingHashPicker(
SynchronizationContext syncContext, List<RingEntry> ring,
ImmutableMap<Object, ChildLbState> subchannels) {
Collection<ChildLbState> children) {
this.syncContext = syncContext;
this.ring = ring;
pickableSubchannels = new HashMap<>(subchannels.size());
for (Map.Entry<Object, ChildLbState> entry : subchannels.entrySet()) {
ChildLbState childLbState = entry.getValue();
pickableSubchannels.put((Endpoint)entry.getKey(),
pickableSubchannels = new HashMap<>(children.size());
for (ChildLbState childLbState : children) {
pickableSubchannels.put((Endpoint)childLbState.getKey(),
new SubchannelView(childLbState, childLbState.getCurrentState()));
}
}
Expand Down

0 comments on commit 778a00b

Please sign in to comment.