rocketmq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vongosl...@apache.org
Subject [rocketmq] branch feature_support_java11 updated: [ISSUE #1870] Add Support for Java 9+ and compatible to previous Java version (#2210)
Date Thu, 15 Oct 2020 03:11:25 GMT
This is an automated email from the ASF dual-hosted git repository.

vongosling pushed a commit to branch feature_support_java11
in repository https://gitbox.apache.org/repos/asf/rocketmq.git


The following commit(s) were added to refs/heads/feature_support_java11 by this push:
     new ed94f11  [ISSUE #1870] Add Support for Java 9+ and compatible to previous Java version
(#2210)
ed94f11 is described below

commit ed94f118094c24dda15fd91a12ff8e4820d41fa7
Author: 张哈希 <zhxhash@vip.sina.com>
AuthorDate: Thu Oct 15 03:08:09 2020 +0000

    [ISSUE #1870] Add Support for Java 9+ and compatible to previous Java version (#2210)
    
    * add jdk11 jvm option
    
    * add jdk11 jvm option for server
    
    * fix jdk11 jvm option for server
    
    * [maven-release-plugin] prepare for next development iteration
    
    * add support JVM Flag for Java version not less than 9 (including Java 9 - 14)
    
    * add support JVM Flag for Java version not less than 9 (including Java 9 - 14) in windows
env
    
    * remove useless comment
    
    Co-authored-by: zhanghaoxin-at-826767166263 <COk6iTbDdOqj/yq53u9n9vPTy+3pmZNcm4mKOhImudI=>
    Co-authored-by: rongtongjin <794220751@qq.com>
---
 distribution/bin/runbroker.cmd | 17 ++++++++++++++++
 distribution/bin/runbroker.sh  | 43 ++++++++++++++++++++++++++++-----------
 distribution/bin/runserver.cmd | 13 ++++++++++++
 distribution/bin/runserver.sh  | 46 +++++++++++++++++++++---------------------
 distribution/bin/tools.cmd     | 13 +++++++++++-
 distribution/bin/tools.sh      | 15 +++++++++++---
 6 files changed, 108 insertions(+), 39 deletions(-)

diff --git a/distribution/bin/runbroker.cmd b/distribution/bin/runbroker.cmd
index eab7e30..d7f5083 100644
--- a/distribution/bin/runbroker.cmd
+++ b/distribution/bin/runbroker.cmd
@@ -28,6 +28,12 @@ set CLASSPATH=.;%BASE_DIR%conf;%CLASSPATH%
 rem ===========================================================================================
 rem  JVM Configuration
 rem ===========================================================================================
+
+for /f tokens^=2-5^ delims^=.-_^" %%j in ('java -fullversion 2^>^&1') do @set "JAVA_VERSION=%%j"
+if %JAVA_VERSION% EQU 1 goto java8-
+goto java9+
+
+:java8-
 set "JAVA_OPT=%JAVA_OPT% -server -Xms2g -Xmx2g -Xmn1g"
 set "JAVA_OPT=%JAVA_OPT% -XX:+UseG1GC -XX:G1HeapRegionSize=16m -XX:G1ReservePercent=25 -XX:InitiatingHeapOccupancyPercent=30
-XX:SoftRefLRUPolicyMSPerMB=0 -XX:SurvivorRatio=8"
 set "JAVA_OPT=%JAVA_OPT% -verbose:gc -Xloggc:%USERPROFILE%\mq_gc.log -XX:+PrintGCDetails
-XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintAdaptiveSizePolicy"
@@ -38,5 +44,16 @@ set "JAVA_OPT=%JAVA_OPT% -XX:MaxDirectMemorySize=15g"
 set "JAVA_OPT=%JAVA_OPT% -XX:-UseLargePages -XX:-UseBiasedLocking"
 set "JAVA_OPT=%JAVA_OPT% -Djava.ext.dirs=%BASE_DIR%lib"
 set "JAVA_OPT=%JAVA_OPT% -cp %CLASSPATH%"
+goto end
+:java9+
+set "JAVA_OPT=%JAVA_OPT% --add-exports java.base/jdk.internal.ref=ALL-UNNAMED -server -Xms8g
-Xmx8g -Xmn4g"
+set "JAVA_OPT=%JAVA_OPT% -XX:+UseG1GC -XX:G1HeapRegionSize=16m -XX:G1ReservePercent=25 -XX:InitiatingHeapOccupancyPercent=30
-XX:SoftRefLRUPolicyMSPerMB=0"
+set "JAVA_OPT=%JAVA_OPT% -Xlog:gc*=info,safepoint=debug:file=%USERPROFILE%\mq_gc.log:utctime,level,tags:filecount=5,filesize=30M"
+set "JAVA_OPT=%JAVA_OPT% -XX:-OmitStackTraceInFastThrow"
+set "JAVA_OPT=%JAVA_OPT% -XX:+AlwaysPreTouch"
+set "JAVA_OPT=%JAVA_OPT% -XX:MaxDirectMemorySize=15g"
+set "JAVA_OPT=%JAVA_OPT% -XX:-UseLargePages -XX:-UseBiasedLocking"
+set "JAVA_OPT=%JAVA_OPT% --class-path="%CLASSPATH%";"%BASE_DIR%lib\*""
+:end
 
 "%JAVA%" %JAVA_OPT% %*
\ No newline at end of file
diff --git a/distribution/bin/runbroker.sh b/distribution/bin/runbroker.sh
index 1d1000e..fa5b841 100644
--- a/distribution/bin/runbroker.sh
+++ b/distribution/bin/runbroker.sh
@@ -64,18 +64,37 @@ choose_gc_log_directory()
 
 choose_gc_log_directory
 
-JAVA_OPT="${JAVA_OPT} -server -Xms8g -Xmx8g -Xmn4g"
-JAVA_OPT="${JAVA_OPT} -XX:+UseG1GC -XX:G1HeapRegionSize=16m -XX:G1ReservePercent=25 -XX:InitiatingHeapOccupancyPercent=30
-XX:SoftRefLRUPolicyMSPerMB=0"
-JAVA_OPT="${JAVA_OPT} -verbose:gc -Xloggc:${GC_LOG_DIR}/rmq_broker_gc_%p_%t.log -XX:+PrintGCDetails
-XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintAdaptiveSizePolicy"
-JAVA_OPT="${JAVA_OPT} -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m"
-JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow"
-JAVA_OPT="${JAVA_OPT} -XX:+AlwaysPreTouch"
-JAVA_OPT="${JAVA_OPT} -XX:MaxDirectMemorySize=15g"
-JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages -XX:-UseBiasedLocking"
-JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${BASE_DIR}/lib:${JAVA_HOME}/lib/ext"
-#JAVA_OPT="${JAVA_OPT} -Xdebug -Xrunjdwp:transport=dt_socket,address=9555,server=y,suspend=n"
-JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}"
-JAVA_OPT="${JAVA_OPT} -cp ${CLASSPATH}"
+version=$($JAVA -version 2>&1 | awk -F '"' '/version/ {print $2}')
+version=${version%.*.*}
+if [[ "$version" -ge 9 ]]; then
+        JAVA_OPT="${JAVA_OPT} --add-exports java.base/jdk.internal.ref=ALL-UNNAMED -server
-Xms8g -Xmx8g -Xmn4g"
+        JAVA_OPT="${JAVA_OPT} -XX:+UseG1GC -XX:G1HeapRegionSize=16m -XX:G1ReservePercent=25
-XX:InitiatingHeapOccupancyPercent=30 -XX:SoftRefLRUPolicyMSPerMB=0"
+        JAVA_OPT="${JAVA_OPT} -Xlog:gc*=info,safepoint=debug:file=${GC_LOG_DIR}/rmq_broker_gc_%p_%t.log:utctime,level,tags:filecount=5,filesize=30M"
+        JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow"
+        JAVA_OPT="${JAVA_OPT} -XX:+AlwaysPreTouch"
+        JAVA_OPT="${JAVA_OPT} -XX:MaxDirectMemorySize=15g"
+        JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages -XX:-UseBiasedLocking"
+        JAVA_OPT="${JAVA_OPT} --class-path=${JAVA_HOME}/jre/lib/ext/*:${BASE_DIR}/lib/*:${CLASSPATH}:${JAVA_HOME}/lib/ext"
+        #JAVA_OPT="${JAVA_OPT} -Xdebug -Xrunjdwp:transport=dt_socket,address=9555,server=y,suspend=n"
+        JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}"
+else
+        JAVA_OPT="${JAVA_OPT} -server -Xms8g -Xmx8g -Xmn4g"
+        JAVA_OPT="${JAVA_OPT} -XX:+UseG1GC -XX:G1HeapRegionSize=16m -XX:G1ReservePercent=25
-XX:InitiatingHeapOccupancyPercent=30 -XX:SoftRefLRUPolicyMSPerMB=0"
+        JAVA_OPT="${JAVA_OPT} -verbose:gc -Xloggc:${GC_LOG_DIR}/rmq_broker_gc_%p_%t.log -XX:+PrintGCDetails
-XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintAdaptiveSizePolicy"
+        JAVA_OPT="${JAVA_OPT} -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m"
+        JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow"
+        JAVA_OPT="${JAVA_OPT} -XX:+AlwaysPreTouch"
+        JAVA_OPT="${JAVA_OPT} -XX:MaxDirectMemorySize=15g"
+        JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages -XX:-UseBiasedLocking"
+        JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${BASE_DIR}/lib:${JAVA_HOME}/lib/ext"
+        #JAVA_OPT="${JAVA_OPT} -Xdebug -Xrunjdwp:transport=dt_socket,address=9555,server=y,suspend=n"
+        JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}"
+        JAVA_OPT="${JAVA_OPT} -cp ${CLASSPATH}"
+fi
+
+
+
+
 
 numactl --interleave=all pwd > /dev/null 2>&1
 if [ $? -eq 0 ]
diff --git a/distribution/bin/runserver.cmd b/distribution/bin/runserver.cmd
index 48e32bf..4abcbeb 100644
--- a/distribution/bin/runserver.cmd
+++ b/distribution/bin/runserver.cmd
@@ -26,6 +26,11 @@ for %%d in (%BASE_DIR%) do set BASE_DIR=%%~dpd
 
 set CLASSPATH=.;%BASE_DIR%conf;%CLASSPATH%
 
+for /f tokens^=2-5^ delims^=.-_^" %%j in ('java -fullversion 2^>^&1') do @set "JAVA_VERSION=%%j"
+if %JAVA_VERSION% EQU 1 goto java8-
+goto java9+
+
+:java8-
 set "JAVA_OPT=%JAVA_OPT% -server -Xms2g -Xmx2g -Xmn1g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
 set "JAVA_OPT=%JAVA_OPT% -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70
-XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled
-XX:SurvivorRatio=8 -XX:-UseParNewGC"
 set "JAVA_OPT=%JAVA_OPT% -verbose:gc -Xloggc:"%USERPROFILE%\rmq_srv_gc.log" -XX:+PrintGCDetails"
@@ -33,5 +38,13 @@ set "JAVA_OPT=%JAVA_OPT% -XX:-OmitStackTraceInFastThrow"
 set "JAVA_OPT=%JAVA_OPT% -XX:-UseLargePages"
 set "JAVA_OPT=%JAVA_OPT% -Djava.ext.dirs=%BASE_DIR%lib"
 set "JAVA_OPT=%JAVA_OPT% -cp "%CLASSPATH%""
+goto end
+:java9+
+set "JAVA_OPT=%JAVA_OPT% --add-exports java.base/jdk.internal.ref=ALL-UNNAMED -server -Xms2g
-Xmx2g -Xmn1g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
+set "JAVA_OPT=%JAVA_OPT% -Xlog:gc*=info,safepoint=debug:file=%USERPROFILE%\rmq_srv_gc.log:utctime,level,tags:filecount=5,filesize=30M"
+set "JAVA_OPT=%JAVA_OPT% -XX:-OmitStackTraceInFastThrow"
+set "JAVA_OPT=%JAVA_OPT% -XX:-UseLargePages"
+set "JAVA_OPT=%JAVA_OPT% --class-path="%CLASSPATH%";"%BASE_DIR%lib\*""
+:end
 
 "%JAVA%" %JAVA_OPT% %*
\ No newline at end of file
diff --git a/distribution/bin/runserver.sh b/distribution/bin/runserver.sh
index 68fd1b4..07fe635 100644
--- a/distribution/bin/runserver.sh
+++ b/distribution/bin/runserver.sh
@@ -62,30 +62,30 @@ choose_gc_log_directory()
     esac
 }
 
