Skip to content

HADOOP-19838. Support parsing environment variables and system properties in the Configuration class.#8346

Open
huangzhaobo99 wants to merge 3 commits intoapache:trunkfrom
huangzhaobo99:HADOOP-19838
Open

HADOOP-19838. Support parsing environment variables and system properties in the Configuration class.#8346
huangzhaobo99 wants to merge 3 commits intoapache:trunkfrom
huangzhaobo99:HADOOP-19838

Conversation

@huangzhaobo99
Copy link
Contributor

@huangzhaobo99 huangzhaobo99 commented Mar 15, 2026

Description of PR

JIRA: https://issues.apache.org/jira/browse/HADOOP-19838

Problem

Currently, Hadoop shell startup scripts only append "HADOOP_CLIENT_OPTS" as JVM arguments before the main class. This prevents users from transparently configuring client-side generic config (such as fs.defaultFS, dfs.client.socket-timeout, dfs.replication) via environment variables.

The examples provided in the doc at this link (https://hadoop.apache.org/docs/stable/hadoop-project-dist/hadoop-common/UnixShellGuide.html#HADOOP_CLIENT_OPTS) fail to take effect in actual practice.

These generic options must be parsed by GenericOptionsParser class, which only processes arguments passed after the main class. As a result, users have to manually add -D/-conf parameters to every single command execution, which is inconvenient and breaks the expected transparent configuration experience, for example:

hadoop fs -Dfs.defaultFS=hdfs://127.0.0.1:8020/ -ls -d /

Solution

Support parsing configuration items from "HADOOP_CLIENT_OPTS" in the Configuration class. The keys used here are exactly the same as those in Hadoop configuration.
This patch also adds support for parsing Java system properties with a specific prefix: "hadoop.property.".
Only system properties prefixed with "hadoop.property." are scanned. The substring after the prefix is used as the actual configuration key.

Benefits

For AI algorithm training scenarios, tuning parameters is required to address training efficiency. With this feature enabled, users no longer need to modify any related code.

How was this patch tested?

Add UT & HDFS Shell

environment variables

export HADOOP_CLIENT_OPTS="-Xmx100m -Dfs.defaultFS=hdfs://127.0.0.1:8020/"

hadoop fs -ls -d /

system properties

This is a Java project that can read and write to the HDFS filesystem

java -Dhadoop.property.dfs.client.socket-timeout=30000 -jar application.jar

@hadoop-yetus
Copy link

💔 -1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 1m 9s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 1s codespell was not available.
+0 🆗 detsecrets 0m 1s detect-secrets was not available.
+0 🆗 xmllint 0m 1s xmllint was not available.
+0 🆗 markdownlint 0m 1s markdownlint was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 1 new or modified test files.
_ trunk Compile Tests _
+0 🆗 mvndep 1m 54s Maven dependency ordering for branch
+1 💚 mvninstall 42m 9s trunk passed
+1 💚 compile 16m 2s trunk passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 compile 16m 32s trunk passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 checkstyle 5m 26s trunk passed
+1 💚 mvnsite 2m 52s trunk passed
+1 💚 javadoc 2m 21s trunk passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javadoc 2m 12s trunk passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+0 🆗 spotbugs 0m 52s branch/hadoop-project no spotbugs output file (spotbugsXml.xml)
+1 💚 shadedclient 30m 53s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+0 🆗 mvndep 0m 29s Maven dependency ordering for patch
+1 💚 mvninstall 1m 33s the patch passed
+1 💚 compile 15m 31s the patch passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javac 15m 31s the patch passed
+1 💚 compile 16m 26s the patch passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 javac 16m 26s the patch passed
-1 ❌ blanks 0m 0s /blanks-eol.txt The patch has 6 line(s) that end in blanks. Use git apply --whitespace=fix <<patch_file>>. Refer https://git-scm.com/docs/git-apply
-0 ⚠️ checkstyle 5m 23s /results-checkstyle-root.txt root: The patch generated 13 new + 215 unchanged - 0 fixed = 228 total (was 215)
+1 💚 mvnsite 2m 47s the patch passed
+1 💚 javadoc 2m 15s the patch passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javadoc 2m 15s the patch passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+0 🆗 spotbugs 0m 46s hadoop-project has no data from spotbugs
+1 💚 shadedclient 30m 14s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 0m 47s hadoop-project in the patch passed.
+1 💚 unit 22m 50s hadoop-common in the patch passed.
+1 💚 asflicense 1m 13s The patch does not generate ASF License warnings.
235m 41s
Subsystem Report/Notes
Docker ClientAPI=1.54 ServerAPI=1.54 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8346/1/artifact/out/Dockerfile
GITHUB PR #8346
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient codespell detsecrets xmllint spotbugs checkstyle markdownlint
uname Linux 50ef235bdee2 5.15.0-173-generic #183-Ubuntu SMP Fri Mar 6 13:29:34 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / 7b57c3e
Default Java Ubuntu-17.0.18+8-Ubuntu-124.04.1
Multi-JDK versions /usr/lib/jvm/java-21-openjdk-amd64:Ubuntu-21.0.10+7-Ubuntu-124.04 /usr/lib/jvm/java-17-openjdk-amd64:Ubuntu-17.0.18+8-Ubuntu-124.04.1
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8346/1/testReport/
Max. process+thread count 1285 (vs. ulimit of 5500)
modules C: hadoop-project hadoop-common-project/hadoop-common U: .
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8346/1/console
versions git=2.43.0 maven=3.9.11 spotbugs=4.9.7
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

@hadoop-yetus
Copy link

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 1m 2s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+0 🆗 detsecrets 0m 0s detect-secrets was not available.
+0 🆗 xmllint 0m 0s xmllint was not available.
+0 🆗 markdownlint 0m 0s markdownlint was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 1 new or modified test files.
_ trunk Compile Tests _
+0 🆗 mvndep 1m 48s Maven dependency ordering for branch
+1 💚 mvninstall 42m 3s trunk passed
+1 💚 compile 15m 59s trunk passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 compile 16m 23s trunk passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 checkstyle 5m 29s trunk passed
+1 💚 mvnsite 2m 45s trunk passed
+1 💚 javadoc 2m 20s trunk passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javadoc 2m 12s trunk passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+0 🆗 spotbugs 0m 51s branch/hadoop-project no spotbugs output file (spotbugsXml.xml)
+1 💚 shadedclient 30m 19s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+0 🆗 mvndep 0m 28s Maven dependency ordering for patch
+1 💚 mvninstall 1m 29s the patch passed
+1 💚 compile 15m 11s the patch passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javac 15m 11s the patch passed
+1 💚 compile 16m 15s the patch passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 javac 16m 15s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
-0 ⚠️ checkstyle 5m 26s /results-checkstyle-root.txt root: The patch generated 1 new + 215 unchanged - 0 fixed = 216 total (was 215)
+1 💚 mvnsite 2m 47s the patch passed
+1 💚 javadoc 2m 17s the patch passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javadoc 2m 14s the patch passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+0 🆗 spotbugs 0m 48s hadoop-project has no data from spotbugs
+1 💚 shadedclient 30m 23s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 0m 48s hadoop-project in the patch passed.
+1 💚 unit 22m 47s hadoop-common in the patch passed.
+1 💚 asflicense 1m 14s The patch does not generate ASF License warnings.
233m 52s
Subsystem Report/Notes
Docker ClientAPI=1.54 ServerAPI=1.54 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8346/2/artifact/out/Dockerfile
GITHUB PR #8346
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient codespell detsecrets xmllint spotbugs checkstyle markdownlint
uname Linux 9b7b6b8c7030 5.15.0-173-generic #183-Ubuntu SMP Fri Mar 6 13:29:34 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / ac77d35
Default Java Ubuntu-17.0.18+8-Ubuntu-124.04.1
Multi-JDK versions /usr/lib/jvm/java-21-openjdk-amd64:Ubuntu-21.0.10+7-Ubuntu-124.04 /usr/lib/jvm/java-17-openjdk-amd64:Ubuntu-17.0.18+8-Ubuntu-124.04.1
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8346/2/testReport/
Max. process+thread count 1369 (vs. ulimit of 5500)
modules C: hadoop-project hadoop-common-project/hadoop-common U: .
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8346/2/console
versions git=2.43.0 maven=3.9.11 spotbugs=4.9.7
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

@hadoop-yetus
Copy link

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 1m 7s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 1s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+0 🆗 detsecrets 0m 0s detect-secrets was not available.
+0 🆗 xmllint 0m 0s xmllint was not available.
+0 🆗 markdownlint 0m 0s markdownlint was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 1 new or modified test files.
_ trunk Compile Tests _
+0 🆗 mvndep 2m 19s Maven dependency ordering for branch
+1 💚 mvninstall 44m 22s trunk passed
+1 💚 compile 16m 11s trunk passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 compile 16m 18s trunk passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 checkstyle 5m 28s trunk passed
+1 💚 mvnsite 2m 50s trunk passed
+1 💚 javadoc 2m 20s trunk passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javadoc 2m 10s trunk passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+0 🆗 spotbugs 0m 52s branch/hadoop-project no spotbugs output file (spotbugsXml.xml)
+1 💚 shadedclient 30m 16s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+0 🆗 mvndep 0m 28s Maven dependency ordering for patch
+1 💚 mvninstall 1m 30s the patch passed
+1 💚 compile 15m 20s the patch passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javac 15m 20s the patch passed
+1 💚 compile 16m 38s the patch passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 javac 16m 38s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 5m 25s the patch passed
+1 💚 mvnsite 2m 47s the patch passed
+1 💚 javadoc 2m 7s the patch passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javadoc 2m 12s the patch passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+0 🆗 spotbugs 0m 49s hadoop-project has no data from spotbugs
+1 💚 shadedclient 30m 44s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 0m 48s hadoop-project in the patch passed.
+1 💚 unit 22m 54s hadoop-common in the patch passed.
+1 💚 asflicense 1m 13s The patch does not generate ASF License warnings.
237m 51s
Subsystem Report/Notes
Docker ClientAPI=1.54 ServerAPI=1.54 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8346/3/artifact/out/Dockerfile
GITHUB PR #8346
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient codespell detsecrets xmllint spotbugs checkstyle markdownlint
uname Linux a86c777bbc9c 5.15.0-173-generic #183-Ubuntu SMP Fri Mar 6 13:29:34 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / 8a477a0
Default Java Ubuntu-17.0.18+8-Ubuntu-124.04.1
Multi-JDK versions /usr/lib/jvm/java-21-openjdk-amd64:Ubuntu-21.0.10+7-Ubuntu-124.04 /usr/lib/jvm/java-17-openjdk-amd64:Ubuntu-17.0.18+8-Ubuntu-124.04.1
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8346/3/testReport/
Max. process+thread count 1287 (vs. ulimit of 5500)
modules C: hadoop-project hadoop-common-project/hadoop-common U: .
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8346/3/console
versions git=2.43.0 maven=3.9.11 spotbugs=4.9.7
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

@hadoop-yetus
Copy link

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 18m 30s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+0 🆗 detsecrets 0m 0s detect-secrets was not available.
+0 🆗 xmllint 0m 0s xmllint was not available.
+0 🆗 markdownlint 0m 0s markdownlint was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 1 new or modified test files.
_ trunk Compile Tests _
+0 🆗 mvndep 2m 12s Maven dependency ordering for branch
+1 💚 mvninstall 42m 32s trunk passed
+1 💚 compile 16m 18s trunk passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 compile 16m 25s trunk passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 checkstyle 5m 31s trunk passed
+1 💚 mvnsite 2m 51s trunk passed
+1 💚 javadoc 2m 19s trunk passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javadoc 2m 14s trunk passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+0 🆗 spotbugs 0m 51s branch/hadoop-project no spotbugs output file (spotbugsXml.xml)
+1 💚 shadedclient 30m 21s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+0 🆗 mvndep 0m 28s Maven dependency ordering for patch
+1 💚 mvninstall 1m 29s the patch passed
+1 💚 compile 15m 27s the patch passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javac 15m 27s the patch passed
+1 💚 compile 16m 23s the patch passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 javac 16m 23s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 5m 27s the patch passed
+1 💚 mvnsite 2m 50s the patch passed
+1 💚 javadoc 2m 11s the patch passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javadoc 2m 15s the patch passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+0 🆗 spotbugs 0m 49s hadoop-project has no data from spotbugs
+1 💚 shadedclient 30m 26s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 0m 46s hadoop-project in the patch passed.
+1 💚 unit 22m 46s hadoop-common in the patch passed.
+1 💚 asflicense 1m 15s The patch does not generate ASF License warnings.
254m 33s
Subsystem Report/Notes
Docker ClientAPI=1.54 ServerAPI=1.54 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8346/4/artifact/out/Dockerfile
GITHUB PR #8346
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient codespell detsecrets xmllint spotbugs checkstyle markdownlint
uname Linux d511ca09dfd9 5.15.0-173-generic #183-Ubuntu SMP Fri Mar 6 13:29:34 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / 54e9dc4
Default Java Ubuntu-17.0.18+8-Ubuntu-124.04.1
Multi-JDK versions /usr/lib/jvm/java-21-openjdk-amd64:Ubuntu-21.0.10+7-Ubuntu-124.04 /usr/lib/jvm/java-17-openjdk-amd64:Ubuntu-17.0.18+8-Ubuntu-124.04.1
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8346/4/testReport/
Max. process+thread count 3160 (vs. ulimit of 5500)
modules C: hadoop-project hadoop-common-project/hadoop-common U: .
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8346/4/console
versions git=2.43.0 maven=3.9.11 spotbugs=4.9.7
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants