Preparing hbase release 2.4.2RC0; tagging and updates to CHANGES.md and RELEASENOTES.md
[hbase.git] / bin / hbase.cmd
bloba927227aa9fb2eafddf10072eac068b927f89dab
1 @echo off
2 @rem/*
3 @rem * Licensed to the Apache Software Foundation (ASF) under one
4 @rem * or more contributor license agreements. See the NOTICE file
5 @rem * distributed with this work for additional information
6 @rem * regarding copyright ownership. The ASF licenses this file
7 @rem * to you under the Apache License, Version 2.0 (the
8 @rem * "License"); you may not use this file except in compliance
9 @rem * with the License. You may obtain a copy of the License at
10 @rem *
11 @rem * http://www.apache.org/licenses/LICENSE-2.0
12 @rem *
13 @rem * Unless required by applicable law or agreed to in writing, software
14 @rem * distributed under the License is distributed on an "AS IS" BASIS,
15 @rem * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 @rem * See the License for the specific language governing permissions and
17 @rem * limitations under the License.
18 @rem */
19 @rem
20 @rem The hbase command script. Based on the hadoop command script putting
21 @rem in hbase classes, libs and configurations ahead of hadoop's.
22 @rem
23 @rem TODO: Narrow the amount of duplicated code.
24 @rem
25 @rem Environment Variables:
26 @rem
27 @rem JAVA_HOME The java implementation to use. Overrides JAVA_HOME.
28 @rem
29 @rem HBASE_CLASSPATH Extra Java CLASSPATH entries.
30 @rem
31 @rem HBASE_HEAPSIZE The maximum amount of heap to use.
32 @rem Default is unset and uses the JVMs default setting
33 @rem (usually 1/4th of the available memory).
34 @rem
35 @rem HBASE_OPTS Extra Java runtime options.
36 @rem
37 @rem HBASE_CONF_DIR Alternate conf dir. Default is ${HBASE_HOME}/conf.
38 @rem
39 @rem HBASE_ROOT_LOGGER The root appender. Default is INFO,console
40 @rem
41 @rem JRUBY_HOME JRuby path: $JRUBY_HOME\lib\jruby.jar should exist.
42 @rem Defaults to the jar packaged with HBase.
43 @rem
44 @rem JRUBY_OPTS Extra options (eg '--1.9') passed to hbase.
45 @rem Empty by default.
46 @rem HBASE_SHELL_OPTS Extra options passed to the hbase shell.
47 @rem Empty by default.
50 setlocal enabledelayedexpansion
52 for %%i in (%0) do (
53 if not defined HBASE_BIN_PATH (
54 set HBASE_BIN_PATH=%%~dpi
58 if "%HBASE_BIN_PATH:~-1%" == "\" (
59 set HBASE_BIN_PATH=%HBASE_BIN_PATH:~0,-1%
62 if "%1" == "--help" (
63 goto :print_usage
64 exit /B 0
66 if "%1" == "-h" (
67 goto :print_usage
68 exit /B 0
71 rem This will set HBASE_HOME, etc.
72 set hbase-config-script=%HBASE_BIN_PATH%\hbase-config.cmd
73 call "%hbase-config-script%" %*
74 if "%1" == "--config" (
75 shift
76 shift
79 rem Detect if we are in hbase sources dir
80 set in_dev_env=false
82 if exist "%HBASE_HOME%\target" set in_dev_env=true
84 rem --service is an internal option. used by MSI setup to install HBase as a windows service
85 if "%1" == "--service" (
86 set service_entry=true
87 shift
90 set hbase-command=%1
91 shift
93 @rem if no args specified, show usage
94 if "%hbase-command%"=="" (
95 goto :print_usage
96 endlocal
97 goto :eof
100 set JAVA_HEAP_MAX=
101 set JAVA_OFFHEAP_MAX=
103 rem check envvars which might override default args
104 if defined HBASE_HEAPSIZE (
105 set JAVA_HEAP_MAX=-Xmx%HBASE_HEAPSIZE%m
108 if defined HBASE_OFFHEAPSIZE (
109 set JAVA_OFFHEAP_MAX=-XX:MaxDirectMemory=%HBASE_OFFHEAPSIZE%m
112 set CLASSPATH=%HBASE_CONF_DIR%;%JAVA_HOME%\lib\tools.jar
114 rem Add maven target directory
115 set cached_classpath_filename=%HBASE_HOME%\hbase-build-configuration\target\cached_classpath.txt
116 if "%in_dev_env%"=="true" (
118 rem adding maven main classes to classpath
119 for /f %%i in ('dir /b "%HBASE_HOME%\hbase-*"') do (
120 if exist %%i\target\classes set CLASSPATH=!CLASSPATH!;%%i\target\classes
123 rem adding maven test classes to classpath
124 rem For developers, add hbase classes to CLASSPATH
125 for /f %%i in ('dir /b "%HBASE_HOME%\hbase-*"') do (
126 if exist %%i\target\test-classes set CLASSPATH=!CLASSPATH!;%%i\target\test-classes
129 if not exist "%cached_classpath_filename%" (
130 echo "As this is a development environment, we need %cached_classpath_filename% to be generated from maven (command: mvn install -DskipTests)"
131 goto :eof
134 for /f "delims=" %%i in ('type "%cached_classpath_filename%"') do set CLASSPATH=%CLASSPATH%;%%i
137 @rem For releases add hbase webapps to CLASSPATH
138 @rem Webapps must come first else it messes up Jetty
139 if exist "%HBASE_HOME%\hbase-webapps" (
140 set CLASSPATH=%CLASSPATH%;%HBASE_HOME%
143 if exist "%HBASE_HOME%\target\hbase-webapps" (
144 set CLASSPATH=%CLASSPATH%;%HBASE_HOME%\target
147 for /F %%f in ('dir /b "%HBASE_HOME%\hbase*.jar" 2^>nul') do (
148 if not "%%f:~-11"=="sources.jar" (
149 set CLASSPATH=!CLASSPATH!;%HBASE_HOME%\%%f
153 @rem Add libs to CLASSPATH
154 if exist "%HBASE_HOME%\lib" (
155 set CLASSPATH=!CLASSPATH!;%HBASE_HOME%\lib\*
158 @rem Add user-specified CLASSPATH last
159 if defined HBASE_CLASSPATH (
160 set CLASSPATH=%CLASSPATH%;%HBASE_CLASSPATH%
163 @rem Default log directory and file
164 if not defined HBASE_LOG_DIR (
165 set HBASE_LOG_DIR=%HBASE_HOME%\logs
168 if not defined HBASE_LOGFILE (
169 set HBASE_LOGFILE=hbase.log
172 set JAVA_PLATFORM=
174 rem If avail, add Hadoop to the CLASSPATH and to the JAVA_LIBRARY_PATH
175 set PATH=%PATH%;"%HADOOP_HOME%\bin"
176 set HADOOP_IN_PATH=hadoop.cmd
178 if exist "%HADOOP_HOME%\bin\%HADOOP_IN_PATH%" (
179 set hadoopCpCommand=call %HADOOP_IN_PATH% classpath 2^>nul
180 for /f "eol= delims=" %%i in ('!hadoopCpCommand!') do set CLASSPATH_FROM_HADOOP=%%i
181 if defined CLASSPATH_FROM_HADOOP (
182 set CLASSPATH=%CLASSPATH%;!CLASSPATH_FROM_HADOOP!
184 set HADOOP_CLASSPATH=%CLASSPATH%
186 set hadoopJLPCommand=call %HADOOP_IN_PATH% org.apache.hadoop.hbase.util.GetJavaProperty java.library.path 2^>nul
187 for /f "eol= delims=" %%i in ('!hadoopJLPCommand!') do set HADOOP_JAVA_LIBRARY_PATH=%%i
188 if not defined JAVA_LIBRARY_PATH (
189 set JAVA_LIBRARY_PATH=!HADOOP_JAVA_LIBRARY_PATH!
190 ) else (
191 set JAVA_LIBRARY_PATH=%JAVA_LIBRARY_PATH%;!HADOOP_JAVA_LIBRARY_PATH!
195 if exist "%HBASE_HOME%\build\native" (
196 set platformCommand=call %JAVA% -classpath "%CLASSPATH%" org.apache.hadoop.util.PlatformName
197 for /f %%i in ('!platformCommand!') do set JAVA_PLATFORM=%%i
198 set _PATH_TO_APPEND=%HBASE_HOME%\build\native\!JAVA_PLATFORM!;%HBASE_HOME%\build\native\!JAVA_PLATFORM!\lib
199 if not defined JAVA_LIBRARY_PATH (
200 set JAVA_LIBRARY_PATH=!_PATH_TO_APPEND!
201 ) else (
202 set JAVA_LIBRARY_PATH=%JAVA_LIBRARY_PATH%;!_PATH_TO_APPEND!
206 rem This loop would set %hbase-command-arguments%
207 set _hbasearguments=
208 :MakeCmdArgsLoop
209 if [%1]==[] goto :EndLoop
211 if not defined _hbasearguments (
212 set _hbasearguments=%1
213 ) else (
214 set _hbasearguments=!_hbasearguments! %1
216 shift
217 goto :MakeCmdArgsLoop
218 :EndLoop
220 set hbase-command-arguments=%_hbasearguments%
222 @rem figure out which class to run
223 set corecommands=shell master regionserver thrift thrift2 rest avro hlog wal hbck hfile zookeeper zkcli mapredcp
224 for %%i in ( %corecommands% ) do (
225 if "%hbase-command%"=="%%i" set corecommand=true
228 if defined corecommand (
229 call :%hbase-command% %hbase-command-arguments%
230 ) else (
231 if "%hbase-command%" == "classpath" (
232 echo %CLASSPATH%
233 goto :eof
235 if "%hbase-command%" == "version" (
236 set CLASS=org.apache.hadoop.hbase.util.VersionInfo
237 ) else (
238 set CLASS=%hbase-command%
242 if not defined HBASE_IDENT_STRING (
243 set HBASE_IDENT_STRING=%USERNAME%
246 @rem Set the right GC options based on the what we are running
247 set servercommands=master regionserver thrift thrift2 rest avro zookeeper
248 for %%i in ( %servercommands% ) do (
249 if "%hbase-command%"=="%%i" set servercommand=true
252 if "%servercommand%" == "true" (
253 set HBASE_OPTS=%HBASE_OPTS% %SERVER_GC_OPTS%
254 ) else (
255 set HBASE_OPTS=%HBASE_OPTS% %CLIENT_GC_OPTS%
258 @rem If HBase is run as a windows service, configure logging
259 if defined service_entry (
260 set HBASE_LOG_PREFIX=hbase-%hbase-command%-%COMPUTERNAME%
261 set HBASE_LOGFILE=!HBASE_LOG_PREFIX!.log
262 if not defined HBASE_ROOT_LOGGER (
263 set HBASE_ROOT_LOGGER=INFO,DRFA
265 set HBASE_SECURITY_LOGGER=INFO,DRFAS
266 set loggc=!HBASE_LOG_DIR!\!HBASE_LOG_PREFIX!.gc
267 set loglog=!HBASE_LOG_DIR!\!HBASE_LOGFILE!
269 if "%HBASE_USE_GC_LOGFILE%" == "true" (
270 set HBASE_OPTS=%HBASE_OPTS% -Xloggc:"!loggc!"
274 @rem for jruby
275 @rem (1) for the commands which need jruby (see jruby-commands defined below)
276 @rem A. when JRUBY_HOME is defined
277 @rem CLASSPATH and HBASE_OPTS are updated according to JRUBY_HOME defined
278 @rem B. when JRUBY_HOME is not defined
279 @rem add jruby packaged with HBase to CLASSPATH
280 @rem (2) for other commands, do nothing
282 @rem check if the commmand needs jruby
283 set jruby-commands=shell org.jruby.Main
284 for %%i in ( %jruby-commands% ) do (
285 if "%hbase-command%"=="%%i" set jruby-needed=true
288 @rem the command needs jruby
289 if defined jruby-needed (
290 @rem JRUBY_HOME is defined
291 if defined JRUBY_HOME (
292 set CLASSPATH=%JRUBY_HOME%\lib\jruby.jar;%CLASSPATH%
293 set HBASE_OPTS=%HBASE_OPTS% -Djruby.home="%JRUBY_HOME%" -Djruby.lib="%JRUBY_HOME%\lib"
296 @rem JRUBY_HOME is not defined
297 if not defined JRUBY_HOME (
298 @rem in dev environment
299 if "%in_dev_env%"=="true" (
300 set cached_classpath_jruby_filename=%HBASE_HOME%\hbase-build-configuration\target\cached_classpath_jruby.txt
301 if not exist "!cached_classpath_jruby_filename!" (
302 echo "As this is a development environment, we need !cached_classpath_jruby_filename! to be generated from maven (command: mvn install -DskipTests)"
303 goto :eof
305 for /f "delims=" %%i in ('type "!cached_classpath_jruby_filename!"') do set CLASSPATH=%%i;%CLASSPATH%
308 @rem not in dev environment
309 if "%in_dev_env%"=="false" (
310 @rem add jruby packaged with HBase to CLASSPATH
311 set JRUBY_PACKAGED_WITH_HBASE=%HBASE_HOME%\lib\ruby\*
312 if defined jruby-needed (
313 set CLASSPATH=!JRUBY_PACKAGED_WITH_HBASE!;!CLASSPATH!
319 @rem Have JVM dump heap if we run out of memory. Files will be 'launch directory'
320 @rem and are named like the following: java_pid21612.hprof. Apparently it does not
321 @rem 'cost' to have this flag enabled. Its a 1.6 flag only. See:
322 @rem http://blogs.sun.com/alanb/entry/outofmemoryerror_looks_a_bit_better
323 set HBASE_OPTS=%HBASE_OPTS% -Dhbase.log.dir="%HBASE_LOG_DIR%"
324 set HBASE_OPTS=%HBASE_OPTS% -Dhbase.log.file="%HBASE_LOGFILE%"
325 set HBASE_OPTS=%HBASE_OPTS% -Dhbase.home.dir="%HBASE_HOME%"
326 set HBASE_OPTS=%HBASE_OPTS% -Dhbase.id.str="%HBASE_IDENT_STRING%"
327 set HBASE_OPTS=%HBASE_OPTS% -XX:OnOutOfMemoryError="taskkill /F /PID %p"
329 if not defined HBASE_ROOT_LOGGER (
330 set HBASE_ROOT_LOGGER=INFO,console
332 set HBASE_OPTS=%HBASE_OPTS% -Dhbase.root.logger="%HBASE_ROOT_LOGGER%"
334 if defined JAVA_LIBRARY_PATH (
335 set HBASE_OPTS=%HBASE_OPTS% -Djava.library.path="%JAVA_LIBRARY_PATH%"
338 rem Enable security logging on the master and regionserver only
339 if not defined HBASE_SECURITY_LOGGER (
340 set HBASE_SECURITY_LOGGER=INFO,NullAppender
341 if "%hbase-command%"=="master" (
342 set HBASE_SECURITY_LOGGER=INFO,DRFAS
344 if "%hbase-command%"=="regionserver" (
345 set HBASE_SECURITY_LOGGER=INFO,DRFAS
348 set HBASE_OPTS=%HBASE_OPTS% -Dhbase.security.logger="%HBASE_SECURITY_LOGGER%"
350 set HEAP_SETTINGS=%JAVA_HEAP_MAX% %JAVA_OFFHEAP_MAX%
351 set java_arguments=%HEAP_SETTINGS% %HBASE_OPTS% -classpath "%CLASSPATH%" %CLASS% %hbase-command-arguments%
353 if defined service_entry (
354 call :makeServiceXml %java_arguments%
355 ) else (
356 call %JAVA% %java_arguments%
359 endlocal
360 goto :eof
362 :shell
363 rem find the hbase ruby sources
364 if exist "%HBASE_HOME%\lib\ruby" (
365 set HBASE_OPTS=%HBASE_OPTS% -Dhbase.ruby.sources="%HBASE_HOME%\lib\ruby"
366 ) else (
367 set HBASE_OPTS=%HBASE_OPTS% -Dhbase.ruby.sources="%HBASE_HOME%\hbase-shell\src\main\ruby"
369 set HBASE_OPTS=%HBASE_OPTS% %HBASE_SHELL_OPTS%
371 set CLASS=org.jruby.Main -X+O %JRUBY_OPTS% "%HBASE_HOME%\bin\hirb.rb"
372 goto :eof
374 :master
375 set CLASS=org.apache.hadoop.hbase.master.HMaster
376 if NOT "%1"=="stop" (
377 set HBASE_OPTS=%HBASE_OPTS% %HBASE_MASTER_OPTS%
379 goto :eof
381 :regionserver
382 set CLASS=org.apache.hadoop.hbase.regionserver.HRegionServer
383 if NOT "%1"=="stop" (
384 set HBASE_OPTS=%HBASE_OPTS% %HBASE_REGIONSERVER_OPTS%
386 goto :eof
388 :thrift
389 set CLASS=org.apache.hadoop.hbase.thrift.ThriftServer
390 if NOT "%1" == "stop" (
391 set HBASE_OPTS=%HBASE_OPTS% %HBASE_THRIFT_OPTS%
393 goto :eof
395 :thrift2
396 set CLASS=org.apache.hadoop.hbase.thrift2.ThriftServer
397 if NOT "%1" == "stop" (
398 set HBASE_OPTS=%HBASE_OPTS% %HBASE_THRIFT_OPTS%
400 goto :eof
402 :rest
403 set CLASS=org.apache.hadoop.hbase.rest.RESTServer
404 if NOT "%1"=="stop" (
405 set HBASE_OPTS=%HBASE_OPTS% %HBASE_REST_OPTS%
407 goto :eof
409 :avro
410 set CLASS=org.apache.hadoop.hbase.avro.AvroServer
411 if NOT "%1"== "stop" (
412 set HBASE_OPTS=%HBASE_OPTS% %HBASE_AVRO_OPTS%
414 goto :eof
416 :zookeeper
417 set CLASS=org.apache.hadoop.hbase.zookeeper.HQuorumPeer
418 if NOT "%1"=="stop" (
419 set HBASE_OPTS=%HBASE_OPTS% %HBASE_ZOOKEEPER_OPTS%
421 goto :eof
423 :hbck
424 set CLASS=org.apache.hadoop.hbase.util.HBaseFsck
425 goto :eof
427 :wal
428 set CLASS=org.apache.hadoop.hbase.wal.WALPrettyPrinter
429 goto :eof
431 :hfile
432 set CLASS=org.apache.hadoop.hbase.io.hfile.HFile
433 goto :eof
435 :zkcli
436 set CLASS=org.apache.hadoop.hbase.zookeeper.ZKMainServer
437 set CLASSPATH=!CLASSPATH!;%HBASE_HOME%\lib\zkcli\*
438 goto :eof
440 :mapredcp
441 set CLASS=org.apache.hadoop.hbase.util.MapreduceDependencyClasspathTool
442 goto :eof
444 :makeServiceXml
445 set arguments=%*
446 @echo ^<service^>
447 @echo ^<id^>%hbase-command%^</id^>
448 @echo ^<name^>%hbase-command%^</name^>
449 @echo ^<description^>This service runs Isotope %hbase-command%^</description^>
450 @echo ^<executable^>%JAVA%^</executable^>
451 @echo ^<arguments^>%arguments%^</arguments^>
452 @echo ^</service^>
453 goto :eof
455 :print_usage
456 echo Usage: hbase [^<options^>] ^<command^> [^<args^>]
457 echo where ^<command^> an option from one of these categories::
458 echo Options:
459 echo --config DIR Configuration direction to use. Default: ./conf
460 echo --help or -h Print this help message
461 echo.
462 echo Commands:
463 echo Some commands take arguments. Pass no args or -h for usage."
464 echo shell Run the HBase shell
465 echo hbck Run the hbase 'fsck' tool
466 echo wal Write-ahead-log analyzer
467 echo hfile Store file analyzer
468 echo zkcli Run the ZooKeeper shell
469 echo master Run an HBase HMaster node
470 echo regionserver Run an HBase HRegionServer node
471 echo zookeeper Run a ZooKeeper server
472 echo rest Run an HBase REST server
473 echo thrift Run the HBase Thrift server
474 echo thrift2 Run the HBase Thrift2 server
475 echo classpath Dump hbase CLASSPATH
476 echo mapredcp Dump CLASSPATH entries required by mapreduce
477 echo version Print the version
478 echo CLASSNAME Run the class named CLASSNAME
479 goto :eof