xds: eliminate target name dependency in XdsClient and LRS client (#7498)

This commit is contained in:
Chengyuan Zhang 2020-10-08 17:23:46 -07:00 committed by GitHub
parent 0203256171
commit df95acda2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 6 additions and 20 deletions

View File

@ -71,7 +71,6 @@ final class LoadReportClient {
private LrsStream lrsStream;
LoadReportClient(
String targetName,
LoadStatsManager loadStatsManager,
XdsChannel xdsChannel,
Node node,
@ -87,7 +86,7 @@ final class LoadReportClient {
this.retryStopwatch = checkNotNull(stopwatchSupplier, "stopwatchSupplier").get();
this.node = checkNotNull(node, "node").toBuilder()
.addClientFeatures("envoy.lrs.supports_send_all_clusters").build();
logId = InternalLogId.allocate("lrs-client", targetName);
logId = InternalLogId.allocate("lrs-client", null);
logger = XdsLogger.withLogId(logId);
logger.log(XdsLogLevel.INFO, "Created");
}

View File

@ -104,7 +104,6 @@ final class XdsClientImpl2 extends XdsClient {
private final MessagePrinter respPrinter = new MessagePrinter();
private final InternalLogId logId;
private final XdsLogger logger;
private final String targetName; // TODO: delete me.
private final XdsChannel xdsChannel;
private final SynchronizationContext syncContext;
private final ScheduledExecutorService timeService;
@ -149,14 +148,12 @@ final class XdsClientImpl2 extends XdsClient {
private ScheduledHandle ldsRespTimer;
XdsClientImpl2(
String targetName,
XdsChannel channel,
Node node,
SynchronizationContext syncContext,
ScheduledExecutorService timeService,
BackoffPolicy.Provider backoffPolicyProvider,
Supplier<Stopwatch> stopwatchSupplier) {
this.targetName = checkNotNull(targetName, "targetName");
this.xdsChannel = checkNotNull(channel, "channel");
this.node = checkNotNull(node, "node");
this.syncContext = checkNotNull(syncContext, "syncContext");
@ -344,7 +341,6 @@ final class XdsClientImpl2 extends XdsClient {
logger.log(XdsLogLevel.INFO, "Turning on load reporting");
lrsClient =
new LoadReportClient(
targetName,
loadStatsManager,
xdsChannel,
node,

View File

@ -137,7 +137,6 @@ public final class XdsClientWrapperForServerSds {
timeService = SharedResourceHolder.get(timeServiceResource);
XdsClientImpl2 xdsClientImpl =
new XdsClientImpl2(
"",
channel,
node,
createSynchronizationContext(),

View File

@ -62,9 +62,9 @@ public final class XdsNameResolverProvider extends NameResolverProvider {
targetUri);
String name = targetPath.substring(1);
XdsClientPoolFactory xdsClientPoolFactory =
new RefCountedXdsClientPoolFactory(
name, args.getSynchronizationContext(), args.getScheduledExecutorService(),
new ExponentialBackoffPolicy.Provider(), GrpcUtil.STOPWATCH_SUPPLIER);
new RefCountedXdsClientPoolFactory(args.getSynchronizationContext(),
args.getScheduledExecutorService(), new ExponentialBackoffPolicy.Provider(),
GrpcUtil.STOPWATCH_SUPPLIER);
return new XdsNameResolver(
name, args.getServiceConfigParser(),
args.getSynchronizationContext(), xdsClientPoolFactory);
@ -90,19 +90,16 @@ public final class XdsNameResolverProvider extends NameResolverProvider {
}
static class RefCountedXdsClientPoolFactory implements XdsClientPoolFactory {
private final String serviceName;
private final SynchronizationContext syncContext;
private final ScheduledExecutorService timeService;
private final BackoffPolicy.Provider backoffPolicyProvider;
private final Supplier<Stopwatch> stopwatchSupplier;
RefCountedXdsClientPoolFactory(
String serviceName,
SynchronizationContext syncContext,
ScheduledExecutorService timeService,
BackoffPolicy.Provider backoffPolicyProvider,
Supplier<Stopwatch> stopwatchSupplier) {
this.serviceName = checkNotNull(serviceName, "serviceName");
this.syncContext = checkNotNull(syncContext, "syncContext");
this.timeService = checkNotNull(timeService, "timeService");
this.backoffPolicyProvider = checkNotNull(backoffPolicyProvider, "backoffPolicyProvider");
@ -115,8 +112,7 @@ public final class XdsNameResolverProvider extends NameResolverProvider {
XdsClientFactory xdsClientFactory = new XdsClientFactory() {
@Override
XdsClient createXdsClient() {
return new XdsClientImpl2(
serviceName, channel, bootstrapInfo.getNode(), syncContext, timeService,
return new XdsClientImpl2(channel, bootstrapInfo.getNode(), syncContext, timeService,
backoffPolicyProvider, stopwatchSupplier);
}
};

View File

@ -87,7 +87,6 @@ import org.mockito.MockitoAnnotations;
*/
@RunWith(JUnit4.class)
public class LoadReportClientTest {
private static final String TARGET_NAME = "lrs-test.example.com";
// bootstrap node identifier
private static final EnvoyProtoData.Node NODE =
EnvoyProtoData.Node.newBuilder()
@ -185,7 +184,6 @@ public class LoadReportClientTest {
.thenReturn(TimeUnit.SECONDS.toNanos(2L), TimeUnit.SECONDS.toNanos(20L));
lrsClient =
new LoadReportClient(
TARGET_NAME,
loadStatsManager,
new XdsChannel(channel, false),
NODE,

View File

@ -120,7 +120,6 @@ import org.mockito.MockitoAnnotations;
*/
@RunWith(JUnit4.class)
public class XdsClientImplTest2 {
private static final String TARGET_NAME = "hello.googleapis.com";
private static final String LDS_RESOURCE = "listener.googleapis.com";
private static final String RDS_RESOURCE = "route-configuration.googleapis.com";
private static final String CDS_RESOURCE = "cluster.googleapis.com";
@ -277,7 +276,6 @@ public class XdsClientImplTest2 {
xdsClient =
new XdsClientImpl2(
TARGET_NAME,
new XdsChannel(channel, /* useProtocolV3= */ true),
EnvoyProtoData.Node.newBuilder().build(),
syncContext,

View File

@ -196,7 +196,7 @@ public class XdsClientImplTestForListener {
cleanupRule.register(InProcessChannelBuilder.forName(serverName).directExecutor().build());
xdsClient =
new XdsClientImpl2("", new XdsChannel(channel, /* useProtocolV3= */ false), NODE,
new XdsClientImpl2(new XdsChannel(channel, /* useProtocolV3= */ false), NODE,
syncContext, fakeClock.getScheduledExecutorService(), backoffPolicyProvider,
fakeClock.getStopwatchSupplier());
// Only the connection to management server is established, no RPC request is sent until at