Skip to content

Commit 3170896

Browse files
dhruvilshah3hachikuji
authored andcommitted
KAFKA-8962; Use least loaded node for AdminClient#describeTopics (#7421)
Allow routing of `AdminClient#describeTopics` to any broker in the cluster than just the controller, so that we don't create a hotspot for this API call. `AdminClient#describeTopics` uses the broker's metadata cache which is asynchronously maintained, so routing to brokers other than the controller is not expected to have a significant difference in terms of metadata consistency; all metadata requests are eventually consistent. This patch also fixes a few flaky test failures. Reviewers: Ismael Juma <[email protected]>, José Armando García Sancio <[email protected]>, Jason Gustafson <[email protected]>
1 parent 6c0aed2 commit 3170896

File tree

6 files changed

+141
-101
lines changed

6 files changed

+141
-101
lines changed

clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1537,7 +1537,7 @@ public DescribeTopicsResult describeTopics(final Collection<String> topicNames,
15371537
}
15381538
final long now = time.milliseconds();
15391539
Call call = new Call("describeTopics", calcDeadlineMs(now, options.timeoutMs()),
1540-
new ControllerNodeProvider()) {
1540+
new LeastLoadedNodeProvider()) {
15411541

15421542
private boolean supportsDisablingTopicCreation = true;
15431543

core/src/main/scala/kafka/controller/KafkaController.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ class KafkaController(val config: KafkaConfig,
790790
electionType: ElectionType,
791791
electionTrigger: ElectionTrigger
792792
): Map[TopicPartition, Either[Throwable, LeaderAndIsr]] = {
793-
info(s"Starting replica leader election ($electionType) for partitions ${partitions.mkString(",")} triggerd by $electionTrigger")
793+
info(s"Starting replica leader election ($electionType) for partitions ${partitions.mkString(",")} triggered by $electionTrigger")
794794
try {
795795
val strategy = electionType match {
796796
case ElectionType.PREFERRED => PreferredReplicaPartitionLeaderElectionStrategy

0 commit comments

Comments
 (0)