From bfe56c64b749a0c076a563ddb45127811ca2584a Mon Sep 17 00:00:00 2001 From: "yuhayang@linkedin.com" Date: Mon, 9 Dec 2024 12:51:09 -0800 Subject: [PATCH 1/3] ACTIONITEM-3738: Improve the log message for the "There are no nodes in the Kafka cluster" error. --- .../src/main/java/org/apache/kafka/clients/NetworkClient.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clients/src/main/java/org/apache/kafka/clients/NetworkClient.java b/clients/src/main/java/org/apache/kafka/clients/NetworkClient.java index 673e60d3434c7..7e2cf59c19c3a 100644 --- a/clients/src/main/java/org/apache/kafka/clients/NetworkClient.java +++ b/clients/src/main/java/org/apache/kafka/clients/NetworkClient.java @@ -888,7 +888,8 @@ public void close() { public Node leastLoadedNode(long now) { List nodes = this.metadataUpdater.fetchNodes(); if (nodes.isEmpty()) - throw new IllegalStateException("There are no nodes in the Kafka cluster"); + throw new IllegalStateException("metadataUpdater returned empty node list. " + + "The client may not have cluster info yet or there are no nodes in the Kafka cluster."); LeastLoadedNodeAlgorithm algo = this.leastLoadedNodeAlgorithm; if (algo == null) { throw new IllegalStateException("leastLoadedNodeAlgorithm cannot be null"); From c6a617f2f638a76ce5261007eeffacaef19210c1 Mon Sep 17 00:00:00 2001 From: "yuhayang@linkedin.com" Date: Mon, 9 Dec 2024 15:23:14 -0800 Subject: [PATCH 2/3] Improve error msg. --- .../src/main/java/org/apache/kafka/clients/NetworkClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/src/main/java/org/apache/kafka/clients/NetworkClient.java b/clients/src/main/java/org/apache/kafka/clients/NetworkClient.java index 7e2cf59c19c3a..656aded59be91 100644 --- a/clients/src/main/java/org/apache/kafka/clients/NetworkClient.java +++ b/clients/src/main/java/org/apache/kafka/clients/NetworkClient.java @@ -889,7 +889,7 @@ public Node leastLoadedNode(long now) { List nodes = this.metadataUpdater.fetchNodes(); if (nodes.isEmpty()) throw new IllegalStateException("metadataUpdater returned empty node list. " - + "The client may not have cluster info yet or there are no nodes in the Kafka cluster."); + + "The client is not able to connect to the cluster or there are no nodes in the Kafka cluster."); LeastLoadedNodeAlgorithm algo = this.leastLoadedNodeAlgorithm; if (algo == null) { throw new IllegalStateException("leastLoadedNodeAlgorithm cannot be null"); From e76f4eec04f75ff412f920c396dea327733a4027 Mon Sep 17 00:00:00 2001 From: "yuhayang@linkedin.com" Date: Mon, 9 Dec 2024 15:23:48 -0800 Subject: [PATCH 3/3] More improvements. --- .../src/main/java/org/apache/kafka/clients/NetworkClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/src/main/java/org/apache/kafka/clients/NetworkClient.java b/clients/src/main/java/org/apache/kafka/clients/NetworkClient.java index 656aded59be91..db3c283fbe643 100644 --- a/clients/src/main/java/org/apache/kafka/clients/NetworkClient.java +++ b/clients/src/main/java/org/apache/kafka/clients/NetworkClient.java @@ -889,7 +889,7 @@ public Node leastLoadedNode(long now) { List nodes = this.metadataUpdater.fetchNodes(); if (nodes.isEmpty()) throw new IllegalStateException("metadataUpdater returned empty node list. " - + "The client is not able to connect to the cluster or there are no nodes in the Kafka cluster."); + + "The client is not able to connect to the Kafka cluster or there are no nodes in the Kafka cluster."); LeastLoadedNodeAlgorithm algo = this.leastLoadedNodeAlgorithm; if (algo == null) { throw new IllegalStateException("leastLoadedNodeAlgorithm cannot be null");