You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2021/04/13 15:04:20 UTC

[hbase] branch master updated: HBASE-25762 Improvement for some debug-logging guards (#3145)

This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new c5b0989  HBASE-25762 Improvement for some debug-logging guards (#3145)
c5b0989 is described below

commit c5b0989d229203d1e7525dc8890938d128516bc6
Author: ZhiChen <zi...@gmail.com>
AuthorDate: Tue Apr 13 23:03:55 2021 +0800

    HBASE-25762 Improvement for some debug-logging guards (#3145)
    
    Signed-off-by: Duo Zhang <zh...@apache.org>
---
 .../org/apache/hadoop/hbase/ipc/NettyRpcDuplexHandler.java     |  4 ++--
 .../src/main/java/org/apache/hadoop/hbase/ChoreService.java    | 10 ++++++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcDuplexHandler.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcDuplexHandler.java
index 2a2df8a..f31e3d2 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcDuplexHandler.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcDuplexHandler.java
@@ -150,9 +150,9 @@ class NettyRpcDuplexHandler extends ChannelDuplexHandler {
       // to return a response. There is nothing we can do w/ the response at this stage. Clean
       // out the wire of the response so its out of the way and we can get other responses on
       // this connection.
-      int readSoFar = IPCUtil.getTotalSizeWhenWrittenDelimited(responseHeader);
-      int whatIsLeftToRead = totalSize - readSoFar;
       if (LOG.isDebugEnabled()) {
+        int readSoFar = IPCUtil.getTotalSizeWhenWrittenDelimited(responseHeader);
+        int whatIsLeftToRead = totalSize - readSoFar;
         LOG.debug("Unknown callId: " + id + ", skipping over this response of " + whatIsLeftToRead
             + " bytes");
       }
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/ChoreService.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/ChoreService.java
index 5bd67ad..9540d84 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/ChoreService.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/ChoreService.java
@@ -403,6 +403,9 @@ public class ChoreService {
    * Prints a summary of important details about the chore. Used for debugging purposes
    */
   private void printChoreDetails(final String header, ScheduledChore chore) {
+    if (!LOG.isTraceEnabled()) {
+      return;
+    }
     LinkedHashMap<String, String> output = new LinkedHashMap<>();
     output.put(header, "");
     output.put("Chore name: ", chore.getName());
@@ -410,7 +413,7 @@ public class ChoreService {
     output.put("Chore timeBetweenRuns: ", Long.toString(chore.getTimeBetweenRuns()));
 
     for (Entry<String, String> entry : output.entrySet()) {
-      if (LOG.isTraceEnabled()) LOG.trace(entry.getKey() + entry.getValue());
+      LOG.trace(entry.getKey() + entry.getValue());
     }
   }
 
@@ -418,6 +421,9 @@ public class ChoreService {
    * Prints a summary of important details about the service. Used for debugging purposes
    */
   private void printChoreServiceDetails(final String header) {
+    if (!LOG.isTraceEnabled()) {
+      return;
+    }
     LinkedHashMap<String, String> output = new LinkedHashMap<>();
     output.put(header, "");
     output.put("ChoreService corePoolSize: ", Integer.toString(getCorePoolSize()));
@@ -426,7 +432,7 @@ public class ChoreService {
       Integer.toString(getNumberOfChoresMissingStartTime()));
 
     for (Entry<String, String> entry : output.entrySet()) {
-      if (LOG.isTraceEnabled()) LOG.trace(entry.getKey() + entry.getValue());
+      LOG.trace(entry.getKey() + entry.getValue());
     }
   }
 }