kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ij...@apache.org
Subject [kafka] branch trunk updated: KAFKA-6760: Fix response logging in the Controller (#4834)
Date Fri, 01 Jun 2018 23:40:21 GMT
This is an automated email from the ASF dual-hosted git repository.

ijuma 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 73e2cbb  KAFKA-6760: Fix response logging in the Controller (#4834)
73e2cbb is described below

commit 73e2cbbd8f56f70bd5ef4594adc3770fa5a402ce
Author: Mickael Maison <mimaison@users.noreply.github.com>
AuthorDate: Sat Jun 2 00:40:16 2018 +0100

    KAFKA-6760: Fix response logging in the Controller (#4834)
    
    - Override toString in LeaderAndIsrResponse and StopReplicaResponse
    - Add unit tests
    
    Reviewers: Ismael Juma <ismael@juma.me.uk>
---
 .../apache/kafka/common/requests/LeaderAndIsrResponse.java  |  9 +++++++++
 .../apache/kafka/common/requests/StopReplicaResponse.java   |  9 +++++++++
 .../kafka/common/requests/LeaderAndIsrResponseTest.java     | 13 +++++++++++++
 .../kafka/common/requests/StopReplicaResponseTest.java      | 13 +++++++++++++
 4 files changed, 44 insertions(+)

diff --git a/clients/src/main/java/org/apache/kafka/common/requests/LeaderAndIsrResponse.java
b/clients/src/main/java/org/apache/kafka/common/requests/LeaderAndIsrResponse.java
index c21f9a7..8e63245 100644
--- a/clients/src/main/java/org/apache/kafka/common/requests/LeaderAndIsrResponse.java
+++ b/clients/src/main/java/org/apache/kafka/common/requests/LeaderAndIsrResponse.java
@@ -119,4 +119,13 @@ public class LeaderAndIsrResponse extends AbstractResponse {
 
         return struct;
     }
+
+    @Override
+    public String toString() {
+        return "LeaderAndIsrResponse(" +
+                "responses=" + responses +
+                ", error=" + error +
+                ")";
+    }
+
 }
diff --git a/clients/src/main/java/org/apache/kafka/common/requests/StopReplicaResponse.java
b/clients/src/main/java/org/apache/kafka/common/requests/StopReplicaResponse.java
index 777416d..4e8efe9 100644
--- a/clients/src/main/java/org/apache/kafka/common/requests/StopReplicaResponse.java
+++ b/clients/src/main/java/org/apache/kafka/common/requests/StopReplicaResponse.java
@@ -115,4 +115,13 @@ public class StopReplicaResponse extends AbstractResponse {
         struct.set(ERROR_CODE, error.code());
         return struct;
     }
+
+    @Override
+    public String toString() {
+        return "StopReplicaResponse(" +
+                "responses=" + responses +
+                ", error=" + error +
+                ")";
+    }
+
 }
diff --git a/clients/src/test/java/org/apache/kafka/common/requests/LeaderAndIsrResponseTest.java
b/clients/src/test/java/org/apache/kafka/common/requests/LeaderAndIsrResponseTest.java
index 3eda778..c242555 100644
--- a/clients/src/test/java/org/apache/kafka/common/requests/LeaderAndIsrResponseTest.java
+++ b/clients/src/test/java/org/apache/kafka/common/requests/LeaderAndIsrResponseTest.java
@@ -27,6 +27,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 public class LeaderAndIsrResponseTest {
 
@@ -64,4 +65,16 @@ public class LeaderAndIsrResponseTest {
         assertEquals(1, errorCounts.get(Errors.CLUSTER_AUTHORIZATION_FAILED).intValue());
     }
 
+    @Test
+    public void testToString() {
+        Map<TopicPartition, Errors> errors = new HashMap<>();
+        errors.put(new TopicPartition("foo", 0), Errors.NONE);
+        errors.put(new TopicPartition("foo", 1), Errors.CLUSTER_AUTHORIZATION_FAILED);
+        LeaderAndIsrResponse response = new LeaderAndIsrResponse(Errors.NONE, errors);
+        String responseStr = response.toString();
+        assertTrue(responseStr.contains(LeaderAndIsrResponse.class.getSimpleName()));
+        assertTrue(responseStr.contains(errors.toString()));
+        assertTrue(responseStr.contains(Errors.NONE.name()));
+    }
+
 }
diff --git a/clients/src/test/java/org/apache/kafka/common/requests/StopReplicaResponseTest.java
b/clients/src/test/java/org/apache/kafka/common/requests/StopReplicaResponseTest.java
index 95cb3aa..3a87fc6 100644
--- a/clients/src/test/java/org/apache/kafka/common/requests/StopReplicaResponseTest.java
+++ b/clients/src/test/java/org/apache/kafka/common/requests/StopReplicaResponseTest.java
@@ -26,6 +26,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
 public class StopReplicaResponseTest {
 
@@ -58,4 +59,16 @@ public class StopReplicaResponseTest {
         assertEquals(1, errorCounts.get(Errors.CLUSTER_AUTHORIZATION_FAILED).intValue());
     }
 
+    @Test
+    public void testToString() {
+        Map<TopicPartition, Errors> errors = new HashMap<>();
+        errors.put(new TopicPartition("foo", 0), Errors.NONE);
+        errors.put(new TopicPartition("foo", 1), Errors.CLUSTER_AUTHORIZATION_FAILED);
+        StopReplicaResponse response = new StopReplicaResponse(Errors.NONE, errors);
+        String responseStr = response.toString();
+        assertTrue(responseStr.contains(StopReplicaResponse.class.getSimpleName()));
+        assertTrue(responseStr.contains(errors.toString()));
+        assertTrue(responseStr.contains(Errors.NONE.name()));
+    }
+
 }

-- 
To stop receiving notification emails like this one, please contact
ijuma@apache.org.

Mime
View raw message