hdfs.cmd 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. @rem This changes %1, %2 etc. Hence those cannot be used after calling this.
  102. :make_command_arguments
  103. if "%1" == "--config" (
  104. shift
  105. shift
  106. )
  107. if [%2] == [] goto :eof
  108. shift
  109. set _hdfsarguments=
  110. :MakeCmdArgsLoop
  111. if [%1]==[] goto :EndLoop
  112. if not defined _hdfsarguments (
  113. set _hdfsarguments=%1
  114. ) else (
  115. set _hdfsarguments=!_hdfsarguments! %1
  116. )
  117. shift
  118. goto :MakeCmdArgsLoop
  119. :EndLoop
  120. set hdfs-command-arguments=%_hdfsarguments%
  121. goto :eof
  122. :print_usage
  123. @echo Usage: hdfs [--config confdir] COMMAND
  124. @echo where COMMAND is one of:
  125. @echo dfs run a filesystem command on the file systems supported in Hadoop.
  126. @echo namenode -format format the DFS filesystem
  127. @echo secondarynamenode run the DFS secondary namenode
  128. @echo namenode run the DFS namenode
  129. @echo zkfc run the ZK Failover Controller daemon
  130. @echo datanode run a DFS datanode
  131. @echo dfsadmin run a DFS admin client
  132. @echo fsck run a DFS filesystem checking utility
  133. @echo balancer run a cluster balancing utility
  134. @echo jmxget get JMX exported values from NameNode or DataNode.
  135. @echo oiv apply the offline fsimage viewer to an fsimage
  136. @echo oev apply the offline edits viewer to an edits file
  137. @echo fetchdt fetch a delegation token from the NameNode
  138. @echo getconf get config values from configuration
  139. @echo groups get the groups which users belong to
  140. @echo Use -help to see options
  141. @echo.
  142. @echo Most commands print help when invoked w/o parameters.
  143. endlocal