storm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From etha...@apache.org
Subject [1/2] storm git commit: [STORM-3265] flight.bash fall back to use java utils directly if $JAVA_HOME not set or java not avaialble in $BINPATH
Date Fri, 02 Nov 2018 15:54:58 GMT
Repository: storm
Updated Branches:
  refs/heads/master dcf637ff6 -> 00cd3d323


[STORM-3265] flight.bash fall back to use java utils directly if $JAVA_HOME not set or java
not avaialble in $BINPATH


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

Branch: refs/heads/master
Commit: c1801ecf36afbe9abd193fd1ea9d6ab9d95d30ed
Parents: dcf637f
Author: Ethan Li <ethanopensource@gmail.com>
Authored: Thu Nov 1 08:56:57 2018 -0500
Committer: Ethan Li <ethanopensource@gmail.com>
Committed: Fri Nov 2 10:50:21 2018 -0500

----------------------------------------------------------------------
 bin/flight.bash | 31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/c1801ecf/bin/flight.bash
----------------------------------------------------------------------
diff --git a/bin/flight.bash b/bin/flight.bash
index 99c5bd1..da15419 100755
--- a/bin/flight.bash
+++ b/bin/flight.bash
@@ -16,7 +16,7 @@
 # limitations under the License.
 
 JDKPATH=$JAVA_HOME
-BINPATH="/usr/bin"
+BINPATH="/usr/bin/"
 USER=`whoami`
 
 #SETTINGS=/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre/lib/jfr/profile.jfc
@@ -34,12 +34,21 @@ fi
 
 if [[ $platform == 'linux' ]]; then
     if [ -z "$JDKPATH" ]; then
-        BINPATH="/usr/bin"
+        BINPATH="/usr/bin/"
     else
-        BINPATH="$JDKPATH/bin"
+        BINPATH="$JDKPATH/bin/"
     fi
 elif [[ $platform == 'darwin' ]]; then
-    BINPATH="/usr/bin"
+    BINPATH="/usr/bin/"
+fi
+
+#check if java is available at $BINPATH; if not, fall back to use java commands directly.
+JAVAPATH="${BINPATH}java"
+if [ -f "$JAVAPATH" ]; then
+	echo "$JAVAPATH found. Will use java utils from $BINPATH"
+else
+	echo "$JAVAPATH or JAVA_HOME not found. Will use java utils directly";
+	BINPATH=""
 fi
 
 function start_record {
@@ -50,38 +59,38 @@ function start_record {
         break;
     done
     if [ "$already_recording" = false ]; then
-        $BINPATH/jcmd $1 JFR.start settings=${SETTINGS}
+        ${BINPATH}jcmd $1 JFR.start settings=${SETTINGS}
     fi
 }
 
 function dump_record {
     for rid in `get_recording_ids $1`; do
         FILENAME=recording-$1-${rid}-${NOW}.jfr
-        $BINPATH/jcmd $1 JFR.dump recording=$rid filename="$2/${FILENAME}"
+        ${BINPATH}jcmd $1 JFR.dump recording=$rid filename="$2/${FILENAME}"
     done
 }
 
 function jstack_record {
     FILENAME=jstack-$1-${NOW}.txt
-    $BINPATH/jstack $1 > "$2/${FILENAME}" 2>&1
+    ${BINPATH}jstack $1 > "$2/${FILENAME}" 2>&1
 }
 
 function jmap_record {
     FILENAME=recording-$1-${NOW}.bin
-    $BINPATH/jmap -dump:format=b,file="$2/${FILENAME}" $1
+    ${BINPATH}jmap -dump:format=b,file="$2/${FILENAME}" $1
     /bin/chmod g+r "$2/${FILENAME}"
 }
 
 function stop_record {
     for rid in `get_recording_ids $1`; do
         FILENAME=recording-$1-${rid}-${NOW}.jfr
-        $BINPATH/jcmd $1 JFR.dump recording=$rid filename="$2/${FILENAME}"
-        $BINPATH/jcmd $1 JFR.stop recording=$rid
+        ${BINPATH}jcmd $1 JFR.dump recording=$rid filename="$2/${FILENAME}"
+        ${BINPATH}jcmd $1 JFR.stop recording=$rid
     done
 }
 
 function get_recording_ids {
-    $BINPATH/jcmd $1 JFR.check | perl -n -e '/recording=([0-9]+)/ && print "$1 "'
+    ${BINPATH}jcmd $1 JFR.check | perl -n -e '/recording=([0-9]+)/ && print "$1 "'
 }
 
 function usage_and_quit {


Mime
View raw message