-choose_gc_options()
-{
-    # Example of JAVA_MAJOR_VERSION value : '1', '9', '10', '11', ...
-    # '1' means releases befor Java 9
-    JAVA_MAJOR_VERSION=$("$JAVA" -version 2>&1 | sed -E -n 's/.* version "([0-9]*).*$/\1/p')
-    if [[ "$JAVA_MAJOR_VERSION" -lt "9" ]] ; then
-      JAVA_OPT="${JAVA_OPT} -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70
-XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled
-XX:SurvivorRatio=8 -XX:-UseParNewGC"
-      JAVA_OPT="${JAVA_OPT} -verbose:gc -Xloggc:${GC_LOG_DIR}/rmq_srv_gc_%p_%t.log -XX:+PrintGCDetails"
-      JAVA_OPT="${JAVA_OPT} -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m"
-    else
-      JAVA_OPT="${JAVA_OPT} -XX:+UseG1GC -XX:G1HeapRegionSize=16m -XX:G1ReservePercent=25
-XX:InitiatingHeapOccupancyPercent=30 -XX:SoftRefLRUPolicyMSPerMB=0"
-      JAVA_OPT="${JAVA_OPT} -Xlog:gc*:file=${GC_LOG_DIR}/rmq_srv_gc_%p_%t.log:time,tags:filecount=5,filesize=30M"
-    fi
-}
+version=$($JAVA -version 2>&1 | awk -F '"' '/version/ {print $2}')
+version=${version%.*.*}
+if [[ "$version" -ge 9 ]]; then
+        JAVA_OPT="${JAVA_OPT} -server -Xms4g -Xmx4g -Xmn2g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
+        JAVA_OPT="${JAVA_OPT} -XX:SurvivorRatio=8"
+        JAVA_OPT="${JAVA_OPT} -Xlog:gc*=info,safepoint=debug:file=${GC_LOG_DIR}/rmq_srv_gc_%p_%t.log:utctime,level,tags:filecount=5,filesize=30M"
+        JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow"
+        JAVA_OPT="${JAVA_OPT}  -XX:-UseLargePages"
+        JAVA_OPT="${JAVA_OPT} --class-path=${JAVA_HOME}/jre/lib/ext/*:${BASE_DIR}/lib/*:${CLASSPATH}"
+        #JAVA_OPT="${JAVA_OPT} -Xdebug -Xrunjdwp:transport=dt_socket,address=9555,server=y,suspend=n"
+        JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}"
+else
+        JAVA_OPT="${JAVA_OPT} -server -Xms4g -Xmx4g -Xmn2g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
+        JAVA_OPT="${JAVA_OPT} -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection
-XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0
-XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8  -XX:-UseParNewGC"
+        JAVA_OPT="${JAVA_OPT} -verbose:gc -Xloggc:${GC_LOG_DIR}/rmq_srv_gc_%p_%t.log -XX:+PrintGCDetails"
+        JAVA_OPT="${JAVA_OPT} -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m"
+        JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow"
+        JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages"
+        JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${BASE_DIR}/lib"
+        #JAVA_OPT="${JAVA_OPT} -Xdebug -Xrunjdwp:transport=dt_socket,address=9555,server=y,suspend=n"
+        JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}"
+        JAVA_OPT="${JAVA_OPT} -cp ${CLASSPATH}"
+fi
 
-choose_gc_log_directory
 
-JAVA_OPT="${JAVA_OPT} -server -Xms4g -Xmx4g -Xmn2g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
-choose_gc_options
-JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow"
-JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages"
-JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${BASE_DIR}/lib:${JAVA_HOME}/lib/ext"
-#JAVA_OPT="${JAVA_OPT} -Xdebug -Xrunjdwp:transport=dt_socket,address=9555,server=y,suspend=n"
-JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}"
-JAVA_OPT="${JAVA_OPT} -cp ${CLASSPATH}"
 
 $JAVA ${JAVA_OPT} $@
diff --git a/distribution/bin/tools.cmd b/distribution/bin/tools.cmd
index c61fbcf..c0b601b 100644
--- a/distribution/bin/tools.cmd
+++ b/distribution/bin/tools.cmd
@@ -25,11 +25,22 @@ for %%d in (%BASE_DIR%) do set BASE_DIR=%%~dpd
 
 set CLASSPATH=.;%BASE_DIR%conf;%CLASSPATH%
 
+for /f tokens^=2-5^ delims^=.-_^" %%j in ('java -fullversion 2^>^&1') do @set "JAVA_VERSION=%%j"
+if %JAVA_VERSION% EQU 1 goto java8-
+goto java9+
+
 rem ===========================================================================================
 rem JVM Configuration
 rem ===========================================================================================
+
+:java8-
 set "JAVA_OPT=%JAVA_OPT% -server -Xms1g -Xmx1g -Xmn256m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m"
 set "JAVA_OPT=%JAVA_OPT% -Djava.ext.dirs="%BASE_DIR%\lib";"%JAVA_HOME%\jre\lib\ext";"%JAVA_HOME%\lib\ext""
 set "JAVA_OPT=%JAVA_OPT% -cp "%CLASSPATH%""
+goto end
+:java9+
+set "JAVA_OPT=%JAVA_OPT% --add-exports java.base/jdk.internal.ref=ALL-UNNAMED -server -Xms1g
-Xmx1g -Xmn256m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m"
+set "JAVA_OPT=%JAVA_OPT% --class-path="%CLASSPATH%";"%BASE_DIR%\lib\*";"%JAVA_HOME%\jre\lib\ext";"%JAVA_HOME%\lib\ext""
+:end
 
-"%JAVA%" %JAVA_OPT% %*
+"%JAVA%" %JAVA_OPT% -version
diff --git a/distribution/bin/tools.sh b/distribution/bin/tools.sh
index a13dc7e..cfe0eb3 100644
--- a/distribution/bin/tools.sh
+++ b/distribution/bin/tools.sh
@@ -36,8 +36,17 @@ export CLASSPATH=.:${BASE_DIR}/conf:${CLASSPATH}
 #===========================================================================================
 # JVM Configuration
 #===========================================================================================
-JAVA_OPT="${JAVA_OPT} -server -Xms1g -Xmx1g -Xmn256m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m"
-JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${BASE_DIR}/lib:${JAVA_HOME}/jre/lib/ext:${JAVA_HOME}/lib/ext"
-JAVA_OPT="${JAVA_OPT} -cp ${CLASSPATH}"
+
+version=$($JAVA -version 2>&1 | awk -F '"' '/version/ {print $2}')
+version=${version%.*.*}
+
+if [[ "$version" -ge 9 ]]; then
+        JAVA_OPT="${JAVA_OPT} -server -Xms1g -Xmx1g -Xmn256m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m"
+        JAVA_OPT="${JAVA_OPT} --class-path=${JAVA_HOME}/jre/lib/ext/*:${BASE_DIR}/lib/*:${CLASSPATH}"
+else
+        JAVA_OPT="${JAVA_OPT} -server -Xms1g -Xmx1g -Xmn256m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m"
+        JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${BASE_DIR}/lib:${JAVA_HOME}/jre/lib/ext:${JAVA_HOME}/lib/ext"
+        JAVA_OPT="${JAVA_OPT} -cp ${CLASSPATH}"
+fi
 
 $JAVA ${JAVA_OPT} "$@"


Mime
View raw message