HBASE-15199 Move jruby jar so only on runtime classpath for hbase-shell and support scripts.

Signed-off-by: Sean Busbey <busbey@apache.org>
Signed-off-by: Jerry He <jerryjch@apache.org>
This commit is contained in:
Xiang Li 2017-04-26 23:48:34 +08:00 committed by Sean Busbey
parent 30d0c3fdde
commit 083796d2e6
3 changed files with 80 additions and 13 deletions

View File

@ -48,7 +48,7 @@
# JRUBY_HOME JRuby path: $JRUBY_HOME/lib/jruby.jar should exist. # JRUBY_HOME JRuby path: $JRUBY_HOME/lib/jruby.jar should exist.
# Defaults to the jar packaged with HBase. # Defaults to the jar packaged with HBase.
# #
# JRUBY_OPTS Extra options (eg '--1.9') passed to the hbase shell. # JRUBY_OPTS Extra options (eg '--1.9') passed to hbase.
# Empty by default. # Empty by default.
# #
# HBASE_SHELL_OPTS Extra options passed to the hbase shell. # HBASE_SHELL_OPTS Extra options passed to the hbase shell.
@ -293,13 +293,41 @@ if [ "$AUTH_AS_SERVER" == "true" ] || [ "$COMMAND" = "hbck" ]; then
fi fi
fi fi
# for jruby
# (1) when JRUBY_HOME is specified explicitly, eg. export JRUBY_HOME=/usr/local/share/jruby
# for all commands, CLASSPATH and HBASE_OPTS are updated according to JRUBY_HOME specified
# (2) when JRUBY_HOME is not specified explicitly
# A. for jruby_cmds defined below, add JRUBY_PACKAGED_WITH_HBASE into CLASSPATH
# B. for other commands, do nothing
if [ "$JRUBY_HOME" != "" ]; then # JRUBY_HOME is specified explicitly, eg. export JRUBY_HOME=/usr/local/share/jruby
# add jruby.jar into CLASSPATH
CLASSPATH="$JRUBY_HOME/lib/jruby.jar:$CLASSPATH"
# add jruby to HBASE_OPTS
HBASE_OPTS="$HBASE_OPTS -Djruby.home=$JRUBY_HOME -Djruby.lib=$JRUBY_HOME/lib"
else # JRUBY_HOME is not specified explicitly
# check if the commmand needs jruby
declare -a jruby_cmds=("shell" "org.jruby.Main")
for cmd in "${jruby_cmds[@]}"; do
if [[ $cmd == "$COMMAND" ]]; then
jruby_needed=true
break
fi
done
# add JRUBY_PACKAGED_WITH_HBASE to CLASSPATH when jruby is needed
JRUBY_PACKAGED_WITH_HBASE="$HBASE_HOME/lib/ruby/*.jar"
if [[ $jruby_needed ]]; then # the command needs jruby
for jruby_jar in $JRUBY_PACKAGED_WITH_HBASE; do
CLASSPATH=$jruby_jar:$CLASSPATH;
done
fi
fi
# figure out which class to run # figure out which class to run
if [ "$COMMAND" = "shell" ] ; then if [ "$COMMAND" = "shell" ] ; then
# eg export JRUBY_HOME=/usr/local/share/jruby
if [ "$JRUBY_HOME" != "" ] ; then
CLASSPATH="$JRUBY_HOME/lib/jruby.jar:$CLASSPATH"
HBASE_OPTS="$HBASE_OPTS -Djruby.home=$JRUBY_HOME -Djruby.lib=$JRUBY_HOME/lib"
fi
#find the hbase ruby sources #find the hbase ruby sources
if [ -d "$HBASE_HOME/lib/ruby" ]; then if [ -d "$HBASE_HOME/lib/ruby" ]; then
HBASE_OPTS="$HBASE_OPTS -Dhbase.ruby.sources=$HBASE_HOME/lib/ruby" HBASE_OPTS="$HBASE_OPTS -Dhbase.ruby.sources=$HBASE_HOME/lib/ruby"

View File

