This is an automated email from the ASF dual-hosted git repository. yuzhou pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/rocketmq.git
The following commit(s) were added to refs/heads/develop by this push: new 1242a5873d [ISSUE #7495] Support Higher Java version in Windows (#7507) 1242a5873d is described below commit 1242a5873df2b20e914ad13e1d46df500df932b9 Author: Ao Qiao <qiao...@foxmail.com> AuthorDate: Mon Jan 15 17:49:40 2024 +0800 [ISSUE #7495] Support Higher Java version in Windows (#7507) * fix 7495 --- distribution/bin/runbroker.cmd | 37 ++++++++++++++++++++++++++++--------- distribution/bin/runserver.cmd | 32 ++++++++++++++++++++++++++------ distribution/bin/runserver.sh | 2 +- 3 files changed, 55 insertions(+), 16 deletions(-) diff --git a/distribution/bin/runbroker.cmd b/distribution/bin/runbroker.cmd index 77a0d1ff8e..0ea87f876d 100644 --- a/distribution/bin/runbroker.cmd +++ b/distribution/bin/runbroker.cmd @@ -28,14 +28,33 @@ set CLASSPATH=.;%BASE_DIR%conf;%BASE_DIR%lib\*;%CLASSPATH% rem =========================================================================================== rem JVM Configuration rem =========================================================================================== -set "JAVA_OPT=%JAVA_OPT% -server -Xms2g -Xmx2g" -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" -set "JAVA_OPT=%JAVA_OPT% -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=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% %JAVA_OPT_EXT% -cp %CLASSPATH%" +for /f "tokens=2 delims=" %%v in ('java -version 2^>^&1 ^| findstr /i "version"') do ( + for /f "tokens=1 delims=." %%m in ("%%v") do set "JAVA_MAJOR_VERSION=%%m" +) + +if "%JAVA_MAJOR_VERSION%"=="" ( + set "JAVA_MAJOR_VERSION=0" +) +if %JAVA_MAJOR_VERSION% lss 17 ( + set "JAVA_OPT=%JAVA_OPT% -server -Xms2g -Xmx2g" + 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" + set "JAVA_OPT=%JAVA_OPT% -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=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% %JAVA_OPT_EXT% -cp %CLASSPATH%" +) else ( + set "JAVA_OPT=%JAVA_OPT% -server -Xms2g -Xmx2g" + set "JAVA_OPT=%JAVA_OPT% -XX:+UseG1GC -XX:G1HeapRegionSize=16m -XX:G1ReservePercent=25 -XX:InitiatingHeapOccupancyPercent=30 -XX:SoftRefLRUPolicyMSPerMB=0 -XX:SurvivorRatio=8" + rem set "JAVA_OPT=%JAVA_OPT% -verbose:gc -Xloggc:%USERPROFILE%\mq_gc.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintAdaptiveSizePolicy" + rem set "JAVA_OPT=%JAVA_OPT% -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=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% %JAVA_OPT_EXT% -cp "%CLASSPATH%"" +) "%JAVA%" %JAVA_OPT% %* \ No newline at end of file diff --git a/distribution/bin/runserver.cmd b/distribution/bin/runserver.cmd index dc2e2b4e22..103a5a6e98 100644 --- a/distribution/bin/runserver.cmd +++ b/distribution/bin/runserver.cmd @@ -26,11 +26,31 @@ for %%d in (%BASE_DIR%) do set BASE_DIR=%%~dpd set CLASSPATH=.;%BASE_DIR%conf;%BASE_DIR%lib\*;%CLASSPATH% -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 -XX:+PrintGCDateStamps" -set "JAVA_OPT=%JAVA_OPT% -XX:-OmitStackTraceInFastThrow" -set "JAVA_OPT=%JAVA_OPT% -XX:-UseLargePages" -set "JAVA_OPT=%JAVA_OPT% %JAVA_OPT_EXT% -cp "%CLASSPATH%"" +REM Example of JAVA_MAJOR_VERSION value: '1', '9', '10', '11', ... +REM '1' means releases before Java 9 + +for /f "tokens=2 delims=" %%v in ('java -version 2^>^&1 ^| findstr /i "version"') do ( + for /f "tokens=1 delims=." %%m in ("%%v") do set "JAVA_MAJOR_VERSION=%%m" +) + +if "%JAVA_MAJOR_VERSION%"=="" ( + set "JAVA_MAJOR_VERSION=0" +) + +if %JAVA_MAJOR_VERSION% lss 17 ( + 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 -XX:+PrintGCDateStamps" + set "JAVA_OPT=%JAVA_OPT% -XX:-OmitStackTraceInFastThrow" + set "JAVA_OPT=%JAVA_OPT% -XX:-UseLargePages" + set "JAVA_OPT=%JAVA_OPT% %JAVA_OPT_EXT% -cp "%CLASSPATH%"" +) else ( + set "JAVA_OPT=%JAVA_OPT% -server -Xms2g -Xmx2g -Xmn1g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m" + rem set "JAVA_OPT=%JAVA_OPT% -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 -XX:-UseParNewGC" + rem set "JAVA_OPT=%JAVA_OPT% -verbose:gc -Xloggc:"%USERPROFILE%\rmq_srv_gc.log" -XX:+PrintGCDetails -XX:+PrintGCDateStamps" + set "JAVA_OPT=%JAVA_OPT% -XX:-OmitStackTraceInFastThrow" + set "JAVA_OPT=%JAVA_OPT% -XX:-UseLargePages" + set "JAVA_OPT=%JAVA_OPT% %JAVA_OPT_EXT% -cp "%CLASSPATH%"" +) "%JAVA%" %JAVA_OPT% %* \ No newline at end of file diff --git a/distribution/bin/runserver.sh b/distribution/bin/runserver.sh index 76ac9374a0..2a5184d9f8 100644 --- a/distribution/bin/runserver.sh +++ b/distribution/bin/runserver.sh @@ -83,7 +83,7 @@ choose_gc_log_directory() choose_gc_options() { # Example of JAVA_MAJOR_VERSION value : '1', '9', '10', '11', ... - # '1' means releases befor Java 9 + # '1' means releases before Java 9 JAVA_MAJOR_VERSION=$("$JAVA" -version 2>&1 | awk -F '"' '/version/ {print $2}' | awk -F '.' '{print $1}') if [ -z "$JAVA_MAJOR_VERSION" ] || [ "$JAVA_MAJOR_VERSION" -lt "9" ] ; then JAVA_OPT="${JAVA_OPT} -server -Xms4g -Xmx4g -Xmn2g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"