From 27477b9ee1e99a6ea370c56d2d98744e8bb2badd Mon Sep 17 00:00:00 2001 From: Sakthi Date: Sun, 5 May 2019 21:26:00 -0700 Subject: [PATCH] HBASE-22264: Separate out jars related to JDK 11 into a folder in /lib --- bin/hbase | 63 +++++++++++++++++++ .../src/main/assembly/hadoop-two-compat.xml | 7 +++ pom.xml | 6 ++ 3 files changed, 76 insertions(+) diff --git a/bin/hbase b/bin/hbase index 1af2213001e4f85d93ee8f46cf460c78b3179121..af0155d0cf2b40829ba1ffb81d6b1841697ea6ba 100755 --- a/bin/hbase +++ b/bin/hbase @@ -441,6 +441,14 @@ 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 the development env class path stuff if $in_dev_env; then add_maven_deps_to_classpath "cached_classpath.txt" @@ -649,6 +657,61 @@ else CLASS=$COMMAND fi +# Add lib/jdk11 jars to the classpath + +if [ "${DEBUG}" = "true" ]; then + echo "Deciding on addition of lib/jdk11 jars to the classpath" +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 + JAVA=$JAVA_HOME/bin/java + + version=$($JAVA -version 2>&1 | awk -F '"' '/version/ {print $2}') + # '-' check is for cases such as "13-ea" + version_number=$(echo "$version" | cut -d'.' -f1 | cut -d'-' -f1) + + if [ "${DEBUG}" = "true" ]; then + echo "HBASE_JDK11 not set hence using JDK detection." + echo "Extracted JDK version - ${version}, version_number - ${version_number}" + fi + + if [[ "$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 + if [ "${DEBUG}" = "true" ]; then + echo "Added JDK11 jars to classpath." + fi +elif [ "${DEBUG}" = "true" ]; then + echo "JDK11 jars skipped from classpath." +fi + # Have JVM dump heap if we run out of memory. Files will be 'launch directory' # and are named like the following: java_pid21612.hprof. Apparently it doesn't # 'cost' to have this flag enabled. Its a 1.6 flag only. See: diff --git a/hbase-assembly/src/main/assembly/hadoop-two-compat.xml b/hbase-assembly/src/main/assembly/hadoop-two-compat.xml index 05e2fc9565266e4b8f08167e8d58a026d1cbb77e..27492a7133b96f6b65e55ba4ba307cb6dc132005 100644 --- a/hbase-assembly/src/main/assembly/hadoop-two-compat.xml +++ b/hbase-assembly/src/main/assembly/hadoop-two-compat.xml @@ -68,6 +68,7 @@ com.sun.xml.ws:jaxws-ri + com.sun.activation:javax.activation org.jruby:jruby-complete com.sun.jersey:* @@ -190,6 +191,12 @@ jline:jline + + lib/jdk11 + + com.sun.activation:javax.activation + + diff --git a/pom.xml b/pom.xml index ee85e939fbfaf70472554738ce38d90fed6639a3..146f6a6c0ce5863164d5fa47466de601002133bf 100755 --- a/pom.xml +++ b/pom.xml @@ -2314,6 +2314,12 @@ jaxws-ri 2.3.1 pom + + + javax.activation + javax.activation-api + + -- 2.20.1 (Apple Git-117)