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

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

                Author: ASF GitHub Bot
            Created on: 24/Sep/20 21:36
            Start Date: 24/Sep/20 21:36
    Worklog Time Spent: 10m 
      Work Description: NickyYe commented on a change in pull request #2332:
URL: https://github.com/apache/hadoop/pull/2332#discussion_r494624826



##########
File path: 
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManagerSafeMode.java
##########
@@ -309,16 +311,21 @@ String getSafeModeTip() {
     }
 
     if (datanodeThreshold > 0) {
-      int numLive = blockManager.getDatanodeManager().getNumLiveDataNodes();
-      if (numLive < datanodeThreshold) {
-        msg += String.format(
-            "The number of live datanodes %d needs an additional %d live "
-                + "datanodes to reach the minimum number %d.%n",
-            numLive, (datanodeThreshold - numLive), datanodeThreshold);
+      if (isBlockThresholdMet) {
+        int numLive = blockManager.getDatanodeManager().getNumLiveDataNodes();
+        if (numLive < datanodeThreshold) {
+          msg += String.format(
+              "The number of live datanodes %d needs an additional %d live "
+                  + "datanodes to reach the minimum number %d.%n",
+              numLive, (datanodeThreshold - numLive), datanodeThreshold);
+        } else {
+          msg += String.format("The number of live datanodes %d has reached "
+                  + "the minimum number %d. ",
+              numLive, datanodeThreshold);
+        }
       } else {
-        msg += String.format("The number of live datanodes %d has reached "
-                + "the minimum number %d. ",
-            numLive, datanodeThreshold);
+        msg += "The number of live datanodes is not calculated " +

Review comment:
       fixed.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

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

> Lazy calculate live datanodes in safe mode tip
> ----------------------------------------------
>
>                 Key: HDFS-15594
>                 URL: https://issues.apache.org/jira/browse/HDFS-15594
>             Project: Hadoop HDFS
>          Issue Type: Improvement
>          Components: namenode
>            Reporter: Ye Ni
>            Assignee: Ye Ni
>            Priority: Minor
>              Labels: pull-request-available
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> Safe mode tip is printed every 20 seconds.
> This change is to calculate live datanodes until reported block threshold is 
> meet.
>  Old 
> {code:java}
> STATE* Safe mode ON. The reported blocks 111054015 needs additional 27902753 
> blocks to reach the threshold 0.9990 of total blocks 139095856. The number of 
> live datanodes 2531 has reached the minimum number 1. Safe mode will be 
> turned off automatically once the thresholds have been reached.{code}
> New 
> {code:java}
> STATE* Safe mode ON. 
> The reported blocks 134851250 needs additional 3218494 blocks to reach the 
> threshold 0.9990 of total blocks 138207947.
> The number of live datanodes is not calculated since reported blocks hasn't 
> reached the threshold. Safe mode will be turned off automatically once the 
> thresholds have been reached.{code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org

Reply via email to