Back to home page

OSCL-LXR

 
 

    


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 # Starts the master on the machine this script is executed on.
0021 
0022 if [ -z "${SPARK_HOME}" ]; then
0023   export SPARK_HOME="$(cd "`dirname "$0"`"/..; pwd)"
0024 fi
0025 
0026 # NOTE: This exact class name is matched downstream by SparkSubmit.
0027 # Any changes need to be reflected there.
0028 CLASS="org.apache.spark.deploy.master.Master"
0029 
0030 if [[ "$@" = *--help ]] || [[ "$@" = *-h ]]; then
0031   echo "Usage: ./sbin/start-master.sh [options]"
0032   pattern="Usage:"
0033   pattern+="\|Using Spark's default log4j profile:"
0034   pattern+="\|Started daemon with process name"
0035   pattern+="\|Registered signal handler for"
0036 
0037   "${SPARK_HOME}"/bin/spark-class $CLASS --help 2>&1 | grep -v "$pattern" 1>&2
0038   exit 1
0039 fi
0040 
0041 ORIGINAL_ARGS="$@"
0042 
0043 . "${SPARK_HOME}/sbin/spark-config.sh"
0044 
0045 . "${SPARK_HOME}/bin/load-spark-env.sh"
0046 
0047 if [ "$SPARK_MASTER_PORT" = "" ]; then
0048   SPARK_MASTER_PORT=7077
0049 fi
0050 
0051 if [ "$SPARK_MASTER_HOST" = "" ]; then
0052   case `uname` in
0053       (SunOS)
0054           SPARK_MASTER_HOST="`/usr/sbin/check-hostname | awk '{print $NF}'`"
0055           ;;
0056       (*)
0057           SPARK_MASTER_HOST="`hostname -f`"
0058           ;;
0059   esac
0060 fi
0061 
0062 if [ "$SPARK_MASTER_WEBUI_PORT" = "" ]; then
0063   SPARK_MASTER_WEBUI_PORT=8080
0064 fi
0065 
0066 "${SPARK_HOME}/sbin"/spark-daemon.sh start $CLASS 1 \
0067   --host $SPARK_MASTER_HOST --port $SPARK_MASTER_PORT --webui-port $SPARK_MASTER_WEBUI_PORT \
0068   $ORIGINAL_ARGS