From bf94264a3e037e00a7b7111a677467de980071c9 Mon Sep 17 00:00:00 2001 From: Gengliang Wang Date: Thu, 15 Nov 2018 23:43:44 +0800 Subject: [PATCH 1/5] fix --- bin/load-spark-env.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/load-spark-env.sh b/bin/load-spark-env.sh index 0b5006dbd63ac..62aec47f91e49 100644 --- a/bin/load-spark-env.sh +++ b/bin/load-spark-env.sh @@ -47,8 +47,8 @@ if [ -z "$SPARK_SCALA_VERSION" ]; then ASSEMBLY_DIR1="${SPARK_HOME}/assembly/target/scala-2.12" if [[ -d "$ASSEMBLY_DIR2" && -d "$ASSEMBLY_DIR1" ]]; then - echo -e "Presence of build for multiple Scala versions detected." 1>&2 - echo -e 'Either clean one of them or, export SPARK_SCALA_VERSION in spark-env.sh.' 1>&2 + echo -e "Presence of build for both scala versions(SCALA 2.11 and SCALA 2.12) detected." 1>&2 + echo -e 'Either clean one of them or, export SPARK_SCALA_VERSION=2.12 in load-spark-env.sh.' 1>&2 exit 1 fi From 1289df1f1271b7ce747b02ffa88cc726f56d02a9 Mon Sep 17 00:00:00 2001 From: Gengliang Wang Date: Fri, 16 Nov 2018 00:14:21 +0800 Subject: [PATCH 2/5] address comments --- bin/load-spark-env.sh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/bin/load-spark-env.sh b/bin/load-spark-env.sh index 62aec47f91e49..c31e8c4b3b156 100644 --- a/bin/load-spark-env.sh +++ b/bin/load-spark-env.sh @@ -42,19 +42,20 @@ fi # Setting SPARK_SCALA_VERSION if not already set. if [ -z "$SPARK_SCALA_VERSION" ]; then - - ASSEMBLY_DIR2="${SPARK_HOME}/assembly/target/scala-2.11" - ASSEMBLY_DIR1="${SPARK_HOME}/assembly/target/scala-2.12" - - if [[ -d "$ASSEMBLY_DIR2" && -d "$ASSEMBLY_DIR1" ]]; then - echo -e "Presence of build for both scala versions(SCALA 2.11 and SCALA 2.12) detected." 1>&2 - echo -e 'Either clean one of them or, export SPARK_SCALA_VERSION=2.12 in load-spark-env.sh.' 1>&2 + SCALA_VERSION1=2.12 + SCALA_VERSION2=2.11 + + ASSEMBLY_DIR1="${SPARK_HOME}/assembly/target/scala-${SCALA_VERSION1}" + ASSEMBLY_DIR2="${SPARK_HOME}/assembly/target/scala-${SCALA_VERSION2}" + if [[ -d "$ASSEMBLY_DIR1" && -d "$ASSEMBLY_DIR2" ]]; then + echo -e "Presence of build for multiple Scala versions detected($ASSEMBLY_DIR1 and $ASSEMBLY_DIR2)." 1>&2 + echo -e "Remove one of them, or export SPARK_SCALA_VERSION=$SCALA_VERSION1 in load-spark-env.sh." 1>&2 exit 1 fi - if [ -d "$ASSEMBLY_DIR2" ]; then - export SPARK_SCALA_VERSION="2.11" + if [ -d "$ASSEMBLY_DIR1" ]; then + export SPARK_SCALA_VERSION=$SCALA_VERSION1 else - export SPARK_SCALA_VERSION="2.12" + export SPARK_SCALA_VERSION=$SCALA_VERSION2 fi fi From daf5e33f14f28fa28e85a703fbd3acc08075fd1b Mon Sep 17 00:00:00 2001 From: Gengliang Wang Date: Fri, 16 Nov 2018 11:28:15 +0800 Subject: [PATCH 3/5] address comments --- bin/load-spark-env.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/bin/load-spark-env.sh b/bin/load-spark-env.sh index c31e8c4b3b156..22f61afd42ca0 100644 --- a/bin/load-spark-env.sh +++ b/bin/load-spark-env.sh @@ -42,20 +42,20 @@ fi # Setting SPARK_SCALA_VERSION if not already set. if [ -z "$SPARK_SCALA_VERSION" ]; then - SCALA_VERSION1=2.12 - SCALA_VERSION2=2.11 - - ASSEMBLY_DIR1="${SPARK_HOME}/assembly/target/scala-${SCALA_VERSION1}" - ASSEMBLY_DIR2="${SPARK_HOME}/assembly/target/scala-${SCALA_VERSION2}" - if [[ -d "$ASSEMBLY_DIR1" && -d "$ASSEMBLY_DIR2" ]]; then - echo -e "Presence of build for multiple Scala versions detected($ASSEMBLY_DIR1 and $ASSEMBLY_DIR2)." 1>&2 - echo -e "Remove one of them, or export SPARK_SCALA_VERSION=$SCALA_VERSION1 in load-spark-env.sh." 1>&2 + SCALA_VERSION_1=2.12 + SCALA_VERSION_2=2.11 + + ASSEMBLY_DIR_1="${SPARK_HOME}/assembly/target/scala-${SCALA_VERSION_1}" + ASSEMBLY_DIR_2="${SPARK_HOME}/assembly/target/scala-${SCALA_VERSION_2}" + if [[ -d "$ASSEMBLY_DIR_1" && -d "$ASSEMBLY_DIR_2" ]]; then + echo "Presence of build for multiple Scala versions detected ($ASSEMBLY_DIR_1 and $ASSEMBLY_DIR_2)." 1>&2 + echo "Remove one of them or, export SPARK_SCALA_VERSION=$SCALA_VERSION_1 in ${SPARK_CONF_DIR}/spark-env.sh." 1>&2 exit 1 fi - if [ -d "$ASSEMBLY_DIR1" ]; then - export SPARK_SCALA_VERSION=$SCALA_VERSION1 + if [[ -d "$ASSEMBLY_DIR_1" ]]; then + export SPARK_SCALA_VERSION=${SCALA_VERSION_1} else - export SPARK_SCALA_VERSION=$SCALA_VERSION2 + export SPARK_SCALA_VERSION=${SCALA_VERSION_2} fi fi From 3269862c0b80bb7c546e9d45fd5fd4aa17aa1c7e Mon Sep 17 00:00:00 2001 From: Gengliang Wang Date: Fri, 16 Nov 2018 12:07:05 +0800 Subject: [PATCH 4/5] revise --- bin/load-spark-env.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/load-spark-env.sh b/bin/load-spark-env.sh index 22f61afd42ca0..2021dbf39c4b2 100644 --- a/bin/load-spark-env.sh +++ b/bin/load-spark-env.sh @@ -26,15 +26,17 @@ if [ -z "${SPARK_HOME}" ]; then source "$(dirname "$0")"/find-spark-home fi +SPARK_ENV_SH="spark-env.sh" if [ -z "$SPARK_ENV_LOADED" ]; then export SPARK_ENV_LOADED=1 export SPARK_CONF_DIR="${SPARK_CONF_DIR:-"${SPARK_HOME}"/conf}" - if [ -f "${SPARK_CONF_DIR}/spark-env.sh" ]; then + SPARK_ENV_SH="${SPARK_CONF_DIR}/${SPARK_ENV_SH}" + if [[ -f "${SPARK_ENV_SH}" ]]; then # Promote all variable declarations to environment (exported) variables set -a - . "${SPARK_CONF_DIR}/spark-env.sh" + . ${SPARK_ENV_SH} set +a fi fi @@ -49,7 +51,7 @@ if [ -z "$SPARK_SCALA_VERSION" ]; then ASSEMBLY_DIR_2="${SPARK_HOME}/assembly/target/scala-${SCALA_VERSION_2}" if [[ -d "$ASSEMBLY_DIR_1" && -d "$ASSEMBLY_DIR_2" ]]; then echo "Presence of build for multiple Scala versions detected ($ASSEMBLY_DIR_1 and $ASSEMBLY_DIR_2)." 1>&2 - echo "Remove one of them or, export SPARK_SCALA_VERSION=$SCALA_VERSION_1 in ${SPARK_CONF_DIR}/spark-env.sh." 1>&2 + echo "Remove one of them or, export SPARK_SCALA_VERSION=$SCALA_VERSION_1 in ${SPARK_ENV_SH}." 1>&2 exit 1 fi From 07cd7f592a2c15707706ca720ea220be267c1b75 Mon Sep 17 00:00:00 2001 From: Gengliang Wang Date: Sat, 17 Nov 2018 14:59:01 +0800 Subject: [PATCH 5/5] add doc link --- bin/load-spark-env.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/load-spark-env.sh b/bin/load-spark-env.sh index 2021dbf39c4b2..0ada5d8d0fc1d 100644 --- a/bin/load-spark-env.sh +++ b/bin/load-spark-env.sh @@ -49,9 +49,11 @@ if [ -z "$SPARK_SCALA_VERSION" ]; then ASSEMBLY_DIR_1="${SPARK_HOME}/assembly/target/scala-${SCALA_VERSION_1}" ASSEMBLY_DIR_2="${SPARK_HOME}/assembly/target/scala-${SCALA_VERSION_2}" + ENV_VARIABLE_DOC="https://spark.apache.org/docs/latest/configuration.html#environment-variables" if [[ -d "$ASSEMBLY_DIR_1" && -d "$ASSEMBLY_DIR_2" ]]; then echo "Presence of build for multiple Scala versions detected ($ASSEMBLY_DIR_1 and $ASSEMBLY_DIR_2)." 1>&2 echo "Remove one of them or, export SPARK_SCALA_VERSION=$SCALA_VERSION_1 in ${SPARK_ENV_SH}." 1>&2 + echo "Visit ${ENV_VARIABLE_DOC} for more details about setting environment variables in spark-env.sh." 1>&2 exit 1 fi