You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by si...@apache.org on 2019/07/29 11:49:06 UTC

[bookkeeper] branch master updated: Make default Bookie scripts work on JDK11+

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

sijie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git


The following commit(s) were added to refs/heads/master by this push:
     new 1ff4438  Make default Bookie scripts work on JDK11+
1ff4438 is described below

commit 1ff4438858df888141a31e4049ba8ad845c9cc10
Author: Enrico Olivelli <eo...@gmail.com>
AuthorDate: Mon Jul 29 13:49:00 2019 +0200

    Make default Bookie scripts work on JDK11+
    
    - detect new Java versions in bin/common.sh
    - use different defaults on JDK8 vs JDK11+
    
    Descriptions of the changes in this PR:
    Change distribution scripts in order to detect a JDK newer then JDK8 and set default JVM options accordingly.
    
    ### Motivation
    
    Because I want that BookKeeper tools run out of the box with JDK11
    
    ### Changes
    1) detect a JDK newer then JDK8, but checking if exists $JAVA_HOME/bin/jshell (this is quite robust, better then parsing some Java version string)
    2) use new defaults for JDK11, in particular do not enable experimental and deprecated options, use the new [Java Unified Logging](https://openjdk.java.net/jeps/158) log system for GC
    
    Please note the output of "Java Unified Logging" is very different from the old pre-Java9 one and
    options are different, there is no simple port.
    
    Master Issue: #1912
    
    
    
    
    Reviewers: Sijie Guo <None>
    
    This closes #2132 from eolivelli/fix/run-jdk11
---
 bin/common.sh | 50 +++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 41 insertions(+), 9 deletions(-)

diff --git a/bin/common.sh b/bin/common.sh
index f92c0b9..d3b16d8 100755
--- a/bin/common.sh
+++ b/bin/common.sh
@@ -1,5 +1,4 @@
 #!/usr/bin/env bash
-#
 #/**
 # * Licensed to the Apache Software Foundation (ASF) under one
 # * or more contributor license agreements.  See the NOTICE file
@@ -71,13 +70,31 @@ source ${BK_CONFDIR}/nettyenv.sh
 source ${BK_CONFDIR}/bkenv.sh
 source ${BK_CONFDIR}/bk_cli_env.sh
 
+detect_jdk8() {
+
+  if [ -f "$JAVA_HOME/bin/jshell" ]; then
+     echo "0"
+  else
+     echo "1"
+  fi
+  return
+}
+
 # default netty settings
 NETTY_LEAK_DETECTION_LEVEL=${NETTY_LEAK_DETECTION_LEVEL:-"disabled"}
 NETTY_RECYCLER_MAXCAPACITY=${NETTY_RECYCLER_MAXCAPACITY:-"1000"}
 NETTY_RECYCLER_LINKCAPACITY=${NETTY_RECYCLER_LINKCAPACITY:-"1024"}
 
-# default bookie JVM settings
-DEFAULT_BOOKIE_GC_OPTS="-XX:+UseG1GC \
+USING_JDK8=$(detect_jdk8)
+
+if [ "$USING_JDK8" -ne "1" ]; then
+   DEFAULT_BOOKIE_GC_OPTS="-XX:+UseG1GC \
+    -XX:MaxGCPauseMillis=10 \
+    -XX:+ParallelRefProcEnabled \
+    -XX:+DisableExplicitGC"
+   DEFAULT_BOOKIE_GC_LOGGING_OPTS=""
+else
+  DEFAULT_BOOKIE_GC_OPTS="-XX:+UseG1GC \
     -XX:MaxGCPauseMillis=10 \
     -XX:+ParallelRefProcEnabled \
     -XX:+UnlockExperimentalVMOptions \
@@ -88,11 +105,13 @@ DEFAULT_BOOKIE_GC_OPTS="-XX:+UseG1GC \
     -XX:G1NewSizePercent=50 \
     -XX:+DisableExplicitGC \
     -XX:-ResizePLAB"
-DEFAULT_BOOKIE_GC_LOGGING_OPTS="-XX:+PrintGCDetails \
+  DEFAULT_BOOKIE_GC_LOGGING_OPTS="-XX:+PrintGCDetails \
     -XX:+PrintGCApplicationStoppedTime  \
     -XX:+UseGCLogFileRotation \
     -XX:NumberOfGCLogFiles=5 \
     -XX:GCLogFileSize=64m"
+fi
+
 BOOKIE_MAX_HEAP_MEMORY=${BOOKIE_MAX_HEAP_MEMORY:-"1g"}
 BOOKIE_MIN_HEAP_MEMORY=${BOOKIE_MIN_HEAP_MEMORY:-"1g"}
 BOOKIE_MAX_DIRECT_MEMORY=${BOOKIE_MAX_DIRECT_MEMORY:-"2g"}
@@ -103,11 +122,16 @@ BOOKIE_GC_LOGGING_OPTS=${BOOKIE_GC_LOGGING_OPTS:-"${DEFAULT_BOOKIE_GC_LOGGING_OP
 # default CLI JVM settings
 DEFAULT_CLI_GC_OPTS="-XX:+UseG1GC \
     -XX:MaxGCPauseMillis=10"
-DEFAULT_CLI_GC_LOGGING_OPTS="-XX:+PrintGCDetails \
+if [ "$USING_JDK8" -ne "1" ]; then
+  DEFAULT_CLI_GC_LOGGING_OPTS="-XX:+PrintGCDetails \
     -XX:+PrintGCApplicationStoppedTime  \
     -XX:+UseGCLogFileRotation \
     -XX:NumberOfGCLogFiles=5 \
     -XX:GCLogFileSize=64m"
+else
+  DEFAULT_CLI_GC_LOGGING_OPTS=""
+fi
+
 CLI_MAX_HEAP_MEMORY=${CLI_MAX_HEAP_MEMORY:-"512M"}
 CLI_MIN_HEAP_MEMORY=${CLI_MIN_HEAP_MEMORY:-"256M"}
 CLI_MEM_OPTS=${CLI_MEM_OPTS:-"-Xms${CLI_MIN_HEAP_MEMORY} -Xmx${CLI_MAX_HEAP_MEMORY}"}
@@ -241,15 +265,23 @@ set_module_classpath() {
 build_bookie_jvm_opts() {
   LOG_DIR=$1
   GC_LOG_FILENAME=$2
-
-  echo "$BOOKIE_MEM_OPTS $BOOKIE_GC_OPTS $BOOKIE_GC_LOGGING_OPTS $BOOKIE_PERF_OPTS -Xloggc:${LOG_DIR}/${GC_LOG_FILENAME}"
+  if [ "$USING_JDK8" -eq "1" ]; then
+    echo "$BOOKIE_MEM_OPTS $BOOKIE_GC_OPTS $BOOKIE_GC_LOGGING_OPTS $BOOKIE_PERF_OPTS -Xloggc:${LOG_DIR}/${GC_LOG_FILENAME}"
+  else
+    echo "$BOOKIE_MEM_OPTS $BOOKIE_GC_OPTS $BOOKIE_GC_LOGGING_OPTS $BOOKIE_PERF_OPTS -Xlog:gc=info:file=${LOG_DIR}/${GC_LOG_FILENAME}::filecount=5,filesize=64m"
+  fi
+  return
 }
 
 build_cli_jvm_opts() {
   LOG_DIR=$1
   GC_LOG_FILENAME=$2
-
-  echo "$CLI_MEM_OPTS $CLI_GC_OPTS $CLI_GC_LOGGING_OPTS -Xloggc:${LOG_DIR}/${GC_LOG_FILENAME}"
+  if [ "$USING_JDK8" -eq "1" ]; then
+    echo "$CLI_MEM_OPTS $CLI_GC_OPTS $CLI_GC_LOGGING_OPTS -Xloggc:${LOG_DIR}/${GC_LOG_FILENAME}"
+  else
+    echo "$CLI_MEM_OPTS $CLI_GC_OPTS $CLI_GC_LOGGING_OPTS -Xlog:gc=info:file=${LOG_DIR}/${GC_LOG_FILENAME}::filecount=5,filesize=64m"
+  fi
+  return
 }
 
 build_netty_opts() {