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
11 @rem
* http
://www.apache.org
/licenses
/LICENSE
-2.0
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.
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.
23 @rem TODO: Narrow the amount of duplicated code.
25 @rem Environment Variables:
27 @rem JAVA_HOME The java implementation to use. Overrides JAVA_HOME.
29 @rem HBASE_CLASSPATH Extra Java CLASSPATH entries.
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).
35 @rem HBASE_OPTS Extra Java runtime options.
37 @rem HBASE_CONF_DIR Alternate conf dir. Default is ${HBASE_HOME}/conf.
39 @rem HBASE_ROOT_LOGGER The root appender. Default is INFO,console
41 @rem JRUBY_HOME JRuby path: $JRUBY_HOME\lib\jruby.jar should exist.
42 @rem Defaults to the jar packaged with HBase.
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
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 rem This will set HBASE_HOME, etc.
63 set hbase-config-script=%HBASE_BIN_PATH%\hbase-config.cmd
64 call "%hbase-config-script%" %*
65 if "%1" == "--config" (
70 rem Detect if we are in hbase sources dir
73 if exist "%HBASE_HOME%\target" set in_dev_env=true
75 rem --service is an internal option. used by MSI setup to install HBase as a windows service
76 if "%1" == "--service" (
77 set service_entry=true
84 @rem if no args specified, show usage
85 if "%hbase-command%"=="" (
94 rem check envvars which might override default args
95 if defined HBASE_HEAPSIZE (
96 set JAVA_HEAP_MAX=-Xmx%HBASE_HEAPSIZE%m
99 if defined HBASE_OFFHEAPSIZE (
100 set JAVA_OFFHEAP_MAX=-XX:MaxDirectMemory=%HBASE_OFFHEAPSIZE%m
103 set CLASSPATH=%HBASE_CONF_DIR%;%JAVA_HOME%\lib\tools.jar
105 rem Add maven target directory
106 set cached_classpath_filename=%HBASE_HOME%\hbase-build-configuration\target\cached_classpath.txt
107 if "%in_dev_env%"=="true" (
109 rem adding maven main classes to classpath
110 for /f %%i in ('dir /b
"%HBASE_HOME%\hbase-*"') do (
111 if exist %%i\target\classes set CLASSPATH=!CLASSPATH!;%%i\target\classes
114 rem adding maven test classes to classpath
115 rem For developers, add hbase classes to CLASSPATH
116 for /f %%i in ('dir /b
"%HBASE_HOME%\hbase-*"') do (
117 if exist %%i\target\test-classes set CLASSPATH=!CLASSPATH!;%%i\target\test-classes
120 if not exist "%cached_classpath_filename%" (
121 echo "As this is a development environment, we need %cached_classpath_filename% to be generated from maven (command: mvn install -DskipTests)"
125 for /f "delims=" %%i in ('type "%cached_classpath_filename%"') do set CLASSPATH=%CLASSPATH%;%%i
128 @rem For releases add hbase webapps to CLASSPATH
129 @rem Webapps must come first else it messes up Jetty
130 if exist "%HBASE_HOME%\hbase-webapps" (
131 set CLASSPATH=%CLASSPATH%;%HBASE_HOME%
134 if exist "%HBASE_HOME%\target\hbase-webapps" (
135 set CLASSPATH=%CLASSPATH%;%HBASE_HOME%\target
138 for /F %%f in ('dir /b
"%HBASE_HOME%\hbase*.jar" 2^
>nul
') do (
139 if not "%%f:~-11"=="sources.jar" (
140 set CLASSPATH=!CLASSPATH!;%HBASE_HOME%\%%f
144 @rem Add libs to CLASSPATH
145 if exist "%HBASE_HOME%\lib" (
146 set CLASSPATH=!CLASSPATH!;%HBASE_HOME%\lib\*
149 @rem Add user-specified CLASSPATH last
150 if defined HBASE_CLASSPATH (
151 set CLASSPATH=%CLASSPATH%;%HBASE_CLASSPATH%
154 @rem Default log directory and file
155 if not defined HBASE_LOG_DIR (
156 set HBASE_LOG_DIR=%HBASE_HOME%\logs
159 if not defined HBASE_LOGFILE (
160 set HBASE_LOGFILE=hbase.log
165 rem If avail, add Hadoop to the CLASSPATH and to the JAVA_LIBRARY_PATH
166 set PATH=%PATH%;"%HADOOP_HOME%\bin"
167 set HADOOP_IN_PATH=hadoop.cmd
169 if exist "%HADOOP_HOME%\bin\%HADOOP_IN_PATH%" (
170 set hadoopCpCommand=call %HADOOP_IN_PATH% classpath 2^>nul
171 for /f "eol= delims=" %%i in ('!hadoopCpCommand
!') do set CLASSPATH_FROM_HADOOP=%%i
172 if defined CLASSPATH_FROM_HADOOP (
173 set CLASSPATH=%CLASSPATH%;!CLASSPATH_FROM_HADOOP!
175 set HADOOP_CLASSPATH=%CLASSPATH%
177 set hadoopJLPCommand=call %HADOOP_IN_PATH% org.apache.hadoop.hbase.util.GetJavaProperty java.library.path 2^>nul
178 for /f "eol= delims=" %%i in ('!hadoopJLPCommand
!') do set HADOOP_JAVA_LIBRARY_PATH=%%i
179 if not defined JAVA_LIBRARY_PATH (
180 set JAVA_LIBRARY_PATH=!HADOOP_JAVA_LIBRARY_PATH!
182 set JAVA_LIBRARY_PATH=%JAVA_LIBRARY_PATH%;!HADOOP_JAVA_LIBRARY_PATH!
186 if exist "%HBASE_HOME%\build\native" (
187 set platformCommand=call %JAVA% -classpath "%CLASSPATH%" org.apache.hadoop.util.PlatformName
188 for /f %%i in ('!platformCommand
!') do set JAVA_PLATFORM=%%i
189 set _PATH_TO_APPEND=%HBASE_HOME%\build\native\!JAVA_PLATFORM!;%HBASE_HOME%\build\native\!JAVA_PLATFORM!\lib
190 if not defined JAVA_LIBRARY_PATH (
191 set JAVA_LIBRARY_PATH=!_PATH_TO_APPEND!
193 set JAVA_LIBRARY_PATH=%JAVA_LIBRARY_PATH%;!_PATH_TO_APPEND!
197 rem This loop would set %hbase-command-arguments%
200 if [%1]==[] goto :EndLoop
202 if not defined _hbasearguments (
203 set _hbasearguments=%1
205 set _hbasearguments=!_hbasearguments! %1
208 goto :MakeCmdArgsLoop
211 set hbase-command-arguments=%_hbasearguments%
213 @rem figure out which class to run
214 set corecommands=shell master regionserver thrift thrift2 rest avro hlog wal hbck hfile zookeeper zkcli mapredcp
215 for %%i in ( %corecommands% ) do (
216 if "%hbase-command%"=="%%i" set corecommand=true
219 if defined corecommand (
220 call :%hbase-command% %hbase-command-arguments%
222 if "%hbase-command%" == "classpath" (
226 if "%hbase-command%" == "version" (
227 set CLASS=org.apache.hadoop.hbase.util.VersionInfo
229 set CLASS=%hbase-command%
233 if not defined HBASE_IDENT_STRING (
234 set HBASE_IDENT_STRING=%USERNAME%
237 @rem Set the right GC options based on the what we are running
238 set servercommands=master regionserver thrift thrift2 rest avro zookeeper
239 for %%i in ( %servercommands% ) do (
240 if "%hbase-command%"=="%%i" set servercommand=true
243 if "%servercommand%" == "true" (
244 set HBASE_OPTS=%HBASE_OPTS% %SERVER_GC_OPTS%
246 set HBASE_OPTS=%HBASE_OPTS% %CLIENT_GC_OPTS%
249 @rem If HBase is run as a windows service, configure logging
250 if defined service_entry (
251 set HBASE_LOG_PREFIX=hbase-%hbase-command%-%COMPUTERNAME%
252 set HBASE_LOGFILE=!HBASE_LOG_PREFIX!.log
253 if not defined HBASE_ROOT_LOGGER (
254 set HBASE_ROOT_LOGGER=INFO,DRFA
256 set HBASE_SECURITY_LOGGER=INFO,DRFAS
257 set loggc=!HBASE_LOG_DIR!\!HBASE_LOG_PREFIX!.gc
258 set loglog=!HBASE_LOG_DIR!\!HBASE_LOGFILE!
260 if "%HBASE_USE_GC_LOGFILE%" == "true" (
261 set HBASE_OPTS=%HBASE_OPTS% -Xloggc:"!loggc!"
266 @rem (1) for the commands which need jruby (see jruby-commands defined below)
267 @rem A. when JRUBY_HOME is defined
268 @rem CLASSPATH and HBASE_OPTS are updated according to JRUBY_HOME defined
269 @rem B. when JRUBY_HOME is not defined
270 @rem add jruby packaged with HBase to CLASSPATH
271 @rem (2) for other commands, do nothing
273 @rem check if the commmand needs jruby
274 set jruby-commands=shell org.jruby.Main
275 for %%i in ( %jruby-commands% ) do (
276 if "%hbase-command%"=="%%i" set jruby-needed=true
279 @rem the command needs jruby
280 if defined jruby-needed (
281 @rem JRUBY_HOME is defined
282 if defined JRUBY_HOME (
283 set CLASSPATH=%JRUBY_HOME%\lib\jruby.jar;%CLASSPATH%
284 set HBASE_OPTS=%HBASE_OPTS% -Djruby.home="%JRUBY_HOME%" -Djruby.lib="%JRUBY_HOME%\lib"
287 @rem JRUBY_HOME is not defined
288 if not defined JRUBY_HOME (
289 @rem in dev environment
290 if "%in_dev_env%"=="true" (
291 set cached_classpath_jruby_filename=%HBASE_HOME%\hbase-build-configuration\target\cached_classpath_jruby.txt
292 if not exist "!cached_classpath_jruby_filename!" (
293 echo "As this is a development environment, we need !cached_classpath_jruby_filename! to be generated from maven (command: mvn install -DskipTests)"
296 for /f "delims=" %%i in ('type "!cached_classpath_jruby_filename!"') do set CLASSPATH=%%i;%CLASSPATH%
299 @rem not in dev environment
300 if "%in_dev_env%"=="false" (
301 @rem add jruby packaged with HBase to CLASSPATH
302 set JRUBY_PACKAGED_WITH_HBASE=%HBASE_HOME%\lib\ruby\*
303 if defined jruby-needed (
304 set CLASSPATH=!JRUBY_PACKAGED_WITH_HBASE!;!CLASSPATH!
310 @rem Have JVM dump heap if we run out of memory. Files will be 'launch directory
'
311 @rem and are named like the following: java_pid21612.hprof. Apparently it does not
312 @rem 'cost
' to have this flag enabled. Its a 1.6 flag only. See:
313 @rem http://blogs.sun.com/alanb/entry/outofmemoryerror_looks_a_bit_better
314 set HBASE_OPTS=%HBASE_OPTS% -Dhbase.log.dir="%HBASE_LOG_DIR%"
315 set HBASE_OPTS=%HBASE_OPTS% -Dhbase.log.file="%HBASE_LOGFILE%"
316 set HBASE_OPTS=%HBASE_OPTS% -Dhbase.home.dir="%HBASE_HOME%"
317 set HBASE_OPTS=%HBASE_OPTS% -Dhbase.id.str="%HBASE_IDENT_STRING%"
318 set HBASE_OPTS=%HBASE_OPTS% -XX:OnOutOfMemoryError="taskkill /F /PID %p"
320 if not defined HBASE_ROOT_LOGGER (
321 set HBASE_ROOT_LOGGER=INFO,console
323 set HBASE_OPTS=%HBASE_OPTS% -Dhbase.root.logger="%HBASE_ROOT_LOGGER%"
325 if defined JAVA_LIBRARY_PATH (
326 set HBASE_OPTS=%HBASE_OPTS% -Djava.library.path="%JAVA_LIBRARY_PATH%"
329 rem Enable security logging on the master and regionserver only
330 if not defined HBASE_SECURITY_LOGGER (
331 set HBASE_SECURITY_LOGGER=INFO,NullAppender
332 if "%hbase-command%"=="master" (
333 set HBASE_SECURITY_LOGGER=INFO,DRFAS
335 if "%hbase-command%"=="regionserver" (
336 set HBASE_SECURITY_LOGGER=INFO,DRFAS
339 set HBASE_OPTS=%HBASE_OPTS% -Dhbase.security.logger="%HBASE_SECURITY_LOGGER%"
341 set HEAP_SETTINGS=%JAVA_HEAP_MAX% %JAVA_OFFHEAP_MAX%
342 set java_arguments=%HEAP_SETTINGS% %HBASE_OPTS% -classpath "%CLASSPATH%" %CLASS% %hbase-command-arguments%
344 if defined service_entry (
345 call :makeServiceXml %java_arguments%
347 call %JAVA% %java_arguments%
354 rem find the hbase ruby sources
355 if exist "%HBASE_HOME%\lib\ruby" (
356 set HBASE_OPTS=%HBASE_OPTS% -Dhbase.ruby.sources="%HBASE_HOME%\lib\ruby"
358 set HBASE_OPTS=%HBASE_OPTS% -Dhbase.ruby.sources="%HBASE_HOME%\hbase-shell\src\main\ruby"
360 set HBASE_OPTS=%HBASE_OPTS% %HBASE_SHELL_OPTS%
362 set CLASS=org.jruby.Main -X+O %JRUBY_OPTS% "%HBASE_HOME%\bin\hirb.rb"
366 set CLASS=org.apache.hadoop.hbase.master.HMaster
367 if NOT "%1"=="stop" (
368 set HBASE_OPTS=%HBASE_OPTS% %HBASE_MASTER_OPTS%
373 set CLASS=org.apache.hadoop.hbase.regionserver.HRegionServer
374 if NOT "%1"=="stop" (
375 set HBASE_OPTS=%HBASE_OPTS% %HBASE_REGIONSERVER_OPTS%
380 set CLASS=org.apache.hadoop.hbase.thrift.ThriftServer
381 if NOT "%1" == "stop" (
382 set HBASE_OPTS=%HBASE_OPTS% %HBASE_THRIFT_OPTS%
387 set CLASS=org.apache.hadoop.hbase.thrift2.ThriftServer
388 if NOT "%1" == "stop" (
389 set HBASE_OPTS=%HBASE_OPTS% %HBASE_THRIFT_OPTS%
394 set CLASS=org.apache.hadoop.hbase.rest.RESTServer
395 if NOT "%1"=="stop" (
396 set HBASE_OPTS=%HBASE_OPTS% %HBASE_REST_OPTS%
401 set CLASS=org.apache.hadoop.hbase.avro.AvroServer
402 if NOT "%1"== "stop" (
403 set HBASE_OPTS=%HBASE_OPTS% %HBASE_AVRO_OPTS%
408 set CLASS=org.apache.hadoop.hbase.zookeeper.HQuorumPeer
409 if NOT "%1"=="stop" (
410 set HBASE_OPTS=%HBASE_OPTS% %HBASE_ZOOKEEPER_OPTS%
415 set CLASS=org.apache.hadoop.hbase.util.HBaseFsck
419 set CLASS=org.apache.hadoop.hbase.wal.WALPrettyPrinter
423 set CLASS=org.apache.hadoop.hbase.io.hfile.HFile
427 set CLASS=org.apache.hadoop.hbase.zookeeper.ZKMainServer
428 set CLASSPATH=!CLASSPATH!;%HBASE_HOME%\lib\zkcli\*
432 set CLASS=org.apache.hadoop.hbase.util.MapreduceDependencyClasspathTool
438 @echo ^<id^>%hbase-command%^</id^>
439 @echo ^<name^>%hbase-command%^</name^>
440 @echo ^<description^>This service runs Isotope %hbase-command%^</description^>
441 @echo ^<executable^>%JAVA%^</executable^>
442 @echo ^<arguments^>%arguments%^</arguments^>
447 echo Usage: hbase [^<options^>] ^<command^> [^<args^>]
448 echo where ^<command^> an option from one of these categories::
450 echo --config DIR Configuration direction to use. Default: ./conf
453 echo Some commands take arguments. Pass no args or -h for usage."
454 echo shell Run the HBase shell
455 echo hbck Run the hbase 'fsck
' tool
456 echo wal Write-ahead-log analyzer
457 echo hfile Store file analyzer
458 echo zkcli Run the ZooKeeper shell
459 echo master Run an HBase HMaster node
460 echo regionserver Run an HBase HRegionServer node
461 echo zookeeper Run a ZooKeeper server
462 echo rest Run an HBase REST server
463 echo thrift Run the HBase Thrift server
464 echo thrift2 Run the HBase Thrift2 server
465 echo classpath Dump hbase CLASSPATH
466 echo mapredcp Dump CLASSPATH entries required by mapreduce
467 echo version Print the version
468 echo CLASSNAME Run the class named CLASSNAME