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