You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tajo.apache.org by jh...@apache.org on 2016/04/22 06:54:15 UTC

tajo git commit: TAJO-2125: Detect default java binary, if JAVA_HOME is not set.

Repository: tajo
Updated Branches:
  refs/heads/master 96507607d -> dc96f7e27


TAJO-2125: Detect default java binary, if JAVA_HOME is not set.

Closes #1002


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

Branch: refs/heads/master
Commit: dc96f7e274b810a038f33613b07cd67467505672
Parents: 9650760
Author: Jinho Kim <jh...@apache.org>
Authored: Fri Apr 22 13:53:33 2016 +0900
Committer: Jinho Kim <jh...@apache.org>
Committed: Fri Apr 22 13:53:33 2016 +0900

----------------------------------------------------------------------
 CHANGES                     |  2 ++
 tajo-dist/src/main/bin/tajo | 33 ++++++++++++++++++++++++---------
 2 files changed, 26 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/dc96f7e2/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 244c261..829f9a3 100644
--- a/CHANGES
+++ b/CHANGES
@@ -10,6 +10,8 @@ Release 0.12.0 - unreleased
 
   IMPROVEMENT
 
+    TAJO-2125: Detect JAVA_HOME on OSX, if JAVA_HOME is not set. (jinho)
+
     TAJO-2108: Refactor Schema to be immutable. (hyunsik)
 
     TAJO-2112: Improve disk load, when queries run simultaneously. (jinho)

http://git-wip-us.apache.org/repos/asf/tajo/blob/dc96f7e2/tajo-dist/src/main/bin/tajo
----------------------------------------------------------------------
diff --git a/tajo-dist/src/main/bin/tajo b/tajo-dist/src/main/bin/tajo
index 007e960..8dffe9a 100755
--- a/tajo-dist/src/main/bin/tajo
+++ b/tajo-dist/src/main/bin/tajo
@@ -105,18 +105,33 @@ if [ "$COMMAND" == "datanode" ] && [ "$EUID" -eq 0 ] && [ -n "$TAJO_SECURE_DN_US
   starting_secure_dn="true"
 fi
 
-# some Java parameters
-if [ "$JAVA_HOME" != "" ]; then
-  #echo "run java in $JAVA_HOME"
-  JAVA_HOME=$JAVA_HOME
-fi
-  
-if [ "$JAVA_HOME" = "" ]; then
-  echo "Error: JAVA_HOME is not set."
-  exit 1
+
+# This is borrowed from hadoop-config.sh in hadoop
+# Newer versions of glibc use an arena memory allocator that causes virtual
+# memory usage to explode. This interacts badly with the many threads that
+# we use in Hadoop. Tune the variable down to prevent vmem explosion.
+export MALLOC_ARENA_MAX=${MALLOC_ARENA_MAX:-4}
+
+# Attempt to set JAVA_HOME if it is not set
+if [[ -z $JAVA_HOME ]]; then
+  # On OSX use java_home (or /Library for older versions)
+  if [ "Darwin" == "$(uname -s)" ]; then
+    if [ -x /usr/libexec/java_home ]; then
+      export JAVA_HOME=($(/usr/libexec/java_home))
+    else
+      export JAVA_HOME=(/Library/Java/Home)
+    fi
+  fi
+
+  # Bail if we did not detect it
+  if [[ -z $JAVA_HOME ]]; then
+    echo "Error: JAVA_HOME is not set and could not be found." 1>&2
+    exit 1
+  fi
 fi
 
 JAVA=$JAVA_HOME/bin/java
+
 JAVA_TAJO_MASTER_HEAP_MAX=-Xmx1000m 
 JAVA_WORKER_HEAP_MAX=-Xmx5000m
 JAVA_QUERYMASTER_HEAP_MAX=-Xmx1000m