You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by st...@apache.org on 2024/01/22 05:47:54 UTC

(phoenix-omid) branch master updated: OMID-272 Support JDK17

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

stoty pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/phoenix-omid.git


The following commit(s) were added to refs/heads/master by this push:
     new edc79fc3 OMID-272 Support JDK17
edc79fc3 is described below

commit edc79fc3038d326c811ffe342bafccd9245c4ef7
Author: Istvan Toth <st...@apache.org>
AuthorDate: Fri Jan 19 07:55:12 2024 +0100

    OMID-272 Support JDK17
---
 pom.xml                | 55 +++++++++++++++++++++++++++++++
 tso-server/bin/omid.sh | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 143 insertions(+)

diff --git a/pom.xml b/pom.xml
index 89d00561..f9dc9e60 100644
--- a/pom.xml
+++ b/pom.xml
@@ -209,6 +209,37 @@
         <harmless.artifactId>hbase-client</harmless.artifactId>
         <harmless.version>${hbase.version}</harmless.version>
         <additionalparam>-Xdoclint:none</additionalparam>
+
+        <!-- JDK module options, copied from HBase. Not all of these are strictly necessary for Omid -->
+        <surefire.Xmx>2200m</surefire.Xmx>
+        <surefire.Xms>1000m</surefire.Xms>
+        <omid-surefire.argLine>-enableassertions -Xmx${surefire.Xmx}
+          -Xms${surefire.Xms} -Djava.security.egd=file:/dev/./urandom -Djava.net.preferIPv4Stack=true
+          -Djava.awt.headless=true -Djdk.net.URLClassPath.disableClassPathURLCheck=true
+          -Dorg.apache.hbase.thirdparty.io.netty.leakDetection.level=advanced
+          -Dio.netty.eventLoopThreads=3 -Dio.opentelemetry.context.enableStrictContext=true</omid-surefire.argLine>
+        <!-- Keep these options in sync with add_jdk11_jvm_flags() in bin/omid.sh.
+        Currently, all of these options are known to be required by HBase, and not the test cases -->
+        <omid-surefire.jdk11.flags>-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</omid-surefire.jdk11.flags>
+        <!-- java.base/jdk.internal.util.random=ALL-UNNAMED is required by the HBase test code, so we do
+        not need this in bin/ -->
+        <!-- We probably do not need this at all for Omid, but it's easier to keep in sync with
+        HBase this way -->
+        <omid-surefire.jdk17.flags>--add-opens java.base/jdk.internal.util.random=ALL-UNNAMED</omid-surefire.jdk17.flags>
+        <argLine>${omid-surefire.argLine}</argLine>
     </properties>
 
     <build>
@@ -481,6 +512,30 @@
 
 
     <profiles>
+        <profile>
+            <id>build-with-jdk11</id>
+            <activation>
+                <jdk>[11,)</jdk>
+            </activation>
+            <properties>
+                <maven.compiler.release>${releaseTarget}</maven.compiler.release>
+                <!-- TODO: replicate logic for windows support -->
+                <argLine>${omid-surefire.jdk11.flags}
+                    ${omid-surefire.argLine}</argLine>
+            </properties>
+        </profile>
+
+        <profile>
+            <id>build-with-jdk17</id>
+            <activation>
+                <jdk>[17,)</jdk>
+            </activation>
+            <properties>
+                <argLine>${omid-surefire.jdk11.flags}
+                    ${omid-surefire.jdk17.flags}
+                    ${omid-surefire.argLine}</argLine>
+            </properties>
+        </profile>
 
         <profile>
             <id>site-deploy</id>
diff --git a/tso-server/bin/omid.sh b/tso-server/bin/omid.sh
index fa5afac5..01e918bb 100755
--- a/tso-server/bin/omid.sh
+++ b/tso-server/bin/omid.sh
@@ -39,6 +39,92 @@ for j in ../lib/*.jar; do
     CLASSPATH=$CLASSPATH:$j
 done
 
+#JVM detection and list of JDK11 options copied from HBase with slight modifications
+
+function read_java_version() {
+  # Avoid calling java repeatedly
+  if [ -z "$read_java_version_cached" ]; then
+    properties="$("${JAVA_HOME}/bin/java" -XshowSettings:properties -version 2>&1)"
+    read_java_version_cached="$(echo "${properties}" | "${GREP}" java.runtime.version | head -1 | "${SED}" -e 's/.* = \([^ ]*\)/\1/')"
+  fi
+  echo "$read_java_version_cached"
+}
+
+# Inspect the system properties exposed by this JVM to identify the major
+# version number. Normalize on the popular version number, thus consider JDK
+# 1.8 as version "8".
+function parse_java_major_version() {
+  complete_version=$1
+  # split off suffix version info like '-b10' or '+10' or '_10'
+  # careful to not use GNU Sed extensions
+  version="$(echo "$complete_version" | "${SED}" -e 's/+/_/g' -e 's/-/_/g' | cut -d'_' -f1)"
+  case "$version" in
+  1.*)
+    echo "$version" | cut -d'.' -f2
+    ;;
+  *)
+    echo "$version" | cut -d'.' -f1
+    ;;
+  esac
+}
+
+add_jdk11_jvm_flags() {
+  # Keep in sync with omid-surefire.jdk11.flags in the root pom.xml
+  OMID_OPTS="$OMID_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 [...]
+}
+
+setup_jdk_options()  {
+
+  # We don't actually add any JARs, but this is copied from HBase which does
+  addJDK11Jars=false
+
+  if [ "${OMID_JDK11}" != "" ]; then
+    # Use the passed Environment Variable HBASE_JDK11
+    if [ "${OMID_JDK11}" = "include" ]; then
+      addJDK11Jars=true
+      if [ "${DEBUG}" = "true" ]; then
+        echo "OMID_JDK11 set as 'include' hence adding JDK11 jars to classpath."
+      fi
+    elif [ "${OMID_JDK11}" = "exclude" ]; then
+      if [ "${DEBUG}" = "true" ]; then
+        echo "OMID_JDK11 set as 'exclude' hence skipping JDK11 jars to classpath."
+      fi
+    else
+      echo "[OMID_JDK11] contains unsupported value(s) - ${HBASE_JDK11}. Ignoring passed value."
+      echo "[OMID_JDK11] supported values: [include, exclude]."
+    fi
+  else
+    # Use JDK detection
+    export GREP="${GREP-grep}"
+    export SED="${SED-sed}"
+    version="$(read_java_version)"
+    major_version_number="$(parse_java_major_version "$version")"
+
+    if [ "${DEBUG}" = "true" ]; then
+      echo "OMID_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_jvm_flags
+    if [ "${DEBUG}" = "true" ]; then
+       echo "Added JDK11 JVM flags."
+    fi
+  elif [ "${DEBUG}" = "true" ]; then
+    echo "Skipped adding JDK11 JVM flags."
+  fi
+}
+
 tso() {
     exec java $JVM_FLAGS $OMID_OPTS -cp $CLASSPATH org.apache.omid.tso.TSOServer $@
 }
@@ -73,6 +159,8 @@ if [ $# = 0 ]; then
     exit 1
 fi
 
+setup_jdk_options
+
 COMMAND=$1
 shift