hdfs.cmd 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. :main
  34. if exist %HADOOP_CONF_DIR%\hadoop-env.cmd (
  35. call %HADOOP_CONF_DIR%\hadoop-env.cmd
  36. )
  37. set hdfs-command=%1
  38. call :make_command_arguments %*
  39. if not defined hdfs-command (
  40. goto print_usage
  41. )
  42. call :%hdfs-command% %hdfs-command-arguments%
  43. set java_arguments=%JAVA_HEAP_MAX% %HADOOP_OPTS% -classpath %CLASSPATH% %CLASS% %hdfs-command-arguments%
  44. call %JAVA% %java_arguments%
  45. goto :eof
  46. :namenode
  47. set CLASS=org.apache.hadoop.hdfs.server.namenode.NameNode
  48. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_NAMENODE_OPTS%
  49. goto :eof
  50. :zkfc
  51. set CLASS=org.apache.hadoop.hdfs.tools.DFSZKFailoverController
  52. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_ZKFC_OPTS%
  53. goto :eof
  54. :secondarynamenode
  55. set CLASS=org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode
  56. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_SECONDARYNAMENODE_OPTS%
  57. goto :eof
  58. :datanode
  59. set CLASS=org.apache.hadoop.hdfs.server.datanode.DataNode
  60. set HADOOP_OPTS=%HADOOP_OPTS% -server %HADOOP_DATANODE_OPTS%
  61. goto :eof
  62. :dfs
  63. set CLASS=org.apache.hadoop.fs.FsShell
  64. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_CLIENT_OPTS%
  65. goto :eof
  66. :dfsadmin
  67. set CLASS=org.apache.hadoop.hdfs.tools.DFSAdmin
  68. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_CLIENT_OPTS%
  69. goto :eof
  70. :haadmin
  71. set CLASS=org.apache.hadoop.hdfs.tools.DFSHAAdmin
  72. set CLASSPATH=%CLASSPATH%;%TOOL_PATH%
  73. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_CLIENT_OPTS%
  74. goto :eof
  75. :fsck
  76. set CLASS=org.apache.hadoop.hdfs.tools.DFSck
  77. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_CLIENT_OPTS%
  78. goto :eof
  79. :balancer
  80. set CLASS=org.apache.hadoop.hdfs.server.balancer.Balancer
  81. set HADOOP_OPTS=%HADOOP_OPTS% %HADOOP_BALANCER_OPTS%
  82. goto :eof
  83. :jmxget
  84. set CLASS=org.apache.hadoop.hdfs.tools.JMXGet
  85. goto :eof
  86. :oiv
  87. set CLASS=org.apache.hadoop.hdfs.tools.offlineImageViewer.OfflineImageViewer
  88. goto :eof
  89. :oev
  90. set CLASS=org.apache.hadoop.hdfs.tools.offlineEditsViewer.OfflineEditsViewer
  91. goto :eof
  92. :fetchdt
  93. set CLASS=org.apache.hadoop.hdfs.tools.DelegationTokenFetcher
  94. goto :eof
  95. :getconf
  96. set CLASS=org.apache.hadoop.hdfs.tools.GetConf
  97. goto :eof
  98. :groups
  99. set CLASS=org.apache.hadoop.hdfs.tools.GetGroups
  100. goto :eof
  101. :snapshotDiff
  102. set CLASS=org.apache.hadoop.hdfs.tools.snapshot.SnapshotDiff
  103. goto :eof
  104. :lsSnapshottableDir
  105. set CLASS=org.apache.hadoop.hdfs.tools.snapshot.LsSnapshottableDir
  106. goto :eof
  107. @rem This changes %1, %2 etc. Hence those cannot be used after calling this.
  108. :make_command_arguments
  109. if "%1" == "--config" (
  110. shift
  111. shift
  112. )
  113. if [%2] == [] goto :eof
  114. shift
  115. set _hdfsarguments=
  116. :MakeCmdArgsLoop
  117. if [%1]==[] goto :EndLoop
  118. if not defined _hdfsarguments (
  119. set _hdfsarguments=%1
  120. ) else (
  121. set _hdfsarguments=!_hdfsarguments! %1
  122. )
  123. shift
  124. goto :MakeCmdArgsLoop
  125. :EndLoop
  126. set hdfs-command-arguments=%_hdfsarguments%
  127. goto :eof
  128. :print_usage
  129. @echo Usage: hdfs [--config confdir] COMMAND
  130. @echo where COMMAND is one of:
  131. @echo dfs run a filesystem command on the file systems supported in Hadoop.
  132. @echo namenode -format format the DFS filesystem
  133. @echo secondarynamenode run the DFS secondary namenode
  134. @echo namenode run the DFS namenode
  135. @echo zkfc run the ZK Failover Controller daemon
  136. @echo datanode run a DFS datanode
  137. @echo dfsadmin run a DFS admin client
  138. @echo fsck run a DFS filesystem checking utility
  139. @echo balancer run a cluster balancing utility
  140. @echo jmxget get JMX exported values from NameNode or DataNode.
  141. @echo oiv apply the offline fsimage viewer to an fsimage
  142. @echo oev apply the offline edits viewer to an edits file
  143. @echo fetchdt fetch a delegation token from the NameNode
  144. @echo getconf get config values from configuration
  145. @echo groups get the groups which users belong to
  146. @echo snapshotDiff diff two snapshots of a directory or diff the
  147. @echo current directory contents with a snapshot
  148. @echo lsSnapshottableDir list all snapshottable dirs owned by the current user
  149. @echo Use -help to see options
  150. @echo.
  151. @echo Most commands print help when invoked w/o parameters.
  152. endlocal