kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ewe...@apache.org
Subject kafka git commit: KAFKA-3255: Added unit tests for NetworkClient.connectionDelay(Node node, long now)
Date Mon, 22 Feb 2016 18:13:28 GMT
Repository: kafka
Updated Branches:
  refs/heads/trunk 49fd0ceb0 -> d2527af99


KAFKA-3255: Added unit tests for NetworkClient.connectionDelay(Node node, long now)

Author: Frank Scholten <frank@frankscholten.nl>

Reviewers: Eno Thereska <eno.thereska@gmail.com>, Ewen Cheslack-Postava <ewen@confluent.io>

Closes #941 from frankscholten/tests/cluster-connection-states


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

Branch: refs/heads/trunk
Commit: d2527af99a9bb1007f7fe63a0cd7d27a55182857
Parents: 49fd0ce
Author: Frank Scholten <frank@frankscholten.nl>
Authored: Mon Feb 22 10:13:11 2016 -0800
Committer: Ewen Cheslack-Postava <me@ewencp.org>
Committed: Mon Feb 22 10:13:11 2016 -0800

----------------------------------------------------------------------
 .../kafka/clients/ClusterConnectionStates.java  |  9 ------
 .../apache/kafka/clients/NetworkClientTest.java | 29 ++++++++++++++++++++
 2 files changed, 29 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/d2527af9/clients/src/main/java/org/apache/kafka/clients/ClusterConnectionStates.java
----------------------------------------------------------------------
diff --git a/clients/src/main/java/org/apache/kafka/clients/ClusterConnectionStates.java b/clients/src/main/java/org/apache/kafka/clients/ClusterConnectionStates.java
index a8101da..ad35e20 100644
--- a/clients/src/main/java/org/apache/kafka/clients/ClusterConnectionStates.java
+++ b/clients/src/main/java/org/apache/kafka/clients/ClusterConnectionStates.java
@@ -95,15 +95,6 @@ final class ClusterConnectionStates {
     }
 
     /**
-     * Return true iff we are in the process of connecting
-     * @param id The id of the connection
-     */
-    public boolean isConnecting(String id) {
-        NodeConnectionState state = nodeState.get(id);
-        return state != null && state.state == ConnectionState.CONNECTING;
-    }
-
-    /**
      * Enter the connected state for the given connection
      * @param id The connection identifier
      */

http://git-wip-us.apache.org/repos/asf/kafka/blob/d2527af9/clients/src/test/java/org/apache/kafka/clients/NetworkClientTest.java
----------------------------------------------------------------------
diff --git a/clients/src/test/java/org/apache/kafka/clients/NetworkClientTest.java b/clients/src/test/java/org/apache/kafka/clients/NetworkClientTest.java
index 12136d8..18f7ecb 100644
--- a/clients/src/test/java/org/apache/kafka/clients/NetworkClientTest.java
+++ b/clients/src/test/java/org/apache/kafka/clients/NetworkClientTest.java
@@ -175,6 +175,35 @@ public class NetworkClientTest {
         assertEquals("There should be NO leastloadednode", leastNode, null);
         
     }
+
+    @Test
+    public void testConnectionDelay() {
+        long now = time.milliseconds();
+        long delay = client.connectionDelay(node, now);
+
+        assertEquals(0, delay);
+    }
+
+    @Test
+    public void testConnectionDelayConnected() {
+        awaitReady(client, node);
+
+        long now = time.milliseconds();
+        long delay = client.connectionDelay(node, now);
+
+        assertEquals(Long.MAX_VALUE, delay);
+    }
+
+    @Test
+    public void testConnectionDelayDisconnected() {
+        awaitReady(client, node);
+
+        selector.close(node.idString());
+        client.poll(requestTimeoutMs, time.milliseconds());
+        long delay = client.connectionDelay(node, time.milliseconds());
+
+        assertEquals(reconnectBackoffMsTest, delay);
+    }
     
     private static class TestCallbackHandler implements RequestCompletionHandler {
         public boolean executed = false;


Mime
View raw message