philipnee commented on code in PR #16629:
URL: https://github.com/apache/kafka/pull/16629#discussion_r1688567705
##########
clients/src/main/java/org/apache/kafka/clients/NetworkClient.java:
##########
@@ -1106,6 +1125,104 @@ private boolean isTelemetryApi(ApiKeys apiKey) {
return apiKey == ApiKeys.GET_TELEMETRY_SUBSCRIPTIONS || apiKey ==
ApiKeys.PUSH_TELEMETRY;
}
+ public static class BootstrapConfiguration {
+ public final List<String> bootstrapServers;
+ public final ClientDnsLookup clientDnsLookup;
+ public final long bootstrapResolveTimeoutMs;
+ private final boolean bootstrapDisabled;
+
+ public BootstrapConfiguration(final List<String> bootstrapServers,
+ final ClientDnsLookup clientDnsLookup,
+ final long bootstrapResolveTimeoutMs) {
+ this.bootstrapServers = bootstrapServers;
+ this.clientDnsLookup = clientDnsLookup;
+ this.bootstrapResolveTimeoutMs = bootstrapResolveTimeoutMs;
+ this.bootstrapDisabled = false;
+ }
+ }
+
+ private class BootstrapState {
+ private final Timer timer;
+ private final List<String> bootstrapServers;
+ private final ClientDnsLookup clientDnsLookup;
+ private final long dnsResolutionTimeoutMs;
+ private final boolean isDisabled;
+ private boolean isBootstrapped;
+
+ BootstrapState(BootstrapConfiguration bootstrapConfiguration) {
+ if (bootstrapConfiguration == null) {
+ this.dnsResolutionTimeoutMs = -1;
+ this.timer = null;
+ this.bootstrapServers = null;
+ this.clientDnsLookup = null;
+ this.isDisabled = true;
+ this.isBootstrapped = false;
+ } else {
+ this.dnsResolutionTimeoutMs =
bootstrapConfiguration.bootstrapResolveTimeoutMs;
+ this.timer =
time.timer(bootstrapConfiguration.bootstrapResolveTimeoutMs);
+ this.bootstrapServers =
bootstrapConfiguration.bootstrapServers;
+ this.clientDnsLookup = bootstrapConfiguration.clientDnsLookup;
+ this.isDisabled = bootstrapConfiguration.bootstrapDisabled;
+ }
+ }
+
+ List<InetSocketAddress> tryResolveAddresses() {
+ timer.update(time.milliseconds());
+
+ do {
Review Comment:
this will cause poll to block on this loop. Let's not do that. My initial
thought was doing the resolution once per poll(). DNS could take 10s of
minutes to get updated, and I think one use case was to let the application
continue to run, until bootstrap is completed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]