Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improve] jvm opt improvement #4010

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,3 @@
-XX:+UseGCLogFileRotation
-XX:GCLogFileSize=50M
-XX:NumberOfGCLogFiles=10

# solved jdk1.8+ dynamic loading of resources to the classpath issue, if jdk > 1.8, you can enable this parameter
#--add-opens java.base/jdk.internal.loader=ALL-UNNAMED --add-opens jdk.zipfs/jdk.nio.zipfs=ALL-UNNAMED

Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,17 @@ if ${cygwin}; then
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
fi

# get jdk version, return version as an Integer.
JDK_VERSION=$("$_RUNJAVA" -version 2>&1 | grep -i 'version' | head -n 1 | cut -d '"' -f 2)
MAJOR_VER=$(echo "$JDK_VERSION" 2>&1 | cut -d '.' -f 1)
[[ $MAJOR_VER -eq 1 ]] && MAJOR_VER=$(echo "$JDK_VERSION" 2>&1 | cut -d '.' -f 2)
MIN_VERSION=8

if [[ $MAJOR_VER -lt $MIN_VERSION ]]; then
echo "JDK Version: \"${JDK_VERSION}\", the version cannot be lower than 1.8"
exit 1
fi

if [[ -z "$USE_NOHUP" ]]; then
if $hpux; then
USE_NOHUP="true"
Expand Down Expand Up @@ -257,7 +268,6 @@ fi

BASH_UTIL="org.apache.streampark.console.base.util.BashJavaUtils"
APP_MAIN="org.apache.streampark.console.StreamParkConsoleBootstrap"
SERVER_PORT=$($_RUNJAVA -cp "$APP_LIB/*" $BASH_UTIL --get_yaml "server.port" "$CONFIG")
JVM_OPTS_FILE=${APP_HOME}/bin/jvm_opts.sh

JVM_ARGS=""
Expand All @@ -270,11 +280,12 @@ if [[ -f $JVM_OPTS_FILE ]]; then
done < $JVM_OPTS_FILE
fi

JVM_OPTS=${JVM_OPTS:-"${JVM_ARGS}"}
JVM_OPTS="$JVM_OPTS -XX:HeapDumpPath=${APP_HOME}/logs/dump.hprof"
JVM_OPTS="$JVM_OPTS -Xloggc:${APP_HOME}/logs/gc.log"
DEBUG_OPTS=""
JAVA_OPTS=${JAVA_OPTS:-"${JVM_ARGS}"}
JAVA_OPTS="$JAVA_OPTS -XX:HeapDumpPath=${APP_HOME}/logs/dump.hprof"
JAVA_OPTS="$JAVA_OPTS -Xloggc:${APP_HOME}/logs/gc.log"
[[ $MAJOR_VER -gt $MIN_VERSION ]] && JAVA_OPTS="$JAVA_OPTS --add-opens java.base/jdk.internal.loader=ALL-UNNAMED --add-opens jdk.zipfs/jdk.nio.zipfs=ALL-UNNAMED"

SERVER_PORT=$($_RUNJAVA -cp "$APP_LIB/*" $BASH_UTIL --get_yaml "server.port" "$CONFIG")
# ----- Execute The Requested Command -----------------------------------------

print_logo() {
Expand Down Expand Up @@ -399,11 +410,6 @@ start() {
APP_CLASSPATH+=":${HADOOP_HOME}/etc/hadoop"
fi

# shellcheck disable=SC2034
# shellcheck disable=SC2006
# shellcheck disable=SC2155
local JAVA_OPTS="$JVM_OPTS $DEBUG_OPTS"

echo_g "JAVA_OPTS: ${JAVA_OPTS}"

eval $NOHUP $_RUNJAVA $JAVA_OPTS \
Expand Down Expand Up @@ -468,9 +474,7 @@ start_docker() {
APP_CLASSPATH+=":${HADOOP_HOME}/etc/hadoop"
fi

JVM_OPTS="${JVM_OPTS} -XX:-UseContainerSupport"

local JAVA_OPTS="$JVM_OPTS $DEBUG_OPTS"
JAVA_OPTS="$JAVA_OPTS -XX:-UseContainerSupport"

echo_g "JAVA_OPTS: ${JAVA_OPTS}"

Expand All @@ -483,18 +487,6 @@ start_docker() {

}

debug() {
# shellcheck disable=SC2236
if [[ ! -n "$DEBUG_PORT" ]]; then
echo_r "If start with debug mode,Please fill in the debug port like: bash streampark.sh debug 10002 "
else
DEBUG_OPTS="""
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$DEBUG_PORT
"""
start
fi
}

# shellcheck disable=SC2120
stop() {
# shellcheck disable=SC2155
Expand Down Expand Up @@ -566,10 +558,6 @@ restart() {

main() {
case "$1" in
"debug")
DEBUG_PORT=$2
debug
;;
"start")
shift
start "$@"
Expand Down Expand Up @@ -599,7 +587,6 @@ main() {
echo_w " stop Stop StreamPark, wait up to 3 seconds and then use kill -KILL if still running"
echo_w " start_docker start in docker or k8s mode"
echo_w " status StreamPark status"
echo_w " debug StreamPark start with debug mode,start debug mode, like: bash streampark.sh debug 10002"
echo_w " restart \$conf restart StreamPark with application config."
exit 0
;;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public void run(ApplicationArguments args) {
System.out.println(" WebSite: https://streampark.apache.org ");
System.out.println(" GitHub : https://github.com/apache/incubator-streampark ");
System.out.println(" Info : streampark-console start successful ");
System.out.println(" JDK : " + System.getProperty("java.version"));
System.out.println(" Local : http://localhost:" + port);
System.out.println(" Time : " + LocalDateTime.now() + "\n\n");
System.setProperty("streampark.start.timestamp", System.currentTimeMillis() + "");
Expand Down
Loading