kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject [kafka] branch trunk updated: KAFKA-7779; Avoid unnecessary loop iteration in leastLoadedNode (#6081)
Date Mon, 29 Apr 2019 14:53:41 GMT
This is an automated email from the ASF dual-hosted git repository.

jgus pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 3af3f42  KAFKA-7779; Avoid unnecessary loop iteration in leastLoadedNode (#6081)
3af3f42 is described below

commit 3af3f425c6301cbd1282155a29b5683b9dc54c18
Author: huxi <huxi_2b@hotmail.com>
AuthorDate: Mon Apr 29 22:53:24 2019 +0800

    KAFKA-7779; Avoid unnecessary loop iteration in leastLoadedNode (#6081)
    
    In NetworkClient.leastLoadedNode, we invoke `isReady` to  check if an established connection
exists for the given node. `isReady` checks whether metadata needs to be updated also which
wants to make metadata request first priority. However, if the to-be-sent request is metadata
request, then we do not have to check this otherwise the loop in `leastLoadedNode` will do
a complete iteration until the final node is selected.
    
    Reviewers: Jason Gustafson <jason@confluent.io>
---
 clients/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 36b9966..2d012a2 100644
--- a/clients/src/main/java/org/apache/kafka/clients/NetworkClient.java
+++ b/clients/src/main/java/org/apache/kafka/clients/NetworkClient.java
@@ -652,7 +652,7 @@ public class NetworkClient implements KafkaClient {
             int idx = (offset + i) % nodes.size();
             Node node = nodes.get(idx);
             int currInflight = this.inFlightRequests.count(node.idString());
-            if (currInflight == 0 && isReady(node, now)) {
+            if (currInflight == 0 && canSendRequest(node.idString(), now)) {
                 // if we find an established connection with no in-flight requests we can
stop right away
                 log.trace("Found least loaded node {} connected with no in-flight requests",
node);
                 return node;


Mime
View raw message