From d7a9fc81217aca648f3998b924ef7ee772317f39 Mon Sep 17 00:00:00 2001 From: Duo Zhang Date: Wed, 17 Jul 2024 10:43:22 +0800 Subject: [PATCH] HBASE-28708 Remove the specific logic for jdk11 in hbase-assembly and change our script to only support jdk17 (#6069) Signed-off-by: Xin Sun --- bin/hbase | 97 ++++--------------- bin/hbase-config.sh | 14 ++- .../src/main/assembly/hadoop-three-compat.xml | 67 +------------ 3 files changed, 31 insertions(+), 147 deletions(-) diff --git a/bin/hbase b/bin/hbase index 81379eaa587d..ff0c57c055c7 100755 --- a/bin/hbase +++ b/bin/hbase @@ -158,15 +158,7 @@ fi # establish a default value for HBASE_OPTS if it's not already set. For now, # all we set is the garbage collector. if [ -z "${HBASE_OPTS}" ] ; then - major_version_number="$(parse_java_major_version "$(read_java_version)")" - case "$major_version_number" in - 8|9|10) - HBASE_OPTS="-XX:+UseConcMarkSweepGC" - ;; - 11|*) - HBASE_OPTS="-XX:+UseG1GC" - ;; - esac + HBASE_OPTS="-XX:+UseG1GC" export HBASE_OPTS fi @@ -487,17 +479,22 @@ add_maven_deps_to_classpath() { CLASSPATH=${CLASSPATH}:$(cat "${f}") } -add_jdk11_deps_to_classpath() { - for f in ${HBASE_HOME}/lib/jdk11/*; do - if [ -f "${f}" ]; then - CLASSPATH="${CLASSPATH}:${f}" - fi - done -} - -add_jdk11_jvm_flags() { - # Keep in sync with hbase-surefire.jdk11.flags in the root pom.xml - HBASE_OPTS="$HBASE_OPTS -Dorg.apache.hbase.thirdparty.io.netty.tryReflectionSetAccessible=true --add-modules jdk.unsupported --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/jdk.internal.ref=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.util.concurrent=ALL-UNNAMED --add-exports java.base/jdk.internal.misc=ALL-UNNAMED --add-exports java.security.jgss/sun.security.krb5=ALL-UNNAMED --add-exports java.base/sun.net.dns=ALL-UNNAMED --add-exports java.base/sun.net.util=ALL-UNNAMED" +add_jdk17_jvm_flags() { + # Keep in sync with hbase-surefire.jdk17.flags in the root pom.xml + HBASE_OPTS="$HBASE_OPTS -Dorg.apache.hbase.thirdparty.io.netty.tryReflectionSetAccessible=true" + HBASE_OPTS="$HBASE_OPTS --add-modules jdk.unsupported" + HBASE_OPTS="$HBASE_OPTS --add-opens java.base/java.io=ALL-UNNAMED" + HBASE_OPTS="$HBASE_OPTS --add-opens java.base/java.nio=ALL-UNNAMED" + HBASE_OPTS="$HBASE_OPTS --add-opens java.base/sun.nio.ch=ALL-UNNAMED" + HBASE_OPTS="$HBASE_OPTS --add-opens java.base/java.lang=ALL-UNNAMED" + HBASE_OPTS="$HBASE_OPTS --add-opens java.base/jdk.internal.ref=ALL-UNNAMED" + HBASE_OPTS="$HBASE_OPTS --add-opens java.base/java.lang.reflect=ALL-UNNAMED" + HBASE_OPTS="$HBASE_OPTS --add-opens java.base/java.util=ALL-UNNAMED" + HBASE_OPTS="$HBASE_OPTS --add-opens java.base/java.util.concurrent=ALL-UNNAMED" + HBASE_OPTS="$HBASE_OPTS --add-exports java.base/jdk.internal.misc=ALL-UNNAMED" + HBASE_OPTS="$HBASE_OPTS --add-exports java.security.jgss/sun.security.krb5=ALL-UNNAMED" + HBASE_OPTS="$HBASE_OPTS --add-exports java.base/sun.net.dns=ALL-UNNAMED" + HBASE_OPTS="$HBASE_OPTS --add-exports java.base/sun.net.util=ALL-UNNAMED" } add_opentelemetry_agent() { @@ -566,12 +563,6 @@ if [ "$COMMAND" = "shell" ] ; then 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' # 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"}" @@ -784,59 +775,9 @@ if [[ "$CLASS" =~ .*IntegrationTest.* ]] ; then fi fi -# Add lib/jdk11 jars to the classpath - +add_jdk17_jvm_flags if [ "${DEBUG}" = "true" ]; then - echo "Deciding on addition of lib/jdk11 jars to the classpath and setting JVM module flags" -fi - -addJDK11Jars=false - -if [ "${HBASE_JDK11}" != "" ]; then - # Use the passed Environment Variable HBASE_JDK11 - if [ "${HBASE_JDK11}" = "include" ]; then - addJDK11Jars=true - if [ "${DEBUG}" = "true" ]; then - echo "HBASE_JDK11 set as 'include' hence adding JDK11 jars to classpath." - fi - elif [ "${HBASE_JDK11}" = "exclude" ]; then - if [ "${DEBUG}" = "true" ]; then - echo "HBASE_JDK11 set as 'exclude' hence skipping JDK11 jars to classpath." - fi - else - echo "[HBASE_JDK11] contains unsupported value(s) - ${HBASE_JDK11}. Ignoring passed value." - echo "[HBASE_JDK11] supported values: [include, exclude]." - fi -else - # Use JDK detection - version="$(read_java_version)" - major_version_number="$(parse_java_major_version "$version")" - - if [ "${DEBUG}" = "true" ]; then - echo "HBASE_JDK11 not set hence using JDK detection." - echo "Extracted JDK version - ${version}, major_version_number - ${major_version_number}" - fi - - if [[ "$major_version_number" -ge "11" ]]; then - if [ "${DEBUG}" = "true" ]; then - echo "Version ${version} is greater-than/equal to 11 hence adding JDK11 jars to classpath." - fi - addJDK11Jars=true - elif [ "${DEBUG}" = "true" ]; then - echo "Version ${version} is lesser than 11 hence skipping JDK11 jars from classpath." - fi -fi - -if [ "${addJDK11Jars}" = "true" ]; then - add_jdk11_deps_to_classpath - add_jdk11_jvm_flags - if [ "${DEBUG}" = "true" ]; then - echo "Added JDK11 jars to classpath." - echo "Added JDK11 JVM flags too." - fi -elif [ "${DEBUG}" = "true" ]; then - echo "JDK11 jars skipped from classpath." - echo "Skipped adding JDK11 JVM flags." + echo "Added JDK17 JVM flags." fi if [[ "${HBASE_OTEL_TRACING_ENABLED:-false}" = "true" ]] ; then diff --git a/bin/hbase-config.sh b/bin/hbase-config.sh index 0e8b3feed213..d9afa19a4aaa 100644 --- a/bin/hbase-config.sh +++ b/bin/hbase-config.sh @@ -164,17 +164,17 @@ export MALLOC_ARENA_MAX=${MALLOC_ARENA_MAX:-4} # Now having JAVA_HOME defined is required if [ -z "$JAVA_HOME" ]; then - cat 1>&2 <&2 < http://www.oracle.com/technetwork/java/javase/downloads | | | -| HBase requires Java 1.8 or later. | +| HBase requires Java 17 or later. | +======================================================================+ EOF - exit 1 + exit 1 fi function read_java_version() { @@ -203,3 +203,11 @@ function parse_java_major_version() { ;; esac } + +# test whether we are on jdk17 or above +java_version="$(read_java_version)" +major_version_number="$(parse_java_major_version "$java_version")" +if [ "${major_version_number}" -lt 17 ] ; then + echo "HBase can only be run on JDK17 and later. Detected JDK version is ${java_version}". + exit 1 +fi diff --git a/hbase-assembly/src/main/assembly/hadoop-three-compat.xml b/hbase-assembly/src/main/assembly/hadoop-three-compat.xml index 27962b6e473c..244de766ce72 100644 --- a/hbase-assembly/src/main/assembly/hadoop-three-compat.xml +++ b/hbase-assembly/src/main/assembly/hadoop-three-compat.xml @@ -65,36 +65,7 @@ - - com.sun.activation:javax.activation - - com.sun.xml.ws:* - jakarta.annotation:jakarta.annotation-api - org.glassfish.jaxb:* - com.sun.istack:istack-commons-runtime - org.glassfish.gmbal:gmbal - org.glassfish.external:management-api - org.glassfish.pfl:* - org.jvnet.staxex:stax-ex - com.sun.xml.stream.buffer:streambuffer - org.jvnet.mimepull:mimepull - com.sun.xml.fastinfoset:FastInfoset - org.glassfish.ha:ha-api - com.sun.xml.messaging.saaj:saaj-impl - jakarta.activation:jakarta.activation-api - com.sun.xml.bind:jaxb-xjc - com.sun.xml.bind:jaxb-jxc - jakarta.mail:jakarta.mail-api - jakarta.persistence:jakarta.persistence-api - org.eclipse.persistence:* - jakarta.xml.ws:jakarta.xml.ws-api - jakarta.xml.bind:jakarta.xml.bind-api - jakarta.xml.soap:jakarta.xml.soap-api - jakarta.jws:jakarta.jws-api - + org.jruby:jruby-complete com.sun.jersey:* com.sun.jersey.contribs:* @@ -221,42 +192,6 @@ jline:jline - - lib/jdk11 - true - - com.sun.activation:javax.activation - - com.sun.xml.ws:* - jakarta.annotation:jakarta.annotation-api - org.glassfish.jaxb:* - com.sun.istack:istack-commons-runtime - org.glassfish.gmbal:gmbal - org.glassfish.external:management-api - org.glassfish.pfl:* - org.jvnet.staxex:stax-ex - com.sun.xml.stream.buffer:streambuffer - org.jvnet.mimepull:mimepull - com.sun.xml.fastinfoset:FastInfoset - org.glassfish.ha:ha-api - com.sun.xml.messaging.saaj:saaj-impl - com.fasterxml.woodstox:woodstox-core - org.codehaus.woodstox:stax2-api - jakarta.activation:jakarta.activation-api - com.sun.xml.bind:jaxb-xjc - com.sun.xml.bind:jaxb-jxc - jakarta.mail:jakarta.mail-api - jakarta.persistence:jakarta.persistence-api - org.eclipse.persistence:* - jakarta.xml.ws:jakarta.xml.ws-api - jakarta.xml.bind:jakarta.xml.bind-api - jakarta.xml.soap:jakarta.xml.soap-api - jakarta.jws:jakarta.jws-api - - lib/trace