Skip to content

Commit 196e118

Browse files
larry-safranejona86
andcommitted
xds: Use XdsDependencyManager for XdsNameResolver
Contributes to the gRFC A74 effort. https://github.com/grpc/proposal/blob/master/A74-xds-config-tears.md Co-authored-by: Eric Anderson <ejona@google.com>
1 parent fca1d3c commit 196e118

File tree

8 files changed

+579
-475
lines changed

8 files changed

+579
-475
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,22 @@ final class XdsAttributes {
3636
static final Attributes.Key<ObjectPool<XdsClient>> XDS_CLIENT_POOL =
3737
Attributes.Key.create("io.grpc.xds.XdsAttributes.xdsClientPool");
3838

39+
/**
40+
* Attribute key for passing around the latest XdsConfig across NameResolver/LoadBalancers.
41+
*/
42+
@NameResolver.ResolutionResultAttr
43+
static final Attributes.Key<XdsConfig> XDS_CONFIG =
44+
Attributes.Key.create("io.grpc.xds.XdsAttributes.xdsConfig");
45+
46+
47+
/**
48+
* Attribute key for passing around the XdsDependencyManager across NameResolver/LoadBalancers.
49+
*/
50+
@NameResolver.ResolutionResultAttr
51+
static final Attributes.Key<XdsConfig.XdsClusterSubscriptionRegistry>
52+
XDS_CLUSTER_SUBSCRIPT_REGISTRY =
53+
Attributes.Key.create("io.grpc.xds.XdsAttributes.xdsConfig.XdsClusterSubscriptionRegistry");
54+
3955
/**
4056
* Attribute key for obtaining the global provider that provides atomics for aggregating
4157
* outstanding RPCs sent to each cluster.

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

Lines changed: 13 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;
3029
import java.util.Map;
3130
import java.util.Objects;
31+
import java.util.Set;
3232

3333
/**
3434
* Represents the xDS configuration tree for a specified Listener.
@@ -178,13 +178,22 @@ public boolean equals(Object obj) {
178178
public StatusOr<EdsUpdate> getEndpoint() {
179179
return endpoint;
180180
}
181+
182+
@Override
183+
public String toString() {
184+
if (endpoint.hasValue()) {
185+
return "EndpointConfig{endpoint=" + endpoint.getValue() + "}";
186+
} else {
187+
return "EndpointConfig{error=" + endpoint.getStatus() + "}";
188+
}
189+
}
181190
}
182191

183192
// The list of leaf clusters for an aggregate cluster.
184193
static final class AggregateConfig implements ClusterChild {
185-
private final List<String> leafNames;
194+
private final Set<String> leafNames;
186195

187-
public AggregateConfig(List<String> leafNames) {
196+
public AggregateConfig(Set<String> leafNames) {
188197
this.leafNames = checkNotNull(leafNames, "leafNames");
189198
}
190199

@@ -234,6 +243,7 @@ XdsConfigBuilder setVirtualHost(VirtualHost virtualHost) {
234243
XdsConfig build() {
235244
checkNotNull(listener, "listener");
236245
checkNotNull(route, "route");
246+
checkNotNull(virtualHost, "virtualHost");
237247
return new XdsConfig(listener, route, clusters, virtualHost);
238248
}
239249
}

0 commit comments

Comments
 (0)