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 # Stop all spark daemons.
0021 # Run this on the master node.
0022 
0023 if [ -z "${SPARK_HOME}" ]; then
0024   export SPARK_HOME="$(cd "`dirname "$0"`"/..; pwd)"
0025 fi
0026 
0027 # Load the Spark configuration
0028 . "${SPARK_HOME}/sbin/spark-config.sh"
0029 
0030 # Stop the slaves, then the master
0031 "${SPARK_HOME}/sbin"/stop-slaves.sh
0032 "${SPARK_HOME}/sbin"/stop-master.sh
0033 
0034 if [ "$1" == "--wait" ]
0035 then
0036   printf "Waiting for workers to shut down..."
0037   while true
0038   do
0039     running=`${SPARK_HOME}/sbin/slaves.sh ps -ef | grep -v grep | grep deploy.worker.Worker`
0040     if [ -z "$running" ]
0041     then
0042       printf "\nAll workers successfully shut down.\n"
0043       break
0044     else
0045       printf "."
0046       sleep 10
0047     fi
0048   done
0049 fi