Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HBASE-28708 Remove the specific logic for jdk11 in hbase-assembly and… #6069

Merged
merged 1 commit into from
Jul 17, 2024
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
97 changes: 19 additions & 78 deletions bin/hbase
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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"}"
Expand Down Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions bin/hbase-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF
cat 1>&2 <<EOF
+======================================================================+
| Error: JAVA_HOME is not set |
+----------------------------------------------------------------------+
| Please download the latest Sun JDK from the Sun Java web site |
| > 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() {
Expand Down Expand Up @@ -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
67 changes: 1 addition & 66 deletions hbase-assembly/src/main/assembly/hadoop-three-compat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,36 +65,7 @@
<dependencySets>
<dependencySet>
<excludes>
<!-- Exclude J2EE libraries that get pulled in when building on JDK11 -->
<exclude>com.sun.activation:javax.activation</exclude>
<!-- The following artifacts are transitive dependencies of com.sun.xml.ws:jaxws-ri:pom
They are needed to be included in lib/jdk11 to be added to classpath during
Java 11 runtime hence excluding from main lib.
-->
<exclude>com.sun.xml.ws:*</exclude>
<exclude>jakarta.annotation:jakarta.annotation-api</exclude>
<exclude>org.glassfish.jaxb:*</exclude>
<exclude>com.sun.istack:istack-commons-runtime</exclude>
<exclude>org.glassfish.gmbal:gmbal</exclude>
<exclude>org.glassfish.external:management-api</exclude>
<exclude>org.glassfish.pfl:*</exclude>
<exclude>org.jvnet.staxex:stax-ex</exclude>
<exclude>com.sun.xml.stream.buffer:streambuffer</exclude>
<exclude>org.jvnet.mimepull:mimepull</exclude>
<exclude>com.sun.xml.fastinfoset:FastInfoset</exclude>
<exclude>org.glassfish.ha:ha-api</exclude>
<exclude>com.sun.xml.messaging.saaj:saaj-impl</exclude>
<exclude>jakarta.activation:jakarta.activation-api</exclude>
<exclude>com.sun.xml.bind:jaxb-xjc</exclude>
<exclude>com.sun.xml.bind:jaxb-jxc</exclude>
<exclude>jakarta.mail:jakarta.mail-api</exclude>
<exclude>jakarta.persistence:jakarta.persistence-api</exclude>
<exclude>org.eclipse.persistence:*</exclude>
<exclude>jakarta.xml.ws:jakarta.xml.ws-api</exclude>
<exclude>jakarta.xml.bind:jakarta.xml.bind-api</exclude>
<exclude>jakarta.xml.soap:jakarta.xml.soap-api</exclude>
<exclude>jakarta.jws:jakarta.jws-api</exclude>
<!-- Exclude libraries that we put in their own dirs under lib/ -->
<!-- Exclude libraries that we put in their own dirs under lib/ -->
<exclude>org.jruby:jruby-complete</exclude>
<exclude>com.sun.jersey:*</exclude>
<exclude>com.sun.jersey.contribs:*</exclude>
Expand Down Expand Up @@ -221,42 +192,6 @@
<include>jline:jline</include>
</includes>
</dependencySet>
<dependencySet>
<outputDirectory>lib/jdk11</outputDirectory>
<useTransitiveDependencies>true</useTransitiveDependencies>
<includes>
<include>com.sun.activation:javax.activation</include>
<!-- The following artifacts are transitive dependencies of com.sun.xml.ws:jaxws-ri:pom
They are needed to be included in lib/jdk11 to be added to classpath during
Java 11 runtime
-->
<include>com.sun.xml.ws:*</include>
<include>jakarta.annotation:jakarta.annotation-api</include>
<include>org.glassfish.jaxb:*</include>
<include>com.sun.istack:istack-commons-runtime</include>
<include>org.glassfish.gmbal:gmbal</include>
<include>org.glassfish.external:management-api</include>
<include>org.glassfish.pfl:*</include>
<include>org.jvnet.staxex:stax-ex</include>
<include>com.sun.xml.stream.buffer:streambuffer</include>
<include>org.jvnet.mimepull:mimepull</include>
<include>com.sun.xml.fastinfoset:FastInfoset</include>
<include>org.glassfish.ha:ha-api</include>
<include>com.sun.xml.messaging.saaj:saaj-impl</include>
<include>com.fasterxml.woodstox:woodstox-core</include>
<include>org.codehaus.woodstox:stax2-api</include>
<include>jakarta.activation:jakarta.activation-api</include>
<include>com.sun.xml.bind:jaxb-xjc</include>
<include>com.sun.xml.bind:jaxb-jxc</include>
<include>jakarta.mail:jakarta.mail-api</include>
<include>jakarta.persistence:jakarta.persistence-api</include>
<include>org.eclipse.persistence:*</include>
<include>jakarta.xml.ws:jakarta.xml.ws-api</include>
<include>jakarta.xml.bind:jakarta.xml.bind-api</include>
<include>jakarta.xml.soap:jakarta.xml.soap-api</include>
<include>jakarta.jws:jakarta.jws-api</include>
</includes>
</dependencySet>
<dependencySet>
<outputDirectory>lib/trace</outputDirectory>
<includes>
Expand Down