hdfs.cmd 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. @echo off
  2. @rem Licensed to the Apache Software Foundation (ASF) under one or more
  3. @rem contributor license agreements. See the NOTICE file distributed with
  4. @rem this work for additional information regarding copyright ownership.
  5. @rem The ASF licenses this file to You under the Apache License, Version 2.0
  6. @rem (the "License"); you may not use this file except in compliance with
  7. @rem the License. You may obtain a copy of the License at
  8. @rem
  9. @rem http://www.apache.org/licenses/LICENSE-2.0
  10. @rem
  11. @rem Unless required by applicable law or agreed to in writing, software
  12. @rem distributed under the License is distributed on an "AS IS" BASIS,
  13. @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. @rem See the License for the specific language governing permissions and
  15. @rem limitations under the License.
  16. @rem
  17. setlocal enabledelayedexpansion
  18. if not defined HADOOP_BIN_PATH (
  19. set HADOOP_BIN_PATH=%~dp0
  20. )
  21. if "%HADOOP_BIN_PATH:~-1%" == "\" (
  22. set HADOOP_BIN_PATH=%HADOOP_BIN_PATH:~0,-1%
  23. )
  24. set DEFAULT_LIBEXEC_DIR=%HADOOP_BIN_PATH%\..\libexec
  25. if not defined HADOOP_LIBEXEC_DIR (
  26. set HADOOP_LIBEXEC_DIR=%DEFAULT_LIBEXEC_DIR%
  27. )
  28. call %HADOOP_LIBEXEC_DIR%\hdfs-config.cmd %*
  29. if "%1" == "--config" (
  30. shift
  31. shift
  32. )
  33. if "%1" == "--loglevel" (
  34. shift
  35. shift
  36. )
  37. :main
  38. if exist %HADOOP_CONF_DIR%\hadoop-env.cmd (
  39. call %HADOOP_CONF_DIR%\hadoop-env.cmd
  40. )
  41. set hdfs-command=%1
  42. call :make_command_arguments %*
  43. if not defined hdfs-command (
  44. goto print_usage
  45. )
  46. if %hdfs-command% == classpath (
  47. if not defined hdfs-command-arguments (
  48. @rem No need to bother starting up a JVM for this simple case.
  49. @echo %CLASSPATH%
  50. exit /b
  51. )
  52. )
  53. set hdfscommands=dfs namenode secondarynamenode journalnode zkfc datanode dfsadmin haadmin fsck balancer jmxget oiv oev fetchdt getconf groups snapshotDiff lsSnapshottableDir cacheadmin mover storagepolicies classpath
  54. for %%i in ( %hdfscommands% ) do (
  55. if %hdfs-command% == %%i set hdfscommand=true
  56. )
  57. if defined hdfscommand (
  58. call :%hdfs-command%
  59. ) else (
  60. set CLASSPATH=%CLASSPATH%;%CD%
  61. set CLASS=%hdfs-command%
  62. )
  63. set java_arguments=%JAVA_HEAP_MAX% %HADOOP_OPTS% -classpath %CLASSPATH% %CLASS% %hdfs-command-arguments%
  64. call %JAVA% %java_arguments%
  65. goto :eof
  66. :namenode
  67. set CLASS=org.apache.hadoop.hdfs.server.namenode.NameNode
  68. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_NAMENODE_OPTS%
  69. goto :eof
  70. :journalnode
  71. set CLASS=org.apache.hadoop.hdfs.qjournal.server.JournalNode
  72. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_JOURNALNODE_OPTS%
  73. goto :eof
  74. :zkfc
  75. set CLASS=org.apache.hadoop.hdfs.tools.DFSZKFailoverController
  76. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_ZKFC_OPTS%
  77. goto :eof
  78. :secondarynamenode
  79. set CLASS=org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode
  80. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_SECONDARYNAMENODE_OPTS%
  81. goto :eof
  82. :datanode
  83. set CLASS=org.apache.hadoop.hdfs.server.datanode.DataNode
  84. set HADOOP_OPTS=%HADOOP_OPTS% -server %HADOOP_DATANODE_OPTS%
  85. goto :eof
  86. :dfs
  87. set CLASS=org.apache.hadoop.fs.FsShell
  88. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_CLIENT_OPTS%
  89. goto :eof
  90. :dfsadmin
  91. set CLASS=org.apache.hadoop.hdfs.tools.DFSAdmin
  92. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_CLIENT_OPTS%
  93. goto :eof
  94. :haadmin
  95. set CLASS=org.apache.hadoop.hdfs.tools.DFSHAAdmin
  96. set CLASSPATH=%CLASSPATH%;%TOOL_PATH%
  97. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_CLIENT_OPTS%
  98. goto :eof
  99. :fsck
  100. set CLASS=org.apache.hadoop.hdfs.tools.DFSck
  101. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_CLIENT_OPTS%
  102. goto :eof
  103. :balancer
  104. set CLASS=org.apache.hadoop.hdfs.server.balancer.Balancer
  105. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_BALANCER_OPTS%
  106. goto :eof
  107. :jmxget
  108. set CLASS=org.apache.hadoop.hdfs.tools.JMXGet
  109. goto :eof
  110. :classpath
  111. set CLASS=org.apache.hadoop.util.Classpath
  112. goto :eof
  113. :oiv
  114. set CLASS=org.apache.hadoop.hdfs.tools.offlineImageViewer.OfflineImageViewerPB
  115. goto :eof
  116. :oev
  117. set CLASS=org.apache.hadoop.hdfs.tools.offlineEditsViewer.OfflineEditsViewer
  118. goto :eof
  119. :fetchdt
  120. set CLASS=org.apache.hadoop.hdfs.tools.DelegationTokenFetcher
  121. goto :eof
  122. :getconf
  123. set CLASS=org.apache.hadoop.hdfs.tools.GetConf
  124. goto :eof
  125. :groups
  126. set CLASS=org.apache.hadoop.hdfs.tools.GetGroups
  127. goto :eof
  128. :snapshotDiff
  129. set CLASS=org.apache.hadoop.hdfs.tools.snapshot.SnapshotDiff
  130. goto :eof
  131. :lsSnapshottableDir
  132. set CLASS=org.apache.hadoop.hdfs.tools.snapshot.LsSnapshottableDir
  133. goto :eof
  134. :cacheadmin
  135. set CLASS=org.apache.hadoop.hdfs.tools.CacheAdmin
  136. goto :eof
  137. :mover
  138. set CLASS=org.apache.hadoop.hdfs.server.mover.Mover
  139. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_MOVER_OPTS%
  140. goto :eof
  141. :storagepolicies
  142. set CLASS=org.apache.hadoop.hdfs.tools.StoragePolicyAdmin
  143. goto :eof
  144. @rem This changes %1, %2 etc. Hence those cannot be used after calling this.
  145. :make_command_arguments
  146. if "%1" == "--config" (
  147. shift
  148. shift
  149. )
  150. if "%1" == "--loglevel" (
  151. shift
  152. shift
  153. )
  154. if [%2] == [] goto :eof
  155. shift
  156. set _hdfsarguments=
  157. :MakeCmdArgsLoop
  158. if [%1]==[] goto :EndLoop
  159. if not defined _hdfsarguments (
  160. set _hdfsarguments=%1
  161. ) else (
  162. set _hdfsarguments=!_hdfsarguments! %1
  163. )
  164. shift
  165. goto :MakeCmdArgsLoop
  166. :EndLoop
  167. set hdfs-command-arguments=%_hdfsarguments%
  168. goto :eof
  169. :print_usage
  170. @echo Usage: hdfs [--config confdir] [--loglevel loglevel] COMMAND
  171. @echo where COMMAND is one of:
  172. @echo dfs run a filesystem command on the file systems supported in Hadoop.
  173. @echo namenode -format format the DFS filesystem
  174. @echo secondarynamenode run the DFS secondary namenode
  175. @echo namenode run the DFS namenode
  176. @echo journalnode run the DFS journalnode
  177. @echo zkfc run the ZK Failover Controller daemon
  178. @echo datanode run a DFS datanode
  179. @echo dfsadmin run a DFS admin client
  180. @echo haadmin run a DFS HA admin client
  181. @echo fsck run a DFS filesystem checking utility
  182. @echo balancer run a cluster balancing utility
  183. @echo jmxget get JMX exported values from NameNode or DataNode.
  184. @echo oiv apply the offline fsimage viewer to an fsimage
  185. @echo oev apply the offline edits viewer to an edits file
  186. @echo fetchdt fetch a delegation token from the NameNode
  187. @echo getconf get config values from configuration
  188. @echo groups get the groups which users belong to
  189. @echo snapshotDiff diff two snapshots of a directory or diff the
  190. @echo current directory contents with a snapshot
  191. @echo lsSnapshottableDir list all snapshottable dirs owned by the current user
  192. @echo Use -help to see options
  193. @echo cacheadmin configure the HDFS cache
  194. @echo mover run a utility to move block replicas across storage types
  195. @echo storagepolicies list/get/set block storage policies
  196. @echo.
  197. @echo Most commands print help when invoked w/o parameters.
  198. endlocal