kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aw...@apache.org
Subject [kudu] 01/06: [java] Improve Java RPC traces [1/n]: Improve trace messages
Date Wed, 06 Feb 2019 05:26:08 GMT
This is an automated email from the ASF dual-hosted git repository.

awong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit 8772540d9d7ac95785e370714e58e2f8ddd81804
Author: Will Berkeley <wdberkeley@gmail.org>
AuthorDate: Tue Feb 5 14:23:00 2019 -0800

    [java] Improve Java RPC traces [1/n]: Improve trace messages
    
    Change-Id: I87e564668cffa6b60af6f703c5e9a17ab5b7616b
    Reviewed-on: http://gerrit.cloudera.org:8080/12376
    Reviewed-by: Alexey Serbin <aserbin@cloudera.com>
    Tested-by: Kudu Jenkins
---
 .../org/apache/kudu/client/AsyncKuduClient.java    |  2 +-
 .../main/java/org/apache/kudu/client/KuduRpc.java  |  2 +-
 .../java/org/apache/kudu/client/RpcTraceFrame.java | 23 ++++++++++------------
 .../java/org/apache/kudu/client/TestRpcTraces.java | 13 ++++++------
 4 files changed, 19 insertions(+), 21 deletions(-)

diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduClient.java b/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduClient.java
index 72b96a9..2ec8719 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduClient.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduClient.java
@@ -1647,7 +1647,7 @@ public class AsyncKuduClient implements AutoCloseable {
     if (request.attempt > MAX_RPC_ATTEMPTS) {
       message = "too many attempts: ";
     } else {
-      message = "can not complete before timeout: ";
+      message = "cannot complete before timeout: ";
     }
     Status statusTimedOut = Status.TimedOut(message + request);
     LOG.debug("Cannot continue with RPC because of: {}", statusTimedOut);
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/KuduRpc.java b/java/kudu-client/src/main/java/org/apache/kudu/client/KuduRpc.java
index 0083140..8fc011a 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/KuduRpc.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/KuduRpc.java
@@ -376,7 +376,7 @@ public abstract class KuduRpc<R> {
     // Cheating a bit, we're not actually logging but we'll augment the information provided
by
     // this method if DEBUG is enabled.
     if (LOG.isDebugEnabled()) {
-      buf.append(", ").append(deferred);
+      buf.append(", deferred=").append(deferred);
     }
     buf.append(')');
     return buf.toString();
diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/RpcTraceFrame.java b/java/kudu-client/src/main/java/org/apache/kudu/client/RpcTraceFrame.java
index 7d3df87..8c362d0 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/RpcTraceFrame.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/RpcTraceFrame.java
@@ -33,26 +33,24 @@ class RpcTraceFrame {
     SEND_TO_SERVER {
       @Override
       void appendToStringBuilder(RpcTraceFrame trace, StringBuilder sb) {
-        sb.append("sending RPC to server ");
-        sb.append(trace.getServer().getUuid());
+        sb.append(String.format("sending RPC to server %s",
+                                trace.getServer().getUuid()));
       }
     },
     // Just after parsing the response from the server.
     RECEIVE_FROM_SERVER {
       @Override
       void appendToStringBuilder(RpcTraceFrame trace, StringBuilder sb) {
-        sb.append("received from server ");
-        sb.append(trace.getServer().getUuid());
-        sb.append(" response ");
-        sb.append(trace.getStatus());
+        sb.append(String.format("received response from server %s: %s",
+                                trace.getServer().getUuid(),
+                                trace.getStatus()));
       }
     },
     // Just before sleeping and then retrying.
     SLEEP_THEN_RETRY {
       @Override
       void appendToStringBuilder(RpcTraceFrame trace, StringBuilder sb) {
-        sb.append("delaying RPC due to ");
-        sb.append(trace.getStatus());
+        sb.append(String.format("delaying RPC due to: %s", trace.getStatus()));
       }
     },
     // Waiting for a new authn token to re-send the request.
@@ -67,14 +65,15 @@ class RpcTraceFrame {
     QUERY_MASTER {
       @Override
       void appendToStringBuilder(RpcTraceFrame trace, StringBuilder sb) {
-        sb.append("querying master");
+        sb.append("refreshing cache from master");
       }
     },
     // Once the trace becomes too large, will be the last trace object in the list.
     TRACE_TRUNCATED {
       @Override
       void appendToStringBuilder(RpcTraceFrame trace, StringBuilder sb) {
-        sb.append("trace too long, truncated");
+        sb.append(String.format("too many traces: truncated at %d traces",
+                                KuduRpc.MAX_TRACES_SIZE));
       }
     };
 
@@ -135,9 +134,7 @@ class RpcTraceFrame {
       sb.append("ms] ");
 
       if (!rootMethod.equals(trace.getRpcMethod())) {
-        sb.append("Sub rpc: ");
-        sb.append(trace.getRpcMethod());
-        sb.append(" ");
+        sb.append(String.format("Sub RPC %s: ", trace.getRpcMethod()));
       }
 
       trace.getAction().appendToStringBuilder(trace, sb);
diff --git a/java/kudu-client/src/test/java/org/apache/kudu/client/TestRpcTraces.java b/java/kudu-client/src/test/java/org/apache/kudu/client/TestRpcTraces.java
index fb0887f..faba44d 100644
--- a/java/kudu-client/src/test/java/org/apache/kudu/client/TestRpcTraces.java
+++ b/java/kudu-client/src/test/java/org/apache/kudu/client/TestRpcTraces.java
@@ -18,6 +18,7 @@ package org.apache.kudu.client;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
 
 import java.util.List;
@@ -64,30 +65,30 @@ public class TestRpcTraces {
     // Son's daughter => son => parent.
     RpcTraceFrame trace = getTrace();
     sonsDaughter.addTrace(trace);
-    assertTrue(son.getImmutableTraces().get(0) == trace);
+    assertSame(trace, son.getImmutableTraces().get(0));
     assertTrue(parent.getImmutableTraces().get(0) == trace);
     assertTrue(daughter.getImmutableTraces().isEmpty());
 
     // Son => parent.
     trace = getTrace();
     son.addTrace(trace);
-    assertTrue(son.getImmutableTraces().get(1) == trace);
-    assertTrue(parent.getImmutableTraces().get(1) == trace);
+    assertSame(trace, son.getImmutableTraces().get(1));
+    assertSame(trace, parent.getImmutableTraces().get(1));
     assertTrue(daughter.getImmutableTraces().isEmpty());
     assertEquals(1, sonsDaughter.getImmutableTraces().size());
 
     // Daughter => parent.
     trace = getTrace();
     daughter.addTrace(trace);
-    assertTrue(daughter.getImmutableTraces().get(0) == trace);
-    assertTrue(parent.getImmutableTraces().get(2) == trace);
+    assertSame(trace, daughter.getImmutableTraces().get(0));
+    assertSame(trace, parent.getImmutableTraces().get(2));
     assertEquals(2, son.getImmutableTraces().size());
     assertEquals(1, sonsDaughter.getImmutableTraces().size());
 
     // Parent alone.
     trace = getTrace();
     parent.addTrace(trace);
-    assertTrue(parent.getImmutableTraces().get(3) == trace);
+    assertSame(trace, parent.getImmutableTraces().get(3));
     assertEquals(1, daughter.getImmutableTraces().size());
     assertEquals(2, son.getImmutableTraces().size());
     assertEquals(1, sonsDaughter.getImmutableTraces().size());


Mime
View raw message