-
Notifications
You must be signed in to change notification settings - Fork 2
/
spark.condor.sh
executable file
·37 lines (29 loc) · 1.3 KB
/
spark.condor.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh -x
source env/bin/activate
CONDOR_CHIRP=`condor_config_val LIBEXEC`/condor_chirp
HOSTNAME=`hostname`
PORT=`python -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()'`
#Uncomment if you want to run multiple clusters CLUSTER=`$CONDOR_CHIRP get_job_attr ClusterId`
MEM=`$CONDOR_CHIRP get_job_attr RequestMemory`
function finish
{
[ ! -z $WORKER ] && kill $WORKER && wait $WORKER
[ ! -z $MASTER ] && kill $MASTER && wait $MASTER
[ ! -z $MASTER ] && $CONDOR_CHIRP remove spark-webui${CLUSTER}.url
}
trap finish exit
if echo spark://$HOSTNAME:$PORT | $CONDOR_CHIRP put -perm 600 -mode cwx - spark-master${CLUSTER}.url
then
WEBUI=`python -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()'`
echo http://$HOSTNAME:$WEBUI | $CONDOR_CHIRP put -perm 600 -mode cw - spark-webui${CLUSTER}.url
spark-class org.apache.spark.deploy.master.Master --host $HOSTNAME --port $PORT --webui-port $WEBUI &
MASTER=$!
fi
while
MasterAddress=`$CONDOR_CHIRP fetch spark-master${CLUSTER}.url -`
echo $MasterAddress|grep -v spark://
do sleep 5; done
spark-class org.apache.spark.deploy.worker.Worker -m ${MEM}M --webui-port 0 $MasterAddress &
WORKER=$!
while $CONDOR_CHIRP fetch spark-master${CLUSTER}.url - >/dev/null
do sleep 30; done