You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ak...@apache.org on 2018/10/11 03:03:42 UTC

ignite git commit: IGNITE-7926 Web Agent: Support launching with Java 8+.

Repository: ignite
Updated Branches:
  refs/heads/master 4890ed9a1 -> f313d6504


IGNITE-7926 Web Agent: Support launching with Java 8+.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f313d650
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f313d650
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f313d650

Branch: refs/heads/master
Commit: f313d650448207942357a88bcdeab5833c8bd963
Parents: 4890ed9
Author: Vasiliy Sisko <vs...@gridgain.com>
Authored: Thu Oct 11 10:03:34 2018 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Thu Oct 11 10:03:34 2018 +0700

----------------------------------------------------------------------
 .../web-agent/bin/ignite-web-agent.bat          | 63 ++++++++++++--
 .../web-agent/bin/ignite-web-agent.sh           | 81 +++++++++---------
 .../web-agent/bin/include/functions.sh          | 88 ++++++++++++++++++++
 3 files changed, 183 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/f313d650/modules/web-console/web-agent/bin/ignite-web-agent.bat
----------------------------------------------------------------------
diff --git a/modules/web-console/web-agent/bin/ignite-web-agent.bat b/modules/web-console/web-agent/bin/ignite-web-agent.bat
index 387447f..1c305ca 100644
--- a/modules/web-console/web-agent/bin/ignite-web-agent.bat
+++ b/modules/web-console/web-agent/bin/ignite-web-agent.bat
@@ -43,7 +43,7 @@ goto checkIgniteHome2
 if defined JAVA_HOME  goto checkJdk
     echo %0, ERROR:
     echo JAVA_HOME environment variable is not found.
-    echo Please point JAVA_HOME variable to location of JDK 1.7 or JDK 1.8.
+    echo Please point JAVA_HOME variable to location of JDK 1.8 or JDK 9.
     echo You can also download latest JDK at http://java.com/download.
 goto error_finish
 
@@ -52,18 +52,31 @@ goto error_finish
 if exist "%JAVA_HOME%\bin\java.exe" goto checkJdkVersion
     echo %0, ERROR:
     echo JAVA is not found in JAVA_HOME=%JAVA_HOME%.
-    echo Please point JAVA_HOME variable to installation of JDK 1.7 or JDK 1.8.
+    echo Please point JAVA_HOME variable to installation of JDK 1.8 or JDK 9.
     echo You can also download latest JDK at http://java.com/download.
 goto error_finish
 
 :checkJdkVersion
-"%JAVA_HOME%\bin\java.exe" -version 2>&1 | findstr "1\.[78]\." > nul
-if %ERRORLEVEL% equ 0 goto run_java
+set cmd="%JAVA_HOME%\bin\java.exe"
+for /f "tokens=* USEBACKQ" %%f in (`%cmd% -version 2^>^&1`) do (
+    set var=%%f
+    goto :LoopEscape
+)
+:LoopEscape
+
+for /f "tokens=1-3  delims= " %%a in ("%var%") do set JAVA_VER_STR=%%c
+set JAVA_VER_STR=%JAVA_VER_STR:"=%
+
+for /f "tokens=1,2 delims=." %%a in ("%JAVA_VER_STR%.x") do set MAJOR_JAVA_VER=%%a & set MINOR_JAVA_VER=%%b
+if %MAJOR_JAVA_VER% == 1 set MAJOR_JAVA_VER=%MINOR_JAVA_VER%
+
+if %MAJOR_JAVA_VER% LSS 8 (
     echo %0, ERROR:
     echo The version of JAVA installed in %JAVA_HOME% is incorrect.
-    echo Please point JAVA_HOME variable to installation of JDK 1.7 or JDK 1.8.
+    echo Please point JAVA_HOME variable to installation of JDK 1.8 or JDK 9.
     echo You can also download latest JDK at http://java.com/download.
-goto error_finish
+	goto error_finish
+)
 
 :run_java
 
@@ -74,13 +87,47 @@ goto error_finish
 ::
 "%JAVA_HOME%\bin\java.exe" -version 2>&1 | findstr "1\.[7]\." > nul
 if %ERRORLEVEL% equ 0 (
-    if "%JVM_OPTS%" == "" set JVM_OPTS=-Xms1g -Xmx1g -server -XX:+AggressiveOpts -XX:MaxPermSize=256m
+    if "%JVM_OPTS%" == "" set JVM_OPTS=-Xms1g -Xmx1g -server -XX:MaxPermSize=256m
 ) else (
-    if "%JVM_OPTS%" == "" set JVM_OPTS=-Xms1g -Xmx1g -server -XX:+AggressiveOpts -XX:MaxMetaspaceSize=256m
+    if "%JVM_OPTS%" == "" set JVM_OPTS=-Xms1g -Xmx1g -server -XX:MaxMetaspaceSize=256m
 )
 
 set JVM_OPTS=%JVM_OPTS% -Djava.net.useSystemProxies=true
 
