Skip to content

Commit d4f1a26

Browse files
committed
Restore cluster leaf names to a List
1 parent 44043a6 commit d4f1a26

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
import io.grpc.xds.XdsRouteConfigureResource.RdsUpdate;
2727
import java.io.Closeable;
2828
import java.util.HashMap;
29+
import java.util.List;
2930
import java.util.Map;
3031
import java.util.Objects;
31-
import java.util.Set;
3232

3333
/**
3434
* Represents the xDS configuration tree for a specified Listener.
@@ -206,9 +206,9 @@ public String toString() {
206206

207207
// The list of leaf clusters for an aggregate cluster.
208208
static final class AggregateConfig implements ClusterChild {
209-
private final Set<String> leafNames;
209+
private final List<String> leafNames;
210210

211-
public AggregateConfig(Set<String> leafNames) {
211+
public AggregateConfig(List<String> leafNames) {
212212
this.leafNames = checkNotNull(leafNames, "leafNames");
213213
}
214214

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ private Set<String> addTopLevelClustersToBuilder(
472472
XdsConfig.XdsClusterConfig.ClusterChild child;
473473
switch (cdsUpdate.clusterType()) {
474474
case AGGREGATE:
475-
Set<String> leafNames = new HashSet<>();
475+
List<String> leafNames = new ArrayList<>();
476476
addLeafNames(leafNames, cdsUpdate);
477477
child = new AggregateConfig(leafNames);
478478
leafClusterNames.addAll(leafNames);
@@ -508,15 +508,27 @@ private Set<String> addTopLevelClustersToBuilder(
508508
return leafClusterNames;
509509
}
510510

511-
private void addLeafNames(Set<String> leafNames, XdsClusterResource.CdsUpdate cdsUpdate) {
511+
/**
512+
* Recursively adds the leaf names of the clusters in the aggregate cluster to the list.
513+
* @param leafNames priority ordered list of leaf names we will add to
514+
* @param cdsUpdate the cluster config being processed
515+
*/
516+
private void addLeafNames(List<String> leafNames, XdsClusterResource.CdsUpdate cdsUpdate) {
512517
for (String cluster : cdsUpdate.prioritizedClusterNames()) {
513518
if (leafNames.contains(cluster)) {
514519
continue;
515520
}
521+
516522
StatusOr<XdsClusterResource.CdsUpdate> data = getCluster(cluster).getData();
517-
if (data == null || !data.hasValue() || data.getValue() == null) {
523+
if (data == null) {
518524
continue;
519525
}
526+
if (!data.hasValue()) {
527+
leafNames.add(cluster);
528+
continue;
529+
}
530+
assert data.getValue() != null;
531+
520532
if (data.getValue().clusterType() == ClusterType.AGGREGATE) {
521533
addLeafNames(leafNames, data.getValue());
522534
} else {

0 commit comments

Comments
 (0)