Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public enum ClientDnsLookup {
USE_ALL_DNS_IPS("use_all_dns_ips"),
RESOLVE_CANONICAL_BOOTSTRAP_SERVERS_ONLY("resolve_canonical_bootstrap_servers_only");

private String clientDnsLookup;
private final String clientDnsLookup;

ClientDnsLookup(String clientDnsLookup) {
this.clientDnsLookup = clientDnsLookup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static List<InetSocketAddress> parseAndValidateAddresses(List<String> url
* some third-party applications still rely on this API to parse and validate addresses.
*/
public static List<InetSocketAddress> parseAndValidateAddresses(List<String> urls) {
return parseAndValidateAddresses(urls, ClientDnsLookup.DEFAULT);
return parseAndValidateAddresses(urls, ClientDnsLookup.USE_ALL_DNS_IPS);
}

public static List<InetSocketAddress> parseAndValidateAddresses(List<String> urls, ClientDnsLookup clientDnsLookup) {
Expand Down
4 changes: 2 additions & 2 deletions clients/src/main/java/org/apache/kafka/clients/Metadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,13 @@ public synchronized void incrementNodesTriedSinceLastSuccessfulRefresh() {
/**
* Whether the client should update the cluster metadata by resolving the bootstrap server again
* @param nowMs
* @return true if client hasn't refreshed cluster metadata for maxClusterMetadataExpireTimeMs and
* @return true if client is not in bootstrap mode and hasn't refreshed cluster metadata for maxClusterMetadataExpireTimeMs and
* has tried connecting to at least one node in current node set; or forceClusterMetadataUpdateFromBootstrap
* has been set by receiving stale metadata from a different cluster
*/
public synchronized boolean shouldUpdateClusterMetadataFromBootstrap(long nowMs) {
return (this.nodesTriedSinceLastSuccessfulRefresh >= 1 &&
this.lastSuccessfulRefreshMs + this.maxClusterMetadataExpireTimeMs <= nowMs) ||
(this.lastRefreshMs != 0 && this.lastSuccessfulRefreshMs + this.maxClusterMetadataExpireTimeMs <= nowMs)) ||
this.forceClusterMetadataUpdateFromBootstrap;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ public Node leastLoadedNode(long now) {

int offset = this.randOffset.nextInt(newNodes.size());
Node node = newNodes.get(offset);
log.info("Resolved bootstrap server again, randomly picked node {} as least loaded node from the resolved node set", node);
log.trace("Resolved bootstrap server again, randomly picked node {} as least loaded node from the resolved node set", node);

return node;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public class AdminClientConfig extends AbstractConfig {
METRICS_RECORDING_LEVEL_DOC)
.define(CLIENT_DNS_LOOKUP_CONFIG,
Type.STRING,
ClientDnsLookup.DEFAULT.toString(),
ClientDnsLookup.USE_ALL_DNS_IPS.toString(),
in(ClientDnsLookup.DEFAULT.toString(),
ClientDnsLookup.USE_ALL_DNS_IPS.toString(),
ClientDnsLookup.RESOLVE_CANONICAL_BOOTSTRAP_SERVERS_ONLY.toString()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public class ConsumerConfig extends AbstractConfig {
CommonClientConfigs.BOOTSTRAP_SERVERS_DOC)
.define(CLIENT_DNS_LOOKUP_CONFIG,
Type.STRING,
ClientDnsLookup.DEFAULT.toString(),
ClientDnsLookup.USE_ALL_DNS_IPS.toString(),
in(ClientDnsLookup.DEFAULT.toString(),
ClientDnsLookup.USE_ALL_DNS_IPS.toString(),
ClientDnsLookup.RESOLVE_CANONICAL_BOOTSTRAP_SERVERS_ONLY.toString()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public class ProducerConfig extends AbstractConfig {
CONFIG = new ConfigDef().define(BOOTSTRAP_SERVERS_CONFIG, Type.LIST, Collections.emptyList(), new ConfigDef.NonNullValidator(), Importance.HIGH, CommonClientConfigs.BOOTSTRAP_SERVERS_DOC)
.define(CLIENT_DNS_LOOKUP_CONFIG,
Type.STRING,
ClientDnsLookup.DEFAULT.toString(),
ClientDnsLookup.USE_ALL_DNS_IPS.toString(),
in(ClientDnsLookup.DEFAULT.toString(),
ClientDnsLookup.USE_ALL_DNS_IPS.toString(),
ClientDnsLookup.RESOLVE_CANONICAL_BOOTSTRAP_SERVERS_ONLY.toString()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ public void testResolveBootstrapAfterClusterMetadataTimeout() {
//bootstrap the metadata cache with some valid nodes
clusterMetadata.bootstrap(addresses, time.milliseconds());

clusterMetadata.requestClusterMetadataUpdateFromBootstrap();

//first time call leastLoadedNode on the created NetworkClient should pass since nodesTriedSinceLastSuccessfulRefresh is 0
clusterClient.leastLoadedNode(time.milliseconds());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ private static Cluster mockCluster(int controllerIndex) {

private static Cluster mockBootstrapCluster() {
return Cluster.bootstrap(ClientUtils.parseAndValidateAddresses(
Collections.singletonList("localhost:8121"), ClientDnsLookup.DEFAULT));
singletonList("localhost:8121"), ClientDnsLookup.USE_ALL_DNS_IPS));
}

private static AdminClientUnitTestEnv mockClientEnv(String... configVals) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1861,7 +1861,7 @@ public void testQuotaMetrics() {
Cluster cluster = TestUtils.singletonCluster("test", 1);
Node node = cluster.nodes().get(0);
NetworkClient client = new NetworkClient(selector, metadata, "mock", Integer.MAX_VALUE,
1000, 1000, 64 * 1024, 64 * 1024, 1000, ClientDnsLookup.DEFAULT,
1000, 1000, 64 * 1024, 64 * 1024, 1000, ClientDnsLookup.USE_ALL_DNS_IPS,
time, true, new ApiVersions(), throttleTimeSensor, new LogContext());

short apiVersionsResponseVersion = ApiKeys.API_VERSIONS.latestVersion();
Expand Down Expand Up @@ -3203,7 +3203,7 @@ private void testGetOffsetsForTimesWithError(Errors errorForP0,
TopicPartition t2p0 = new TopicPartition(topicName2, 0);
// Expect a metadata refresh.
metadata.bootstrap(ClientUtils.parseAndValidateAddresses(Collections.singletonList("1.1.1.1:1111"),
ClientDnsLookup.DEFAULT), time.milliseconds());
ClientDnsLookup.USE_ALL_DNS_IPS), time.milliseconds());

Map<String, Integer> partitionNumByTopic = new HashMap<>();
partitionNumByTopic.put(topicName, 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public void testQuotaMetrics() throws Exception {
Cluster cluster = TestUtils.singletonCluster("test", 1);
Node node = cluster.nodes().get(0);
NetworkClient client = new NetworkClient(selector, metadata, "mock", Integer.MAX_VALUE,
1000, 1000, 64 * 1024, 64 * 1024, 1000, ClientDnsLookup.DEFAULT,
1000, 1000, 64 * 1024, 64 * 1024, 1000, ClientDnsLookup.USE_ALL_DNS_IPS,
time, true, new ApiVersions(), throttleTimeSensor, logContext);

short apiVersionsResponseVersion = ApiKeys.API_VERSIONS.latestVersion();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ protected static ConfigDef baseConfigDef() {
Importance.HIGH, BOOTSTRAP_SERVERS_DOC)
.define(CLIENT_DNS_LOOKUP_CONFIG,
Type.STRING,
ClientDnsLookup.DEFAULT.toString(),
ClientDnsLookup.USE_ALL_DNS_IPS.toString(),
in(ClientDnsLookup.DEFAULT.toString(),
ClientDnsLookup.USE_ALL_DNS_IPS.toString(),
ClientDnsLookup.RESOLVE_CANONICAL_BOOTSTRAP_SERVERS_ONLY.toString()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class ControllerChannelManager(controllerContext: ControllerContext,
Selectable.USE_DEFAULT_BUFFER_SIZE,
Selectable.USE_DEFAULT_BUFFER_SIZE,
config.requestTimeoutMs,
ClientDnsLookup.DEFAULT,
ClientDnsLookup.USE_ALL_DNS_IPS,
time,
false,
new ApiVersions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ object TransactionMarkerChannelManager {
Selectable.USE_DEFAULT_BUFFER_SIZE,
config.socketReceiveBufferBytes,
config.requestTimeoutMs,
ClientDnsLookup.DEFAULT,
ClientDnsLookup.USE_ALL_DNS_IPS,
time,
false,
new ApiVersions,
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/kafka/server/KafkaServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ class KafkaServer(val config: KafkaConfig, time: Time = Time.SYSTEM, threadNameP
Selectable.USE_DEFAULT_BUFFER_SIZE,
Selectable.USE_DEFAULT_BUFFER_SIZE,
config.requestTimeoutMs,
ClientDnsLookup.DEFAULT,
ClientDnsLookup.USE_ALL_DNS_IPS,
time,
false,
new ApiVersions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class ReplicaFetcherBlockingSend(sourceBroker: BrokerEndPoint,
Selectable.USE_DEFAULT_BUFFER_SIZE,
brokerConfig.replicaSocketReceiveBufferBytes,
brokerConfig.requestTimeoutMs,
ClientDnsLookup.DEFAULT,
ClientDnsLookup.USE_ALL_DNS_IPS,
time,
false,
new ApiVersions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ private class ReplicaFetcherBlockingSend(sourceNode: Node,
Selectable.USE_DEFAULT_BUFFER_SIZE,
consumerConfig.getInt(ConsumerConfig.RECEIVE_BUFFER_CONFIG),
consumerConfig.getInt(ConsumerConfig.REQUEST_TIMEOUT_MS_CONFIG),
ClientDnsLookup.DEFAULT,
ClientDnsLookup.USE_ALL_DNS_IPS,
time,
false,
new ApiVersions,
Expand Down