|
||||
0001 #!/usr/bin/env bash 0002 0003 # 0004 # Licensed to the Apache Software Foundation (ASF) under one or more 0005 # contributor license agreements. See the NOTICE file distributed with 0006 # this work for additional information regarding copyright ownership. 0007 # The ASF licenses this file to You under the Apache License, Version 2.0 0008 # (the "License"); you may not use this file except in compliance with 0009 # the License. You may obtain a copy of the License at 0010 # 0011 # http://www.apache.org/licenses/LICENSE-2.0 0012 # 0013 # Unless required by applicable law or agreed to in writing, software 0014 # distributed under the License is distributed on an "AS IS" BASIS, 0015 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0016 # See the License for the specific language governing permissions and 0017 # limitations under the License. 0018 # 0019 0020 # Run a shell command on all slave hosts. 0021 # 0022 # Environment Variables 0023 # 0024 # SPARK_SLAVES File naming remote hosts. 0025 # Default is ${SPARK_CONF_DIR}/slaves. 0026 # SPARK_CONF_DIR Alternate conf dir. Default is ${SPARK_HOME}/conf. 0027 # SPARK_SLAVE_SLEEP Seconds to sleep between spawning remote commands. 0028 # SPARK_SSH_OPTS Options passed to ssh when running remote commands. 0029 ## 0030 0031 usage="Usage: slaves.sh [--config <conf-dir>] command..." 0032 0033 # if no args specified, show usage 0034 if [ $# -le 0 ]; then 0035 echo $usage 0036 exit 1 0037 fi 0038 0039 if [ -z "${SPARK_HOME}" ]; then 0040 export SPARK_HOME="$(cd "`dirname "$0"`"/..; pwd)" 0041 fi 0042 0043 . "${SPARK_HOME}/sbin/spark-config.sh" 0044 0045 # If the slaves file is specified in the command line, 0046 # then it takes precedence over the definition in 0047 # spark-env.sh. Save it here. 0048 if [ -f "$SPARK_SLAVES" ]; then 0049 HOSTLIST=`cat "$SPARK_SLAVES"` 0050 fi 0051 0052 # Check if --config is passed as an argument. It is an optional parameter. 0053 # Exit if the argument is not a directory. 0054 if [ "$1" == "--config" ] 0055 then 0056 shift 0057 conf_dir="$1" 0058 if [ ! -d "$conf_dir" ] 0059 then 0060 echo "ERROR : $conf_dir is not a directory" 0061 echo $usage 0062 exit 1 0063 else 0064 export SPARK_CONF_DIR="$conf_dir" 0065 fi 0066 shift 0067 fi 0068 0069 . "${SPARK_HOME}/bin/load-spark-env.sh" 0070 0071 if [ "$HOSTLIST" = "" ]; then 0072 if [ "$SPARK_SLAVES" = "" ]; then 0073 if [ -f "${SPARK_CONF_DIR}/slaves" ]; then 0074 HOSTLIST=`cat "${SPARK_CONF_DIR}/slaves"` 0075 else 0076 HOSTLIST=localhost 0077 fi 0078 else 0079 HOSTLIST=`cat "${SPARK_SLAVES}"` 0080 fi 0081 fi 0082 0083 0084 0085 # By default disable strict host key checking 0086 if [ "$SPARK_SSH_OPTS" = "" ]; then 0087 SPARK_SSH_OPTS="-o StrictHostKeyChecking=no" 0088 fi 0089 0090 for slave in `echo "$HOSTLIST"|sed "s/#.*$//;/^$/d"`; do 0091 if [ -n "${SPARK_SSH_FOREGROUND}" ]; then 0092 ssh $SPARK_SSH_OPTS "$slave" $"${@// /\\ }" \ 0093 2>&1 | sed "s/^/$slave: /" 0094 else 0095 ssh $SPARK_SSH_OPTS "$slave" $"${@// /\\ }" \ 0096 2>&1 | sed "s/^/$slave: /" & 0097 fi 0098 if [ "$SPARK_SLAVE_SLEEP" != "" ]; then 0099 sleep $SPARK_SLAVE_SLEEP 0100 fi 0101 done 0102 0103 wait
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |