-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun-all.sh
86 lines (68 loc) · 1.72 KB
/
run-all.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
# Options for the experiment
#
WORKER_FILE=/home/vicente/PasswordCrackerThrift/PasswordCrackerMaster/WorkerInfoList.json
MASTER_PORT=18000
WORKER_PORT=17000
MASTER=10.20.13.123
# -----------------------------------------------------------------------
trap kill-all SIGHUP SIGINT SIGTERM EXIT # Always call cleanup
NODES=`cat $WORKER_FILE | grep -Po '[0-9]*\..*\..*\.[0-9]*'`
CLASSPATH=`find $(pwd) -name "*.jar" -printf ":%p"`
declare -A PIDS
declare -A KEYS
function run-all()
{
ssh -t -t $MASTER java -cp $CLASSPATH PasswordCrackerMaster.PasswordCrackerMasterMain $MASTER_PORT &
PIDS["master"]="$!"
sleep 1
for node in ${NODES[@]}; do
ssh -t -t $node java -cp $CLASSPATH PasswordCrackerWorker.PasswordCrackerWorkerMain $MASTER $MASTER_PORT $WORKER_PORT &
PIDS["nodes"]="${PIDS["nodes"]} $!"
done
sleep 2
}
function kill-all()
{
for client in ${PIDS["clients"]}; do
wait $client
done
kill ${PIDS[@]}
}
function generate-keys()
{
for i in {1..9}; do
key=${i}zzzzz
KEYS["$key"]=`echo -n $key | openssl md5 -r | cut -d ' ' -f1`
done
}
function launch-client
{
encryptedKey=${KEYS["$1"]}
echo "Submiting key $1:$encryptedKey"
java -cp $CLASSPATH PasswordCrackerClient.PasswordCrackerClient $MASTER $MASTER_PORT ${KEYS[$1]} &
PIDS["clients"]="$! ${PIDS["clients"]}"
}
# ---- Initialize
generate-keys
run-all
# ----
# Time 0
read -a key <<< ${!KEYS[@]}
read -a nodes <<< ${PIDS["nodes"]}
echo "Time 0"
launch-client ${key[1]}
launch-client ${key[3]}
sleep 5 # time 1
echo "Time 1"
kill ${nodes[5]} # Node 5 dies
sleep 10 # time 2
echo "Time 2"
kill ${nodes[4]}
kill ${nodes[6]}
sleep 15 # time 3
echo "Time 3"
launch-client ${key[6]}
launch-client ${key[4]}
# ---- Cleanup
kill-all