From a6efbb21c2561f718f02a788d5fd25c02eff09a0 Mon Sep 17 00:00:00 2001 From: Arpit Agarwal Date: Thu, 15 Jan 2015 11:02:17 -0800 Subject: [PATCH] HDFS-7591. hdfs classpath command should support same options as hadoop classpath. (Contributed by Varun Saxena) --- .../hadoop-common/src/main/bin/hadoop | 8 +------- .../hadoop-common/src/main/bin/hadoop-functions.sh | 11 +++++++++++ hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ hadoop-hdfs-project/hadoop-hdfs/src/main/bin/hdfs | 4 +--- .../hadoop-hdfs/src/main/bin/hdfs.cmd | 14 +++++++++++++- 5 files changed, 29 insertions(+), 11 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/bin/hadoop b/hadoop-common-project/hadoop-common/src/main/bin/hadoop index b216b8f278a..6ba327afff8 100755 --- a/hadoop-common-project/hadoop-common/src/main/bin/hadoop +++ b/hadoop-common-project/hadoop-common/src/main/bin/hadoop @@ -124,13 +124,7 @@ case ${COMMAND} in CLASS=org.apache.hadoop.util.NativeLibraryChecker ;; classpath) - if [[ "$#" -eq 1 ]]; then - CLASS=org.apache.hadoop.util.Classpath - else - hadoop_finalize - echo "${CLASSPATH}" - exit 0 - fi + hadoop_do_classpath_subcommand "$@" ;; credential) CLASS=org.apache.hadoop.security.alias.CredentialShell diff --git a/hadoop-common-project/hadoop-common/src/main/bin/hadoop-functions.sh b/hadoop-common-project/hadoop-common/src/main/bin/hadoop-functions.sh index 75d24998a63..f70be5a5c9f 100644 --- a/hadoop-common-project/hadoop-common/src/main/bin/hadoop-functions.sh +++ b/hadoop-common-project/hadoop-common/src/main/bin/hadoop-functions.sh @@ -1240,3 +1240,14 @@ function hadoop_verify_user fi fi } + +function hadoop_do_classpath_subcommand +{ + if [[ "$#" -gt 0 ]]; then + CLASS=org.apache.hadoop.util.Classpath + else + hadoop_finalize + echo "${CLASSPATH}" + exit 0 + fi +} diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 63797eb4371..c3d32b88ec4 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -133,6 +133,9 @@ Trunk (Unreleased) type instead of concrete classes Block and ReplicaInfo. (David Powell and Joe Pallas via szetszwo) + HDFS-7591. hdfs classpath command should support same options as hadoop + classpath (Varun Saxena via Arpit Agarwal) + OPTIMIZATIONS BUG FIXES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/bin/hdfs b/hadoop-hdfs-project/hadoop-hdfs/src/main/bin/hdfs index 650a0f5a3e5..5f8ff1843b6 100755 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/bin/hdfs +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/bin/hdfs @@ -94,9 +94,7 @@ case ${COMMAND} in CLASS=org.apache.hadoop.hdfs.tools.CacheAdmin ;; classpath) - hadoop_finalize - echo "${CLASSPATH}" - exit + hadoop_do_classpath_subcommand "$@" ;; crypto) CLASS=org.apache.hadoop.hdfs.tools.CryptoAdmin diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/bin/hdfs.cmd b/hadoop-hdfs-project/hadoop-hdfs/src/main/bin/hdfs.cmd index 851637d47b4..78832524c9e 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/bin/hdfs.cmd +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/bin/hdfs.cmd @@ -51,7 +51,15 @@ if "%1" == "--loglevel" ( goto print_usage ) - set hdfscommands=dfs namenode secondarynamenode journalnode zkfc datanode dfsadmin haadmin fsck balancer jmxget oiv oev fetchdt getconf groups snapshotDiff lsSnapshottableDir cacheadmin mover storagepolicies + if %hdfs-command% == classpath ( + if not defined hdfs-command-arguments ( + @rem No need to bother starting up a JVM for this simple case. + @echo %CLASSPATH% + exit /b + ) + ) + + set hdfscommands=dfs namenode secondarynamenode journalnode zkfc datanode dfsadmin haadmin fsck balancer jmxget oiv oev fetchdt getconf groups snapshotDiff lsSnapshottableDir cacheadmin mover storagepolicies classpath for %%i in ( %hdfscommands% ) do ( if %hdfs-command% == %%i set hdfscommand=true ) @@ -122,6 +130,10 @@ goto :eof set CLASS=org.apache.hadoop.hdfs.tools.JMXGet goto :eof +:classpath + set CLASS=org.apache.hadoop.util.Classpath + goto :eof + :oiv set CLASS=org.apache.hadoop.hdfs.tools.offlineImageViewer.OfflineImageViewerPB goto :eof