Skip to content

Commit 9e48cdf

Browse files
Charles Yehsrowen
Charles Yeh
authored andcommitted
[SPARK-11218][CORE] show help messages for start-slave and start-master
Addressing https://issues.apache.org/jira/browse/SPARK-11218, mostly copied start-thriftserver.sh. ``` charlesyeh-mbp:spark charlesyeh$ ./sbin/start-master.sh --help Usage: Master [options] Options: -i HOST, --ip HOST Hostname to listen on (deprecated, please use --host or -h) -h HOST, --host HOST Hostname to listen on -p PORT, --port PORT Port to listen on (default: 7077) --webui-port PORT Port for web UI (default: 8080) --properties-file FILE Path to a custom Spark properties file. Default is conf/spark-defaults.conf. ``` ``` charlesyeh-mbp:spark charlesyeh$ ./sbin/start-slave.sh Usage: Worker [options] <master> Master must be a URL of the form spark://hostname:port Options: -c CORES, --cores CORES Number of cores to use -m MEM, --memory MEM Amount of memory to use (e.g. 1000M, 2G) -d DIR, --work-dir DIR Directory to run apps in (default: SPARK_HOME/work) -i HOST, --ip IP Hostname to listen on (deprecated, please use --host or -h) -h HOST, --host HOST Hostname to listen on -p PORT, --port PORT Port to listen on (default: random) --webui-port PORT Port for web UI (default: 8081) --properties-file FILE Path to a custom Spark properties file. Default is conf/spark-defaults.conf. ``` Author: Charles Yeh <[email protected]> Closes #9432 from CharlesYeh/helpmsg.
1 parent d8b50f7 commit 9e48cdf

File tree

2 files changed

+34
-14
lines changed

2 files changed

+34
-14
lines changed

sbin/start-master.sh

+19-5
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,28 @@ if [ -z "${SPARK_HOME}" ]; then
2323
export SPARK_HOME="$(cd "`dirname "$0"`"/..; pwd)"
2424
fi
2525

26+
# NOTE: This exact class name is matched downstream by SparkSubmit.
27+
# Any changes need to be reflected there.
28+
CLASS="org.apache.spark.deploy.master.Master"
29+
30+
if [[ "$@" = *--help ]] || [[ "$@" = *-h ]]; then
31+
echo "Usage: ./sbin/start-master.sh [options]"
32+
pattern="Usage:"
33+
pattern+="\|Using Spark's default log4j profile:"
34+
pattern+="\|Registered signal handlers for"
35+
36+
"${SPARK_HOME}"/bin/spark-class $CLASS --help 2>&1 | grep -v "$pattern" 1>&2
37+
exit 1
38+
fi
39+
2640
ORIGINAL_ARGS="$@"
2741

2842
START_TACHYON=false
2943

3044
while (( "$#" )); do
3145
case $1 in
3246
--with-tachyon)
33-
if [ ! -e "$sbin"/../tachyon/bin/tachyon ]; then
47+
if [ ! -e "${SPARK_HOME}"/tachyon/bin/tachyon ]; then
3448
echo "Error: --with-tachyon specified, but tachyon not found."
3549
exit -1
3650
fi
@@ -56,12 +70,12 @@ if [ "$SPARK_MASTER_WEBUI_PORT" = "" ]; then
5670
SPARK_MASTER_WEBUI_PORT=8080
5771
fi
5872

59-
"${SPARK_HOME}/sbin"/spark-daemon.sh start org.apache.spark.deploy.master.Master 1 \
73+
"${SPARK_HOME}/sbin"/spark-daemon.sh start $CLASS 1 \
6074
--ip $SPARK_MASTER_IP --port $SPARK_MASTER_PORT --webui-port $SPARK_MASTER_WEBUI_PORT \
6175
$ORIGINAL_ARGS
6276

6377
if [ "$START_TACHYON" == "true" ]; then
64-
"${SPARK_HOME}/sbin"/../tachyon/bin/tachyon bootstrap-conf $SPARK_MASTER_IP
65-
"${SPARK_HOME}/sbin"/../tachyon/bin/tachyon format -s
66-
"${SPARK_HOME}/sbin"/../tachyon/bin/tachyon-start.sh master
78+
"${SPARK_HOME}"/tachyon/bin/tachyon bootstrap-conf $SPARK_MASTER_IP
79+
"${SPARK_HOME}"/tachyon/bin/tachyon format -s
80+
"${SPARK_HOME}"/tachyon/bin/tachyon-start.sh master
6781
fi

sbin/start-slave.sh

+15-9
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,24 @@
3131
# worker. Subsequent workers will increment this
3232
# number. Default is 8081.
3333

34-
usage="Usage: start-slave.sh <spark-master-URL> where <spark-master-URL> is like spark://localhost:7077"
35-
36-
if [ $# -lt 1 ]; then
37-
echo $usage
38-
echo Called as start-slave.sh $*
39-
exit 1
40-
fi
41-
4234
if [ -z "${SPARK_HOME}" ]; then
4335
export SPARK_HOME="$(cd "`dirname "$0"`"/..; pwd)"
4436
fi
4537

38+
# NOTE: This exact class name is matched downstream by SparkSubmit.
39+
# Any changes need to be reflected there.
40+
CLASS="org.apache.spark.deploy.worker.Worker"
41+
42+
if [[ $# -lt 1 ]] || [[ "$@" = *--help ]] || [[ "$@" = *-h ]]; then
43+
echo "Usage: ./sbin/start-slave.sh [options] <master>"
44+
pattern="Usage:"
45+
pattern+="\|Using Spark's default log4j profile:"
46+
pattern+="\|Registered signal handlers for"
47+
48+
"${SPARK_HOME}"/bin/spark-class $CLASS --help 2>&1 | grep -v "$pattern" 1>&2
49+
exit 1
50+
fi
51+
4652
. "${SPARK_HOME}/sbin/spark-config.sh"
4753

4854
. "${SPARK_HOME}/bin/load-spark-env.sh"
@@ -72,7 +78,7 @@ function start_instance {
7278
fi
7379
WEBUI_PORT=$(( $SPARK_WORKER_WEBUI_PORT + $WORKER_NUM - 1 ))
7480

75-
"${SPARK_HOME}/sbin"/spark-daemon.sh start org.apache.spark.deploy.worker.Worker $WORKER_NUM \
81+
"${SPARK_HOME}/sbin"/spark-daemon.sh start $CLASS $WORKER_NUM \
7682
--webui-port "$WEBUI_PORT" $PORT_FLAG $PORT_NUM $MASTER "$@"
7783
}
7884

0 commit comments

Comments
 (0)