Skip to content

Commit 6b5a07b

Browse files
rxinJames Z.M. Gao
authored andcommitted
Merge pull request apache#449 from CrazyJvm/master
SPARK-1028 : fix "set MASTER automatically fails" bug. spark-shell intends to set MASTER automatically if we do not provide the option when we start the shell , but there's a problem. The condition is "if [[ "x" != "x$SPARK_MASTER_IP" && "y" != "y$SPARK_MASTER_PORT" ]];" we sure will set SPARK_MASTER_IP explicitly, the SPARK_MASTER_PORT option, however, we probably do not set just using spark default port 7077. So if we do not set SPARK_MASTER_PORT, the condition will never be true. We should just use default port if users do not set port explicitly I think. (cherry picked from commit 6b4eed7) Signed-off-by: Patrick Wendell <[email protected]>
1 parent a9e41c7 commit 6b5a07b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

bin/spark-shell

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,18 @@ for o in "$@"; do
4545
done
4646

4747
# Set MASTER from spark-env if possible
48+
DEFAULT_SPARK_MASTER_PORT=7077
4849
if [ -z "$MASTER" ]; then
4950
if [ -e "$FWDIR/conf/spark-env.sh" ]; then
5051
. "$FWDIR/conf/spark-env.sh"
5152
fi
52-
if [[ "x" != "x$SPARK_MASTER_IP" && "y" != "y$SPARK_MASTER_PORT" ]]; then
53-
MASTER="spark://${SPARK_MASTER_IP}:${SPARK_MASTER_PORT}"
54-
export MASTER
53+
if [ "x" != "x$SPARK_MASTER_IP" ]; then
54+
if [ "y" != "y$SPARK_MASTER_PORT" ]; then
55+
SPARK_MASTER_PORT="${SPARK_MASTER_PORT}"
56+
else
57+
SPARK_MASTER_PORT=$DEFAULT_SPARK_MASTER_PORT
58+
fi
59+
export MASTER="spark://${SPARK_MASTER_IP}:${SPARK_MASTER_PORT}"
5560
fi
5661
fi
5762

0 commit comments

Comments
 (0)