You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by jd...@apache.org on 2016/04/28 04:32:40 UTC

[4/5] incubator-kudu git commit: [java client] Only add the Deferred to KuduRPC.toString if DEBUG is enabled

[java client] Only add the Deferred to KuduRPC.toString if DEBUG is enabled

All the KuduRPC daughter classes append their Deferred object when
toString() is called, which gives things like:

KuduRpc(method=Write, tablet=9d66b0bb6019492daca0a607fb0bd64b, attempt=8, DeadlineTracker(timeout=10000, elapsed=6289), Deferred@608776154(state=PENDING, result=null, callback=apply batch response -> callback: mark tablet 9d66b0bb6019492daca0a607fb0bd64b inflight done -> (continuation of Deferred@544649099 after retry RPC@1702110689) -> (continuation of Deferred@956406952 after retry RPC@1415267245) -> (continuation of Deferred@690509936 after retry RPC@756533645) -> (continuation of Deferred@1348564629 after retry RPC@1415510081), errback=apply batch error response -> errback: mark tablet 9d66b0bb6019492daca0a607fb0bd64b inflight done -> (continuation of Deferred@544649099 after retry RPC@1702110689) -> (continuation of Deferred@956406952 after retry RPC@1415267245) -> (continuation of Deferred@690509936 after retry RPC@756533645) -> (continuation of Deferred@1348564629 after retry RPC@1415510081)))

It can be useful to debug what happened to the chaining of deferreds
and callbacks, but usually it's not needed and it looks scary.

This patch makes it so that we only add the Deferred part if DEBUG
is enabled, so by default we'd instead output a more reasonable:

KuduRpc(method=Write, tablet=9d66b0bb6019492daca0a607fb0bd64b, attempt=8, DeadlineTracker(timeout=10000, elapsed=6289))

Change-Id: Iff08c234fef3ac0f0c6c8ec7c63078233c702f18
Reviewed-on: http://gerrit.cloudera.org:8080/2873
Tested-by: Kudu Jenkins
Reviewed-by: Adar Dembo <ad...@cloudera.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-kudu/commit/0eefc493
Tree: http://git-wip-us.apache.org/repos/asf/incubator-kudu/tree/0eefc493
Diff: http://git-wip-us.apache.org/repos/asf/incubator-kudu/diff/0eefc493

Branch: refs/heads/master
Commit: 0eefc4937583ee4d9a234cf0024d4c358e35689a
Parents: 01e8329
Author: Jean-Daniel Cryans <jd...@apache.org>
Authored: Tue Apr 26 11:39:16 2016 -0700
Committer: Jean-Daniel Cryans <jd...@gerrit.cloudera.org>
Committed: Thu Apr 28 02:31:38 2016 +0000

----------------------------------------------------------------------
 .../src/main/java/org/kududb/client/KuduRpc.java          | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-kudu/blob/0eefc493/java/kudu-client/src/main/java/org/kududb/client/KuduRpc.java
----------------------------------------------------------------------
diff --git a/java/kudu-client/src/main/java/org/kududb/client/KuduRpc.java b/java/kudu-client/src/main/java/org/kududb/client/KuduRpc.java
index 4219427..a3639e0 100644
--- a/java/kudu-client/src/main/java/org/kududb/client/KuduRpc.java
+++ b/java/kudu-client/src/main/java/org/kududb/client/KuduRpc.java
@@ -35,6 +35,8 @@ import org.jboss.netty.buffer.ChannelBuffers;
 import org.kududb.annotations.InterfaceAudience;
 import org.kududb.util.Pair;
 import org.kududb.util.Slice;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.util.Collection;
@@ -63,6 +65,8 @@ public abstract class KuduRpc<R> {
   protected static final String MASTER_SERVICE_NAME = "kudu.master.MasterService";
   protected static final String TABLET_SERVER_SERVICE_NAME = "kudu.tserver.TabletServerService";
 
+  private static final Logger LOG = LoggerFactory.getLogger(KuduRpc.class);
+
   public interface HasKey {
     /**
      * Returns the partition key this RPC is for.
@@ -236,7 +240,11 @@ public abstract class KuduRpc<R> {
     }
     buf.append(", attempt=").append(attempt);
     buf.append(", ").append(deadlineTracker);
-    buf.append(", ").append(deferred);
+    // 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(')');
     return buf.toString();
   }