Browse Source

HDFS-7591. hdfs classpath command should support same options as hadoop classpath. (Contributed by Varun Saxena)

Arpit Agarwal 10 years ago
parent
commit
a6efbb21c2

+ 1 - 7
hadoop-common-project/hadoop-common/src/main/bin/hadoop

@@ -124,13 +124,7 @@ case ${COMMAND} in
     CLASS=org.apache.hadoop.util.NativeLibraryChecker
     CLASS=org.apache.hadoop.util.NativeLibraryChecker
   ;;
   ;;
   classpath)
   classpath)
-    if [[ "$#" -eq 1 ]]; then
-      CLASS=org.apache.hadoop.util.Classpath
-    else   
-      hadoop_finalize
-      echo "${CLASSPATH}"
-      exit 0
-    fi
+    hadoop_do_classpath_subcommand "$@"
   ;;
   ;;
   credential)
   credential)
     CLASS=org.apache.hadoop.security.alias.CredentialShell
     CLASS=org.apache.hadoop.security.alias.CredentialShell

+ 11 - 0
hadoop-common-project/hadoop-common/src/main/bin/hadoop-functions.sh

@@ -1240,3 +1240,14 @@ function hadoop_verify_user
     fi
     fi
   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
+}

+ 3 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

@@ -133,6 +133,9 @@ Trunk (Unreleased)
     type instead of concrete classes Block and ReplicaInfo.  (David Powell
     type instead of concrete classes Block and ReplicaInfo.  (David Powell
     and Joe Pallas via szetszwo)
     and Joe Pallas via szetszwo)
 
 
+    HDFS-7591. hdfs classpath command should support same options as hadoop
+    classpath (Varun Saxena via Arpit Agarwal)
+
   OPTIMIZATIONS
   OPTIMIZATIONS
 
 
   BUG FIXES
   BUG FIXES

+ 1 - 3
hadoop-hdfs-project/hadoop-hdfs/src/main/bin/hdfs

@@ -94,9 +94,7 @@ case ${COMMAND} in
     CLASS=org.apache.hadoop.hdfs.tools.CacheAdmin
     CLASS=org.apache.hadoop.hdfs.tools.CacheAdmin
   ;;
   ;;
   classpath)
   classpath)
-    hadoop_finalize
-    echo "${CLASSPATH}"
-    exit
+    hadoop_do_classpath_subcommand "$@"
   ;;
   ;;
   crypto)
   crypto)
     CLASS=org.apache.hadoop.hdfs.tools.CryptoAdmin
     CLASS=org.apache.hadoop.hdfs.tools.CryptoAdmin

+ 13 - 1
hadoop-hdfs-project/hadoop-hdfs/src/main/bin/hdfs.cmd

@@ -51,7 +51,15 @@ if "%1" == "--loglevel" (
       goto print_usage
       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 (
   for %%i in ( %hdfscommands% ) do (
     if %hdfs-command% == %%i set hdfscommand=true
     if %hdfs-command% == %%i set hdfscommand=true
   )
   )
@@ -122,6 +130,10 @@ goto :eof
   set CLASS=org.apache.hadoop.hdfs.tools.JMXGet
   set CLASS=org.apache.hadoop.hdfs.tools.JMXGet
   goto :eof
   goto :eof
 
 
+:classpath
+  set CLASS=org.apache.hadoop.util.Classpath
+  goto :eof
+
 :oiv
 :oiv
   set CLASS=org.apache.hadoop.hdfs.tools.offlineImageViewer.OfflineImageViewerPB
   set CLASS=org.apache.hadoop.hdfs.tools.offlineImageViewer.OfflineImageViewerPB
   goto :eof
   goto :eof