xds: cluster_resolver to use acceptResolvedAddresses() (#9615)

Part of a wider migration to migrate load balancers away from
handleResolvedAddresses().
This commit is contained in:
Terry Wilson 2022-10-13 13:27:51 -07:00 committed by GitHub
parent 6904f88a7d
commit 63f3787f86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -113,7 +113,7 @@ final class ClusterResolverLoadBalancer extends LoadBalancer {
} }
@Override @Override
public void handleResolvedAddresses(ResolvedAddresses resolvedAddresses) { public boolean acceptResolvedAddresses(ResolvedAddresses resolvedAddresses) {
logger.log(XdsLogLevel.DEBUG, "Received resolution result: {0}", resolvedAddresses); logger.log(XdsLogLevel.DEBUG, "Received resolution result: {0}", resolvedAddresses);
if (xdsClientPool == null) { if (xdsClientPool == null) {
xdsClientPool = resolvedAddresses.getAttributes().get(InternalXdsAttributes.XDS_CLIENT_POOL); xdsClientPool = resolvedAddresses.getAttributes().get(InternalXdsAttributes.XDS_CLIENT_POOL);
@ -127,6 +127,7 @@ final class ClusterResolverLoadBalancer extends LoadBalancer {
this.config = config; this.config = config;
delegate.handleResolvedAddresses(resolvedAddresses); delegate.handleResolvedAddresses(resolvedAddresses);
} }
return true;
} }
@Override @Override
@ -170,7 +171,7 @@ final class ClusterResolverLoadBalancer extends LoadBalancer {
} }
@Override @Override
public void handleResolvedAddresses(ResolvedAddresses resolvedAddresses) { public boolean acceptResolvedAddresses(ResolvedAddresses resolvedAddresses) {
this.resolvedAddresses = resolvedAddresses; this.resolvedAddresses = resolvedAddresses;
ClusterResolverConfig config = ClusterResolverConfig config =
(ClusterResolverConfig) resolvedAddresses.getLoadBalancingPolicyConfig(); (ClusterResolverConfig) resolvedAddresses.getLoadBalancingPolicyConfig();
@ -189,6 +190,7 @@ final class ClusterResolverLoadBalancer extends LoadBalancer {
clusterStates.put(instance.cluster, state); clusterStates.put(instance.cluster, state);
state.start(); state.start();
} }
return true;
} }
@Override @Override

View File

@ -1081,7 +1081,7 @@ public class ClusterResolverLoadBalancerTest {
} }
private void deliverLbConfig(ClusterResolverConfig config) { private void deliverLbConfig(ClusterResolverConfig config) {
loadBalancer.handleResolvedAddresses( loadBalancer.acceptResolvedAddresses(
ResolvedAddresses.newBuilder() ResolvedAddresses.newBuilder()
.setAddresses(Collections.<EquivalentAddressGroup>emptyList()) .setAddresses(Collections.<EquivalentAddressGroup>emptyList())
.setAttributes( .setAttributes(
@ -1325,10 +1325,11 @@ public class ClusterResolverLoadBalancerTest {
} }
@Override @Override
public void handleResolvedAddresses(ResolvedAddresses resolvedAddresses) { public boolean acceptResolvedAddresses(ResolvedAddresses resolvedAddresses) {
addresses = resolvedAddresses.getAddresses(); addresses = resolvedAddresses.getAddresses();
config = resolvedAddresses.getLoadBalancingPolicyConfig(); config = resolvedAddresses.getLoadBalancingPolicyConfig();
attributes = resolvedAddresses.getAttributes(); attributes = resolvedAddresses.getAttributes();
return true;
} }
@Override @Override