kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jjko...@apache.org
Subject [34/37] git commit: kafka-1571; MetadataTest hangs; patched by Jun Rao; reviewed by Guozhang Wang
Date Tue, 05 Aug 2014 23:00:31 GMT
kafka-1571; MetadataTest hangs; patched by Jun Rao; reviewed by Guozhang Wang


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

Branch: refs/heads/transactional_messaging
Commit: 1d2e776d8c4ffbe59e40985ecfc3b010d99519d1
Parents: f8d521a
Author: Jun Rao <junrao@gmail.com>
Authored: Mon Aug 4 21:19:49 2014 -0700
Committer: Jun Rao <junrao@gmail.com>
Committed: Mon Aug 4 21:19:49 2014 -0700

----------------------------------------------------------------------
 .../apache/kafka/clients/producer/MetadataTest.java   | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/1d2e776d/clients/src/test/java/org/apache/kafka/clients/producer/MetadataTest.java
----------------------------------------------------------------------
diff --git a/clients/src/test/java/org/apache/kafka/clients/producer/MetadataTest.java b/clients/src/test/java/org/apache/kafka/clients/producer/MetadataTest.java
index 543304c..4547bfc 100644
--- a/clients/src/test/java/org/apache/kafka/clients/producer/MetadataTest.java
+++ b/clients/src/test/java/org/apache/kafka/clients/producer/MetadataTest.java
@@ -17,6 +17,7 @@ import static org.junit.Assert.assertTrue;
 
 import org.apache.kafka.clients.producer.internals.Metadata;
 import org.apache.kafka.common.Cluster;
+import org.apache.kafka.common.errors.TimeoutException;
 import org.apache.kafka.test.TestUtils;
 import org.junit.Test;
 
@@ -40,9 +41,7 @@ public class MetadataTest {
         Thread t2 = asyncFetch(topic);
         assertTrue("Awaiting update", t1.isAlive());
         assertTrue("Awaiting update", t2.isAlive());
-        // keep updating the metadata until no need to
-        while (metadata.timeToNextUpdate(time) == 0)
-            metadata.update(TestUtils.singletonCluster(topic, 1), time);
+        metadata.update(TestUtils.singletonCluster(topic, 1), time);
         t1.join();
         t2.join();
         assertFalse("No update needed.", metadata.timeToNextUpdate(time) == 0);
@@ -53,8 +52,13 @@ public class MetadataTest {
     private Thread asyncFetch(final String topic) {
         Thread thread = new Thread() {
             public void run() {
-                while (metadata.fetch().partitionsForTopic(topic) == null)
-                    metadata.awaitUpdate(metadata.requestUpdate(), Long.MAX_VALUE);
+                while (metadata.fetch().partitionsForTopic(topic) == null) {
+                    try {
+                        metadata.awaitUpdate(metadata.requestUpdate(), refreshBackoffMs);
+                    } catch(TimeoutException e) {
+                        // let it go
+                    }
+                }
             }
         };
         thread.start();


Mime
View raw message