[ 
https://issues.apache.org/jira/browse/HDFS-16648?focusedWorklogId=787996&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-787996
 ]

ASF GitHub Bot logged work on HDFS-16648:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 05/Jul/22 18:28
            Start Date: 05/Jul/22 18:28
    Worklog Time Spent: 10m 
      Work Description: goiri commented on code in PR #4529:
URL: https://github.com/apache/hadoop/pull/4529#discussion_r914083773


##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopology.java:
##########
@@ -522,9 +522,11 @@ protected Node chooseRandom(final String scope, String 
excludedScope,
       }
     }
     if (numOfDatanodes <= 0) {
-      LOG.debug("Failed to find datanode (scope=\"{}\" excludedScope=\"{}\")."
-              + " numOfDatanodes={}",
-          scope, excludedScope, numOfDatanodes);
+      if (LOG.isDebugEnabled()) {

Review Comment:
   Are we saving anything by checking LOG.isDebugEnabled()? Using {} should 
avoid toString() and all.



##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NetworkTopology.java:
##########
@@ -539,10 +541,12 @@ protected Node chooseRandom(final String scope, String 
excludedScope,
         netlock.readLock().unlock();
       }
     }
-    LOG.debug("Choosing random from {} available nodes on node {},"
-        + " scope={}, excludedScope={}, excludeNodes={}. numOfDatanodes={}.",
-        availableNodes, innerNode, scope, excludedScope, excludedNodes,
-        numOfDatanodes);
+    if (LOG.isDebugEnabled()) {

Review Comment:
   What are we saving by doing this?
   The + should be statically handled by the compiler.



##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeRpcServer.java:
##########
@@ -2319,8 +2322,10 @@ public void setErasureCodingPolicy(String src, String 
ecPolicyName)
     try {
       if (ecPolicyName == null) {
         ecPolicyName = defaultECPolicyName;
-        LOG.debug("No policy name is specified, " +
-            "set the default policy name instead");
+        if (LOG.isDebugEnabled()) {

Review Comment:
   I don't think we need this check.
   With the new style line limit this could fit in one line too.





Issue Time Tracking
-------------------

    Worklog Id:     (was: 787996)
    Time Spent: 0.5h  (was: 20m)

> Normalize the usage of debug logs in NameNode
> ---------------------------------------------
>
>                 Key: HDFS-16648
>                 URL: https://issues.apache.org/jira/browse/HDFS-16648
>             Project: Hadoop HDFS
>          Issue Type: Improvement
>            Reporter: ZanderXu
>            Assignee: ZanderXu
>            Priority: Minor
>              Labels: pull-request-available
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> There are many irregular debug logs in NameNode.  such as:
> Error type1: 
> {code:java}
> if (LOG.isDebugEnabled()) {
>       LOG.debug("Getting groups for user " + user);
> }
> {code}
> we can format it to:
> {code:java}
> LOG.debug("Getting groups for user {}. ", user);
> {code}
> Error type2:
> {code:java}
> LOG.debug("*DIR* NameNode.renameSnapshot: Snapshot Path {}, " +
>         "snapshotOldName {}, snapshotNewName {}", snapshotRoot,
>         snapshotOldName, snapshotNewName);
> {code}
> we can format it to:
> {code:java}
> if (LOG.isDebugEnabled()) {
>   LOG.debug("*DIR* NameNode.renameSnapshot: Snapshot Path {}, " +
>         "snapshotOldName {}, snapshotNewName {}", snapshotRoot,
>         snapshotOldName, snapshotNewName); 
> }
> {code}
> Error type3:
> {code:java}
> if (LOG.isDebugEnabled()) {
>       LOG.debug("getAdditionalDatanode: src=" + src
>           + ", fileId=" + fileId
>           + ", blk=" + blk
>           + ", existings=" + Arrays.asList(existings)
>           + ", excludes=" + Arrays.asList(excludes)
>           + ", numAdditionalNodes=" + numAdditionalNodes
>           + ", clientName=" + clientName);
>     }
> {code}
> We can format it to:
> {code:java}
>  if (LOG.isDebugEnabled()) {
>    LOG.debug("getAdditionalDatanode: src={}, fileId={}, "
>            + "blk={}, existings={}, excludes={}, numAdditionalNodes={}, "
>           + "clientName={}.", src, fileId, blk, Arrays.asList(existings),
>           Arrays.asList(excludes), numAdditionalNodes, clientName);
>  }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to