Skip to content

Commit

Permalink
Merge pull request alteryx#69 from KarthikTunga/master
Browse files Browse the repository at this point in the history
Fix for issue SPARK-627. Implementing --config argument in the scripts.

This code fix is for issue SPARK-627. I added code to consider --config arguments in the scripts. In case the  <conf-dir> is not a directory the scripts exit. I removed the --hosts argument. It can be achieved by giving a different config directory. Let me know if an explicit --hosts argument is required.

(cherry picked from commit fc26e5b)
Signed-off-by: Reynold Xin <rxin@apache.org>
  • Loading branch information
mateiz authored and rxin committed Oct 18, 2013
1 parent b531552 commit df21ac8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
19 changes: 18 additions & 1 deletion bin/slaves.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# SPARK_SSH_OPTS Options passed to ssh when running remote commands.
##

usage="Usage: slaves.sh [--config confdir] command..."
usage="Usage: slaves.sh [--config <conf-dir>] command..."

# if no args specified, show usage
if [ $# -le 0 ]; then
Expand All @@ -46,6 +46,23 @@ bin=`cd "$bin"; pwd`
# spark-env.sh. Save it here.
HOSTLIST=$SPARK_SLAVES

# Check if --config is passed as an argument. It is an optional parameter.
# Exit if the argument is not a directory.
if [ "$1" == "--config" ]
then
shift
conf_dir=$1
if [ ! -d "$conf_dir" ]
then
echo "ERROR : $conf_dir is not a directory"
echo $usage
exit 1
else
export SPARK_CONF_DIR=$conf_dir
fi
shift
fi

if [ -f "${SPARK_CONF_DIR}/spark-env.sh" ]; then
. "${SPARK_CONF_DIR}/spark-env.sh"
fi
Expand Down
21 changes: 20 additions & 1 deletion bin/spark-daemon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# SPARK_NICENESS The scheduling priority for daemons. Defaults to 0.
##

usage="Usage: spark-daemon.sh [--config <conf-dir>] [--hosts hostlistfile] (start|stop) <spark-command> <spark-instance-number> <args...>"
usage="Usage: spark-daemon.sh [--config <conf-dir>] (start|stop) <spark-command> <spark-instance-number> <args...>"

# if no args specified, show usage
if [ $# -le 1 ]; then
Expand All @@ -43,6 +43,25 @@ bin=`cd "$bin"; pwd`
. "$bin/spark-config.sh"

# get arguments

# Check if --config is passed as an argument. It is an optional parameter.
# Exit if the argument is not a directory.

if [ "$1" == "--config" ]
then
shift
conf_dir=$1
if [ ! -d "$conf_dir" ]
then
echo "ERROR : $conf_dir is not a directory"
echo $usage
exit 1
else
export SPARK_CONF_DIR=$conf_dir
fi
shift
fi

startStop=$1
shift
command=$1
Expand Down
2 changes: 1 addition & 1 deletion bin/spark-daemons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

# Run a Spark command on all slave hosts.

usage="Usage: spark-daemons.sh [--config confdir] [--hosts hostlistfile] [start|stop] command instance-number args..."
usage="Usage: spark-daemons.sh [--config <conf-dir>] [start|stop] command instance-number args..."

# if no args specified, show usage
if [ $# -le 1 ]; then
Expand Down

0 comments on commit df21ac8

Please sign in to comment.