aboutsummaryrefslogtreecommitdiff
path: root/sbin/spark-config.sh
diff options
context:
space:
mode:
authorjerryshao <sshao@hortonworks.com>2015-11-04 10:49:34 +0000
committerSean Owen <sowen@cloudera.com>2015-11-04 10:49:34 +0000
commit8aff36e91de0fee2f3f56c6d240bb203b5bb48ba (patch)
tree0afdded361cb75e7658053953abfdb484da78ced /sbin/spark-config.sh
parent2692bdb7dbf36d6247f595d5fd0cb9cda89e1fdd (diff)
downloadspark-8aff36e91de0fee2f3f56c6d240bb203b5bb48ba.tar.gz
spark-8aff36e91de0fee2f3f56c6d240bb203b5bb48ba.tar.bz2
spark-8aff36e91de0fee2f3f56c6d240bb203b5bb48ba.zip
[SPARK-2960][DEPLOY] Support executing Spark from symlinks (reopen)
This PR is based on the work of roji to support running Spark scripts from symlinks. Thanks for the great work roji . Would you mind taking a look at this PR, thanks a lot. For releases like HDP and others, normally it will expose the Spark executables as symlinks and put in `PATH`, but current Spark's scripts do not support finding real path from symlink recursively, this will make spark fail to execute from symlink. This PR try to solve this issue by finding the absolute path from symlink. Instead of using `readlink -f` like what this PR (https://github.com/apache/spark/pull/2386) implemented is that `-f` is not support for Mac, so here manually seeking the path through loop. I've tested with Mac and Linux (Cent OS), looks fine. This PR did not fix the scripts under `sbin` folder, not sure if it needs to be fixed also? Please help to review, any comment is greatly appreciated. Author: jerryshao <sshao@hortonworks.com> Author: Shay Rojansky <roji@roji.org> Closes #8669 from jerryshao/SPARK-2960.
Diffstat (limited to 'sbin/spark-config.sh')
-rwxr-xr-xsbin/spark-config.sh23
1 files changed, 7 insertions, 16 deletions
diff --git a/sbin/spark-config.sh b/sbin/spark-config.sh
index e6bf544c14..d8d9d00d64 100755
--- a/sbin/spark-config.sh
+++ b/sbin/spark-config.sh
@@ -19,21 +19,12 @@
# should not be executable directly
# also should not be passed any arguments, since we need original $*
-# resolve links - $0 may be a softlink
-this="${BASH_SOURCE:-$0}"
-common_bin="$(cd -P -- "$(dirname -- "$this")" && pwd -P)"
-script="$(basename -- "$this")"
-this="$common_bin/$script"
+# symlink and absolute path should rely on SPARK_HOME to resolve
+if [ -z "${SPARK_HOME}" ]; then
+ export SPARK_HOME="$(cd "`dirname "$0"`"/..; pwd)"
+fi
-# convert relative path to absolute path
-config_bin="`dirname "$this"`"
-script="`basename "$this"`"
-config_bin="`cd "$config_bin"; pwd`"
-this="$config_bin/$script"
-
-export SPARK_PREFIX="`dirname "$this"`"/..
-export SPARK_HOME="${SPARK_PREFIX}"
-export SPARK_CONF_DIR="${SPARK_CONF_DIR:-"$SPARK_HOME/conf"}"
+export SPARK_CONF_DIR="${SPARK_CONF_DIR:-"${SPARK_HOME}/conf"}"
# Add the PySpark classes to the PYTHONPATH:
-export PYTHONPATH="$SPARK_HOME/python:$PYTHONPATH"
-export PYTHONPATH="$SPARK_HOME/python/lib/py4j-0.9-src.zip:$PYTHONPATH"
+export PYTHONPATH="${SPARK_HOME}/python:${PYTHONPATH}"
+export PYTHONPATH="${SPARK_HOME}/python/lib/py4j-0.9-src.zip:${PYTHONPATH}"