+::
+:: Final JVM_OPTS for Java 9+ compatibility
+::
+if "%MAJOR_JAVA_VER%" == "8" (
+    set JVM_OPTS= ^
+    -XX:+AggressiveOpts ^
+    %JVM_OPTS%
+)
+
+if %MAJOR_JAVA_VER% GEQ 9 if %MAJOR_JAVA_VER% LSS 11 (
+    set JVM_OPTS= ^
+    -XX:+AggressiveOpts ^
+    --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED ^
+    --add-exports=java.base/sun.nio.ch=ALL-UNNAMED ^
+    --add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED ^
+    --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED ^
+    --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED ^
+    --illegal-access=permit ^
+    --add-modules=java.transaction ^
+    --add-modules=java.xml.bind ^
+    %JVM_OPTS%
+)
+
+if "%MAJOR_JAVA_VER%" == "11" (
+    set JVM_OPTS= ^
+    --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED ^
+    --add-exports=java.base/sun.nio.ch=ALL-UNNAMED ^
+    --add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED ^
+    --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED ^
+    --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED ^
+    --illegal-access=permit ^
+    %JVM_OPTS%
+)
+
 "%JAVA_HOME%\bin\java.exe" %JVM_OPTS% -cp "*" org.apache.ignite.console.agent.AgentLauncher %*
 
 set JAVA_ERRORLEVEL=%ERRORLEVEL%

http://git-wip-us.apache.org/repos/asf/ignite/blob/f313d650/modules/web-console/web-agent/bin/ignite-web-agent.sh
----------------------------------------------------------------------
diff --git a/modules/web-console/web-agent/bin/ignite-web-agent.sh b/modules/web-console/web-agent/bin/ignite-web-agent.sh
index 530bc7f..3a649e3 100755
--- a/modules/web-console/web-agent/bin/ignite-web-agent.sh
+++ b/modules/web-console/web-agent/bin/ignite-web-agent.sh
@@ -16,49 +16,14 @@
 # limitations under the License.
 #
 
-# Check JAVA_HOME.
-if [ "$JAVA_HOME" = "" ]; then
-    JAVA=`type -p java`
-    RETCODE=$?
-
-    if [ $RETCODE -ne 0 ]; then
-        echo $0", ERROR:"
-        echo "JAVA_HOME environment variable is not found."
-        echo "Please point JAVA_HOME variable to location of JDK 1.7 or JDK 1.8."
-        echo "You can also download latest JDK at http://java.com/download"
-
-        exit 1
-    fi
+SOURCE=$(dirname "$0")
 
-    JAVA_HOME=
-else
-    JAVA=${JAVA_HOME}/bin/java
-fi
+source "${SOURCE}"/include/functions.sh
 
 #
-# Check JDK.
+# Discover path to Java executable and check it's version.
 #
-if [ ! -e "$JAVA" ]; then
-    echo $0", ERROR:"
-    echo "JAVA is not found in JAVA_HOME=$JAVA_HOME."
-    echo "Please point JAVA_HOME variable to installation of JDK 1.7 or JDK 1.8."
-    echo "You can also download latest JDK at http://java.com/download"
-
-    exit 1
-fi
-
-JAVA_VER=`"$JAVA" -version 2>&1 | egrep "1\.[78]\."`
-
-if [ "$JAVA_VER" == "" ]; then
-    echo $0", ERROR:"
-    echo "The version of JAVA installed in JAVA_HOME=$JAVA_HOME is incorrect."
-    echo "Please point JAVA_HOME variable to installation of JDK 1.7 or JDK 1.8."
-    echo "You can also download latest JDK at http://java.com/download"
-
-    exit 1
-fi
-
-SOURCE="${BASH_SOURCE[0]}"
+checkJava
 
 #
 # Set IGNITE_HOME.
@@ -87,12 +52,46 @@ cd $DIR
 #
 if [ -z "$JVM_OPTS" ] ; then
     if [[ `"$JAVA" -version 2>&1 | egrep "1\.[7]\."` ]]; then
-        JVM_OPTS="-Xms1g -Xmx1g -server -XX:+AggressiveOpts -XX:MaxPermSize=256m"
+        JVM_OPTS="-Xms1g -Xmx1g -server -XX:MaxPermSize=256m"
     else
