kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jkr...@apache.org
Subject kafka git commit: KAFKA-1919: Always update the metadata, when a metadata response is received to ensure we back off.
Date Sat, 21 Feb 2015 23:40:24 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk fbb115497 -> 19031823c


KAFKA-1919: Always update the metadata, when a metadata response is received to ensure we
back off.


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/19031823
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/19031823
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/19031823

Branch: refs/heads/trunk
Commit: 19031823c15cb3a0e5fcecaaf5de79c09b5300ed
Parents: fbb1154
Author: Jay Kreps <jay.kreps@gmail.com>
Authored: Wed Feb 4 17:01:51 2015 -0800
Committer: Jay Kreps <jay.kreps@gmail.com>
Committed: Sat Feb 21 15:39:23 2015 -0800

----------------------------------------------------------------------
 clients/src/main/java/org/apache/kafka/clients/Metadata.java | 8 ++++++++
 .../main/java/org/apache/kafka/clients/NetworkClient.java    | 6 ++++--
 2 files changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/19031823/clients/src/main/java/org/apache/kafka/clients/Metadata.java
----------------------------------------------------------------------
diff --git a/clients/src/main/java/org/apache/kafka/clients/Metadata.java b/clients/src/main/java/org/apache/kafka/clients/Metadata.java
index b8cdd14..e8afecd 100644
--- a/clients/src/main/java/org/apache/kafka/clients/Metadata.java
+++ b/clients/src/main/java/org/apache/kafka/clients/Metadata.java
@@ -148,6 +148,14 @@ public final class Metadata {
     }
     
     /**
+     * Record an attempt to update the metadata that failed. We need to keep track of this
+     * to avoid retrying immediately.
+     */
+    public synchronized void failedUpdate(long now) {
+        this.lastRefreshMs = now;
+    }
+    
+    /**
      * @return The current metadata version
      */
     public synchronized int version() {

http://git-wip-us.apache.org/repos/asf/kafka/blob/19031823/clients/src/main/java/org/apache/kafka/clients/NetworkClient.java
----------------------------------------------------------------------
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 fef90a0..a7fa4a9 100644
--- a/clients/src/main/java/org/apache/kafka/clients/NetworkClient.java
+++ b/clients/src/main/java/org/apache/kafka/clients/NetworkClient.java
@@ -381,10 +381,12 @@ public class NetworkClient implements KafkaClient {
         Cluster cluster = response.cluster();
         // don't update the cluster if there are no valid nodes...the topic we want may still
be in the process of being
         // created which means we will get errors and no nodes until it exists
-        if (cluster.nodes().size() > 0)
+        if (cluster.nodes().size() > 0) {
             this.metadata.update(cluster, now);
-        else
+        } else {
             log.trace("Ignoring empty metadata response with correlation id {}.", header.correlationId());
+            this.metadata.failedUpdate(now);
+        }
     }
 
     /**


Mime
View raw message