You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by nd...@apache.org on 2021/05/25 16:22:42 UTC

[hbase] branch HBASE-25904 updated (f828aeb -> a109852)

This is an automated email from the ASF dual-hosted git repository.

ndimiduk pushed a change to branch HBASE-25904
in repository https://gitbox.apache.org/repos/asf/hbase.git.


    from f828aeb  disable other checks
     new 3787e14  Revert "Revert "HBASE-25841 Add basic jshell support""
     new a109852  HBASE-25841 Add basic jshell support (adendum)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 bin/hbase                                          | 24 ++++++++++++++++++++--
 .../canary/canary.jsp => bin/hbase_startup.jsh     |  6 +++---
 conf/hbase-env.sh                                  |  3 +++
 src/main/asciidoc/_chapters/ops_mgt.adoc           |  1 +
 4 files changed, 29 insertions(+), 5 deletions(-)
 copy hbase-server/src/main/resources/hbase-webapps/canary/canary.jsp => bin/hbase_startup.jsh (91%)

[hbase] 02/02: HBASE-25841 Add basic jshell support (adendum)

Posted by nd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ndimiduk pushed a commit to branch HBASE-25904
in repository https://gitbox.apache.org/repos/asf/hbase.git

commit a1098522a092e32ca02c2b2227c2c02ba5f2412b
Author: Nick Dimiduk <nd...@apache.org>
AuthorDate: Tue May 25 09:17:47 2021 -0700

    HBASE-25841 Add basic jshell support (adendum)
---
 bin/hbase | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/bin/hbase b/bin/hbase
index f921561..c6612e3 100755
--- a/bin/hbase
+++ b/bin/hbase
@@ -520,9 +520,6 @@ 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
@@ -550,6 +547,8 @@ elif [ "$COMMAND" = 'jshell' ] ; then
     exit 1
   fi
   CLASS='jdk.internal.jshell.tool.JShellToolProvider'
+  # 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"}"
 elif [ "$COMMAND" = "hbck" ] ; then
   # Look for the -j /path/to/HBCK2.jar parameter. Else pass through to hbck.
   case "${1}" in

[hbase] 01/02: Revert "Revert "HBASE-25841 Add basic jshell support""

Posted by nd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ndimiduk pushed a commit to branch HBASE-25904
in repository https://gitbox.apache.org/repos/asf/hbase.git

commit 3787e141ce9049037e985fa1e0a4ed61bf53e787
Author: Nick Dimiduk <nd...@apache.org>
AuthorDate: Tue May 25 09:21:21 2021 -0700

    Revert "Revert "HBASE-25841 Add basic jshell support""
    
    This reverts commit 8e19026e38c14d06a7e46902b89090a614920e87.
---
 bin/hbase                                | 25 +++++++++++++++++++++++--
 bin/hbase_startup.jsh                    | 20 ++++++++++++++++++++
 conf/hbase-env.sh                        |  3 +++
 src/main/asciidoc/_chapters/ops_mgt.adoc |  1 +
 4 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/bin/hbase b/bin/hbase
index 2f27270..f921561 100755
--- a/bin/hbase
+++ b/bin/hbase
@@ -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`
 
@@ -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"
@@ -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
@@ -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
@@ -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
diff --git a/bin/hbase_startup.jsh b/bin/hbase_startup.jsh
new file mode 100644
index 0000000..0f5dd9c
--- /dev/null
+++ b/bin/hbase_startup.jsh
@@ -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.*;
diff --git a/conf/hbase-env.sh b/conf/hbase-env.sh
index 1d21fd5..f660f16 100644
--- a/conf/hbase-env.sh
+++ b/conf/hbase-env.sh
@@ -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"
diff --git a/src/main/asciidoc/_chapters/ops_mgt.adoc b/src/main/asciidoc/_chapters/ops_mgt.adoc
index c494bca..dbdb752 100644
--- a/src/main/asciidoc/_chapters/ops_mgt.adoc
+++ b/src/main/asciidoc/_chapters/ops_mgt.adoc
@@ -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