Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions bin/hbase
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
# HBASE_SHELL_OPTS Extra options passed to the hbase shell.
# Empty by default.
#
# HBASE_JSHELL_ARGS Additional arguments passed to the jshell.
# Defaults to `--startup DEFAULT --startup PRINTING --startup hbase_startup.jsh`
#
bin=`dirname "$0"`
bin=`cd "$bin">/dev/null; pwd`

Expand Down Expand Up @@ -87,6 +90,7 @@ show_usage() {
echo " thrift2 Run the HBase Thrift2 server"
echo " clean Run the HBase clean up script"
fi
echo " jshell Run a jshell with HBase on the classpath"
echo " classpath Dump hbase CLASSPATH"
echo " mapredcp Dump CLASSPATH entries required by mapreduce"
echo " pe Run PerformanceEvaluation"
Expand Down Expand Up @@ -516,6 +520,9 @@ if [[ $jruby_needed ]]; then
fi
fi

# set default values for HBASE_JSHELL_ARGS
read -r -a JSHELL_ARGS <<< "${HBASE_JSHELL_ARGS:-"--startup DEFAULT --startup PRINTING --startup ${HBASE_HOME}/bin/hbase_startup.jsh"}"

# figure out which class to run
if [ "$COMMAND" = "shell" ] ; then
#find the hbase ruby sources
Expand All @@ -535,6 +542,14 @@ if [ "$COMMAND" = "shell" ] ; then
CLASS="org.jruby.Main -X+O ${JRUBY_OPTS} ${HBASE_HOME}/hbase-shell/src/main/ruby/jar-bootstrap.rb"
fi
HBASE_OPTS="$HBASE_OPTS $HBASE_SHELL_OPTS"
elif [ "$COMMAND" = 'jshell' ] ; then
java_version="$(read_java_version)"
major_version_number="$(parse_java_major_version "${java_version}")"
if [ "${major_version_number}" -lt 9 ] ; then
echo "JShell is available only with JDK9 and lated. Detected JDK version is ${java_version}".
exit 1
fi
CLASS='jdk.internal.jshell.tool.JShellToolProvider'
elif [ "$COMMAND" = "hbck" ] ; then
# Look for the -j /path/to/HBCK2.jar parameter. Else pass through to hbck.
case "${1}" in
Expand Down Expand Up @@ -825,9 +840,15 @@ if [ "${DEBUG}" = "true" ]; then
HBASE_OPTS="${HBASE_OPTS} -Xdiag"
fi

# resolve the command arguments
read -r -a CMD_ARGS <<< "$@"
if [ "${#JSHELL_ARGS[@]}" -gt 0 ] ; then
CMD_ARGS=("${JSHELL_ARGS[@]}" "${CMD_ARGS[@]}")
fi

if [ "${HBASE_NOEXEC}" != "" ]; then
"$JAVA" -Dproc_$COMMAND -XX:OnOutOfMemoryError="kill -9 %p" $HEAP_SETTINGS $HBASE_OPTS $CLASS "$@"
"$JAVA" -Dproc_$COMMAND -XX:OnOutOfMemoryError="kill -9 %p" $HEAP_SETTINGS $HBASE_OPTS $CLASS "${CMD_ARGS[@]}"
else
export JVM_PID="$$"
exec "$JAVA" -Dproc_$COMMAND -XX:OnOutOfMemoryError="kill -9 %p" $HEAP_SETTINGS $HBASE_OPTS $CLASS "$@"
exec "$JAVA" -Dproc_$COMMAND -XX:OnOutOfMemoryError="kill -9 %p" $HEAP_SETTINGS $HBASE_OPTS $CLASS "${CMD_ARGS[@]}"
fi
20 changes: 20 additions & 0 deletions bin/hbase_startup.jsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import org.apache.hadoop.hbase.*;
import org.apache.hadoop.hbase.client.*;
3 changes: 3 additions & 0 deletions conf/hbase-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,6 @@
# zipkin. See https://github.com/open-telemetry/opentelemetry-java-instrumentation on how to
# configure exporters and other components through system properties.
# export HBASE_TRACE_OPTS="-Dotel.resource.attributes=service.name=HBase -Dotel.traces.exporter=logging otel.metrics.exporter=none"

# Additional argments passed to jshell invocation
# export HBASE_JSHELL_ARGS="--startup DEFAULT --startup PRINTING --startup hbase_startup.jsh"
1 change: 1 addition & 0 deletions src/main/asciidoc/_chapters/ops_mgt.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Some commands take arguments. Pass no args or -h for usage.
thrift Run the HBase Thrift server
thrift2 Run the HBase Thrift2 server
clean Run the HBase clean up script
jshell Run a jshell with HBase on the classpath
classpath Dump hbase CLASSPATH
mapredcp Dump CLASSPATH entries required by mapreduce
pe Run PerformanceEvaluation
Expand Down