[ 
https://issues.apache.org/jira/browse/HDFS-17380?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17826804#comment-17826804
 ] 

ASF GitHub Bot commented on HDFS-17380:
---------------------------------------

szetszwo commented on code in PR #6549:
URL: https://github.com/apache/hadoop/pull/6549#discussion_r1523650714


##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FsImageValidation.java:
##########
@@ -77,6 +79,35 @@ public class FsImageValidation {
 
   static final String FS_IMAGE = "FS_IMAGE";
 
+  /**
+   * Use an environment variable "PRINT_ERROR" to enable/disable printing 
error messages.
+   * The default is true
+   */
+  static final boolean PRINT_ERROR;
+
+  static {
+    PRINT_ERROR = getEnvBoolean("PRINT_ERROR", true);
+  }
+
+  /**
+   * @return the boolean value of an environment property.
+   *         If the environment property is not set or cannot be parsed as a 
boolean,
+   *         return the default value.
+   */
+  static boolean getEnvBoolean(String property, boolean defaultValue) {
+    final String env = System.getenv().get(property);
+    final boolean setToNonDefault = ("" + !defaultValue).equalsIgnoreCase(env);
+    // default | setToNonDefault | value
+    // ---------------------------------
+    // true    |    true         | false
+    // true    |    false        | true
+    // false   |    true         | true
+    // false   |    false        | false
+    final boolean value = defaultValue != setToNonDefault;

Review Comment:
   `getEnv` does not care about the default value.  This method `getEnvBoolean` 
will handle default as specified in the javadoc
   ```java
      *         If the environment property is not set or cannot be parsed as a 
boolean,
      *         return the default value.
   ```





> FsImageValidation: remove inaccessible nodes
> --------------------------------------------
>
>                 Key: HDFS-17380
>                 URL: https://issues.apache.org/jira/browse/HDFS-17380
>             Project: Hadoop HDFS
>          Issue Type: Improvement
>          Components: tools
>            Reporter: Tsz-wo Sze
>            Assignee: Tsz-wo Sze
>            Priority: Major
>              Labels: pull-request-available
>
> If a fsimage is corrupted,  it may have inaccessible nodes.  The 
> FsImageValidation tool currently is able to identify the inaccessible nodes 
> when validating the INodeMap.  This JIRA is to update the tool to remove the 
> inaccessible nodes and then save a new fsimage.



--
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