cds: ClusterImplLoadBalancer to use acceptResolvedAddresses() (#9571)

This is part of the API migration away from handleResolvedAddresses().
This commit is contained in:
Terry Wilson 2022-10-10 15:55:57 -07:00 committed by GitHub
parent ab78f39f23
commit 458e06fafa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 9 deletions

View File

@ -102,7 +102,7 @@ final class ClusterImplLoadBalancer 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);
Attributes attributes = resolvedAddresses.getAttributes(); Attributes attributes = resolvedAddresses.getAttributes();
if (xdsClientPool == null) { if (xdsClientPool == null) {
@ -134,6 +134,7 @@ final class ClusterImplLoadBalancer extends LoadBalancer {
.setAttributes(attributes) .setAttributes(attributes)
.setLoadBalancingPolicyConfig(config.childPolicy.getConfig()) .setLoadBalancingPolicyConfig(config.childPolicy.getConfig())
.build()); .build());
return true;
} }
@Override @Override
@ -162,11 +163,6 @@ final class ClusterImplLoadBalancer extends LoadBalancer {
} }
} }
@Override
public boolean canHandleEmptyAddressListFromNameResolution() {
return true;
}
/** /**
* A decorated {@link LoadBalancer.Helper} that applies configurations for connections * A decorated {@link LoadBalancer.Helper} that applies configurations for connections
* or requests to endpoints in the cluster. * or requests to endpoints in the cluster.

View File

@ -282,7 +282,7 @@ public class ClusterImplLoadBalancerTest {
config = new ClusterImplConfig(CLUSTER, EDS_SERVICE_NAME, LRS_SERVER_INFO, null, config = new ClusterImplConfig(CLUSTER, EDS_SERVICE_NAME, LRS_SERVER_INFO, null,
Collections.singletonList(DropOverload.create("lb", 1_000_000)), Collections.singletonList(DropOverload.create("lb", 1_000_000)),
new PolicySelection(weightedTargetProvider, weightedTargetConfig), null); new PolicySelection(weightedTargetProvider, weightedTargetConfig), null);
loadBalancer.handleResolvedAddresses( loadBalancer.acceptResolvedAddresses(
ResolvedAddresses.newBuilder() ResolvedAddresses.newBuilder()
.setAddresses(Collections.singletonList(endpoint)) .setAddresses(Collections.singletonList(endpoint))
.setAttributes( .setAttributes(
@ -571,7 +571,7 @@ public class ClusterImplLoadBalancerTest {
private void deliverAddressesAndConfig(List<EquivalentAddressGroup> addresses, private void deliverAddressesAndConfig(List<EquivalentAddressGroup> addresses,
ClusterImplConfig config) { ClusterImplConfig config) {
loadBalancer.handleResolvedAddresses( loadBalancer.acceptResolvedAddresses(
ResolvedAddresses.newBuilder() ResolvedAddresses.newBuilder()
.setAddresses(addresses) .setAddresses(addresses)
.setAttributes( .setAttributes(
@ -677,10 +677,11 @@ public class ClusterImplLoadBalancerTest {
} }
@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