Revert "xds: XdsNR should be subscribing to clusters with XdsDepManager"

This reverts commit 2604ce8a55 as part of
reverting 297ab05efe.
This commit is contained in:
Eric Anderson 2025-07-14 13:47:24 -07:00
parent 3b63af411d
commit 98e4252e34
1 changed files with 9 additions and 25 deletions

View File

@ -548,7 +548,7 @@ final class XdsNameResolver extends NameResolver {
if (clusterRefs.get(cluster).refCount.get() != 0) {
throw new AssertionError();
}
clusterRefs.remove(cluster).close();
clusterRefs.remove(cluster);
if (resolveState.lastConfigOrStatus.hasValue()) {
updateResolutionResult(resolveState.lastConfigOrStatus.getValue());
} else {
@ -793,13 +793,9 @@ final class XdsNameResolver extends NameResolver {
clusterRefs.get(cluster).refCount.incrementAndGet();
} else {
if (clusterNameMap.containsKey(cluster)) {
assert cluster.startsWith("cluster:");
XdsConfig.Subscription subscription =
xdsDependencyManager.subscribeToCluster(cluster.substring("cluster:".length()));
clusterRefs.put(
cluster,
ClusterRefState.forCluster(
new AtomicInteger(1), clusterNameMap.get(cluster), subscription));
ClusterRefState.forCluster(new AtomicInteger(1), clusterNameMap.get(cluster)));
}
if (rlsPluginConfigMap.containsKey(cluster)) {
clusterRefs.put(
@ -830,7 +826,7 @@ final class XdsNameResolver extends NameResolver {
for (String cluster : deletedClusters) {
int count = clusterRefs.get(cluster).refCount.decrementAndGet();
if (count == 0) {
clusterRefs.remove(cluster).close();
clusterRefs.remove(cluster);
shouldUpdateResult = true;
}
}
@ -883,7 +879,7 @@ final class XdsNameResolver extends NameResolver {
for (String cluster : existingClusters) {
int count = clusterRefs.get(cluster).refCount.decrementAndGet();
if (count == 0) {
clusterRefs.remove(cluster).close();
clusterRefs.remove(cluster);
}
}
existingClusters = null;
@ -969,18 +965,15 @@ final class XdsNameResolver extends NameResolver {
final String traditionalCluster;
@Nullable
final RlsPluginConfig rlsPluginConfig;
@Nullable
final XdsConfig.Subscription subscription;
private ClusterRefState(
AtomicInteger refCount, @Nullable String traditionalCluster,
@Nullable RlsPluginConfig rlsPluginConfig, @Nullable XdsConfig.Subscription subscription) {
@Nullable RlsPluginConfig rlsPluginConfig) {
this.refCount = refCount;
checkArgument(traditionalCluster == null ^ rlsPluginConfig == null,
"There must be exactly one non-null value in traditionalCluster and pluginConfig");
this.traditionalCluster = traditionalCluster;
this.rlsPluginConfig = rlsPluginConfig;
this.subscription = subscription;
}
private Map<String, ?> toLbPolicy() {
@ -1000,21 +993,12 @@ final class XdsNameResolver extends NameResolver {
}
}
private void close() {
if (subscription != null) {
subscription.close();
}
static ClusterRefState forCluster(AtomicInteger refCount, String name) {
return new ClusterRefState(refCount, name, null);
}
static ClusterRefState forCluster(
AtomicInteger refCount, String name, XdsConfig.Subscription subscription) {
return new ClusterRefState(refCount, name, null, checkNotNull(subscription, "subscription"));
}
static ClusterRefState forRlsPlugin(
AtomicInteger refCount,
RlsPluginConfig rlsPluginConfig) {
return new ClusterRefState(refCount, null, rlsPluginConfig, null);
static ClusterRefState forRlsPlugin(AtomicInteger refCount, RlsPluginConfig rlsPluginConfig) {
return new ClusterRefState(refCount, null, rlsPluginConfig);
}
}
}