@ -41,7 +41,7 @@
@rem JRUBY_HOME JRuby path: $JRUBY_HOME\lib\jruby.jar should exist. @rem JRUBY_HOME JRuby path: $JRUBY_HOME\lib\jruby.jar should exist.
@rem Defaults to the jar packaged with HBase. @rem Defaults to the jar packaged with HBase.
@rem @rem
@rem JRUBY_OPTS Extra options (eg '--1.9') passed to the hbase shell. @rem JRUBY_OPTS Extra options (eg '--1.9') passed to hbase.
@rem Empty by default. @rem Empty by default.
@rem HBASE_SHELL_OPTS Extra options passed to the hbase shell. @rem HBASE_SHELL_OPTS Extra options passed to the hbase shell.
@rem Empty by default. @rem Empty by default.
@ -262,6 +262,33 @@ if defined service_entry (
) )
) )
@rem for jruby
@rem (1) when JRUBY_HOME is defined
@rem for all commands, CLASSPATH and HBASE_OPTS are updated according to JRUBY_HOME specified
@rem (2) when JRUBY_HOME is not defined
@rem A. for jruby-commands defined below, add JRUBY_PACKAGED_WITH_HBASE into CLASSPATH
@rem B. for other commands, do nothing
@rem JRUBY_HOME is defined
if defined JRUBY_HOME (
set CLASSPATH=%CLASSPATH%;%JRUBY_HOME%\lib\jruby.jar
set HBASE_OPTS=%HBASE_OPTS% -Djruby.home="%JRUBY_HOME%" -Djruby.lib="%JRUBY_HOME%\lib"
)
@rem JRUBY_HOME is not defined
if not defined JRUBY_HOME (
@rem check if the commmand needs jruby
set jruby-commands=shell org.jruby.Main
for %%i in ( !jruby-commands! ) do (
if "%hbase-command%"=="%%i" set jruby-needed=true
)
@rem add JRUBY_PACKAGED_WITH_HBASE to CLASSPATH if jruby is needed
set JRUBY_PACKAGED_WITH_HBASE=%HBASE_HOME%\lib\ruby\*
if defined jruby-needed (
set CLASSPATH=!JRUBY_PACKAGED_WITH_HBASE!;!CLASSPATH!
)
)
@rem Have JVM dump heap if we run out of memory. Files will be 'launch directory' @rem Have JVM dump heap if we run out of memory. Files will be 'launch directory'
@rem and are named like the following: java_pid21612.hprof. Apparently it does not @rem and are named like the following: java_pid21612.hprof. Apparently it does not
@ -307,11 +334,6 @@ endlocal
goto :eof goto :eof
:shell :shell
rem eg export JRUBY_HOME=/usr/local/share/jruby
if defined JRUBY_HOME (
set CLASSPATH=%CLASSPATH%;%JRUBY_HOME%\lib\jruby.jar
set HBASE_OPTS=%HBASE_OPTS% -Djruby.home="%JRUBY_HOME%" -Djruby.lib="%JRUBY_HOME%\lib"
)
rem find the hbase ruby sources rem find the hbase ruby sources
if exist "%HBASE_HOME%\lib\ruby" ( if exist "%HBASE_HOME%\lib\ruby" (
set HBASE_OPTS=%HBASE_OPTS% -Dhbase.ruby.sources="%HBASE_HOME%\lib\ruby" set HBASE_OPTS=%HBASE_OPTS% -Dhbase.ruby.sources="%HBASE_HOME%\lib\ruby"

View File

@ -55,7 +55,12 @@
<outputDirectory>lib</outputDirectory> <outputDirectory>lib</outputDirectory>
<unpack>false</unpack> <unpack>false</unpack>
<dependencySets> <dependencySets>
<dependencySet/> <!-- Exclude jruby-complete from hbase_home/lib -->
<dependencySet>
<excludes>
<exclude>org.jruby:jruby-complete</exclude>
</excludes>
</dependencySet>
</dependencySets> </dependencySets>
</binaries> </binaries>
</moduleSet> </moduleSet>
@ -81,4 +86,16 @@
<lineEnding>unix</lineEnding> <lineEnding>unix</lineEnding>
</file> </file>
</files> </files>
<!-- Add jruby-complete to hbase_home/lib/ruby.
Update JRUBY_PACKAGED_WITH_HBASE in bin/hbase and hbase.cmd if you would like to update outputDirectory below -->
<dependencySets>
<dependencySet>
<outputDirectory>lib/ruby</outputDirectory>
<includes>
<include>org.jruby:jruby-complete</include>
</includes>
</dependencySet>
</dependencySets>
</assembly> </assembly>