-        JVM_OPTS="-Xms1g -Xmx1g -server -XX:+AggressiveOpts -XX:MaxMetaspaceSize=256m"
+        JVM_OPTS="-Xms1g -Xmx1g -server -XX:MaxMetaspaceSize=256m"
     fi
 fi
 
 JVM_OPTS="${JVM_OPTS} -Djava.net.useSystemProxies=true"
 
+#
+# Final JVM_OPTS for Java 9+ compatibility
+#
+javaMajorVersion "${JAVA_HOME}/bin/java"
+
+if [ $version -eq 8 ] ; then
+    JVM_OPTS="\
+        -XX:+AggressiveOpts \
+         ${JVM_OPTS}"
+
+elif [ $version -gt 8 ] && [ $version -lt 11 ]; then
+    JVM_OPTS="\
+        -XX:+AggressiveOpts \
+        --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED \
+        --add-exports=java.base/sun.nio.ch=ALL-UNNAMED \
+        --add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED \
+        --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED \
+        --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED \
+        --illegal-access=permit \
+        --add-modules=java.transaction \
+        --add-modules=java.xml.bind \
+        ${JVM_OPTS}"
+
+elif [ $version -eq 11 ] ; then
+    JVM_OPTS="\
+        --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED \
+        --add-exports=java.base/sun.nio.ch=ALL-UNNAMED \
+        --add-exports=java.management/com.sun.jmx.mbeanserver=ALL-UNNAMED \
+        --add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED \
+        --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED \
+        --illegal-access=permit \
+        ${JVM_OPTS}"
+fi
+
 "$JAVA" ${JVM_OPTS} -cp "*" org.apache.ignite.console.agent.AgentLauncher "$@"

http://git-wip-us.apache.org/repos/asf/ignite/blob/f313d650/modules/web-console/web-agent/bin/include/functions.sh
----------------------------------------------------------------------
diff --git a/modules/web-console/web-agent/bin/include/functions.sh b/modules/web-console/web-agent/bin/include/functions.sh
new file mode 100644
index 0000000..0c316e3
--- /dev/null
+++ b/modules/web-console/web-agent/bin/include/functions.sh
@@ -0,0 +1,88 @@
+#!/bin/bash
+#
+# 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.
+#
+
+#
+# This is a collection of utility functions to be used in other Ignite scripts.
+# Before calling any function from this file you have to import it:
+#   if [ "${IGNITE_HOME}" = "" ];
+#       then IGNITE_HOME_TMP="$(dirname "$(cd "$(dirname "$0")"; "pwd")")";
+#       else IGNITE_HOME_TMP=${IGNITE_HOME};
+#   fi
+#
+#   source "${IGNITE_HOME_TMP}"/bin/include/functions.sh
+#
+
+# Extract java version to `version` variable.
+javaVersion() {
+    version=$("$1" -version 2>&1 | awk -F '"' '/version/ {print $2}')
+}
+
+# Extract only major version of java to `version` variable.
+javaMajorVersion() {
+    javaVersion "$1"
+    version="${version%%.*}"
+
+    if [ ${version} -eq 1 ]; then
+        # Version seems starts from 1, we need second number.
+        javaVersion "$1"
+        backIFS=$IFS
+
+        IFS=. ver=(${version##*-})
+        version=${ver[1]}
+
+        IFS=$backIFS
+    fi
+}
+
+#
+# Discovers path to Java executable and checks it's version.
+# The function exports JAVA variable with path to Java executable.
+#
+checkJava() {
+    # Check JAVA_HOME.
+    if [ "$JAVA_HOME" = "" ]; then
+        JAVA=`type -p java`
+        RETCODE=$?
+
+        if [ $RETCODE -ne 0 ]; then
+            echo $0", ERROR:"
+            echo "JAVA_HOME environment variable is not found."
+            echo "Please point JAVA_HOME variable to location of JDK 1.8 or JDK 9."
+            echo "You can also download latest JDK at http://java.com/download"
+
+            exit 1
+        fi
+
+        JAVA_HOME=
+    else
+        JAVA=${JAVA_HOME}/bin/java
+    fi
+
+    #
+    # Check JDK.
+    #
+    javaMajorVersion "$JAVA"
+
+    if [ $version -lt 8 ]; then
+        echo "$0, ERROR:"
+        echo "The $version version of JAVA installed in JAVA_HOME=$JAVA_HOME is incompatible."
+        echo "Please point JAVA_HOME variable to installation of JDK 1.8 or JDK 9."
+        echo "You can also download latest JDK at http://java.com/download"
+        exit 1
+    fi
+}