forked from sbshrey/DiPETrans
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
133 lines (101 loc) · 4.11 KB
/
run.py
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import os
import sys
import json
import subprocess
import time
print "experiment started"
cdir = "/scratch/sbshrey/Distributed-Mining-validator"
path = "data/bigquery/simulated/ethereum_data_1_"
logs_path = "logs/simulated/val-new/ethereum_data_1_"
mport = 8090
vport = 10090
vport2 = 11090
mining = 0
#m = 2000
for i in [1,2,4,8,16]:
for m in [100,200,300,400,500,1000,1500,2000,2500]:
print "Updating data path"
data_path = "{}{}_{}.json".format(path,i,m)
print data_path
#print "Creating Directory"
dir_path = "{}{}_{}/".format(logs_path,i,m)
#print dir_path
print "Running for differnt worker configurations"
for j in [0,1,2,3,4,5]:
print
processes = []
if j == 0:
print "serial experiment"
commands = [
#"rm -rf {}serial/".format(dir_path),
"mkdir -p {}serial/".format(dir_path),
"./serial-contract {} {}serial/ {}".format(data_path, dir_path, mining)
]
elif j == 1:
print "{} worker experiment".format(j)
node2 = 3
commands = [
#"rm -rf {}{}_worker/".format(dir_path,j),
"mkdir -p {}{}_worker/miner/".format(dir_path,j),
"mkdir -p {}{}_worker/val/".format(dir_path,j),
"mkdir -p {}{}_worker/val2/".format(dir_path,j),
"./masterServer {} {} {} {}{}_worker/miner/ {} &".format(mport, j, data_path, dir_path,j,mining),
'ssh node{} cd {} && ./masterValidator {} {} {} {}{}_worker/val/ {} & '.format(7,cdir,vport,j,data_path,dir_path,j, vport),
'ssh node{} cd {} && ./masterValidator {} {} {} {}{}_worker/val2/ {} & '.format(7,cdir,vport2,j,data_path,dir_path,j, vport2),
'ssh node{} cd {} && ./workerServer {} {} {}{}_worker/miner/ & '.format(node2,cdir,mport+j,j, dir_path,j),
'ssh node{} cd {} && ./workerServer {} {} {}{}_worker/val/ & '.format(8,cdir,vport+j,j, dir_path,j),
'ssh node{} cd {} && ./workerServer {} {} {}{}_worker/val2/ & '.format(8,cdir,vport2+j,j, dir_path,j)
#"./masterClient {}".format(port),
#"pkill Server"
]
else :
print "{} workers experiment".format(j)
commands = [
#"rm -rf {}{}_workers/".format(dir_path,j),
#"mkdir -p {}{}_workers/".format(dir_path,j),
#"./masterServer {} {} {} {}{}_workers/ {} &".format(port, j, data_path, dir_path,j,mining),
"mkdir -p {}{}_workers/miner/".format(dir_path,j),
"mkdir -p {}{}_workers/val/".format(dir_path,j),
"mkdir -p {}{}_workers/val2/".format(dir_path,j),
"./masterServer {} {} {} {}{}_workers/miner/ {} &".format(mport, j, data_path, dir_path,j,mining),
'ssh node{} cd {} && ./masterValidator {} {} {} {}{}_workers/val/ {} & '.format(7,cdir,vport,j,data_path,dir_path,j, vport),
'ssh node{} cd {} && ./masterValidator {} {} {} {}{}_workers/val2/ {} & '.format(7,cdir,vport2,j,data_path,dir_path,j, vport2)
]
nodes = [8,10,11,13,14]
mnodes = [3,4,5,6,24]
k = 1
while k <= j:
#commands.append("./workerServer {} {} {}{}_workers/ &".format(port+k,k,dir_path,j))
commands.append('ssh node{} cd {} && ./workerServer {} {} {}{}_workers/miner/ & '.format(mnodes[k-1],cdir,mport+k,k, dir_path,j))
commands.append('ssh node{} cd {} && ./workerServer {} {} {}{}_workers/val/ & '.format(nodes[k-1],cdir,vport+k,k, dir_path,j))
commands.append('ssh node{} cd {} && ./workerServer {} {} {}{}_workers/val2/ & '.format(nodes[k-1],cdir,vport2+k,k, dir_path,j))
k+=1
#commands.append("./masterClient {}".format(port))
#commands.append("pkill Server")
for cmd in commands:
print cmd
#os.system(cmd)
p = subprocess.Popen(cmd.split(" "))
#time.sleep(5)
if j == 0:
p.wait()
else:
processes.append(p)
if j != 0:
print "./masterClient", str(mport)
time.sleep(60)
p = subprocess.Popen(["./masterClient", str(mport)])
#print p
p.wait()
time.sleep(10)
os.system("pkill Server")
for x in processes:
print "killing", x
x.kill()
os.system("./kill.sh")
#for x in [1,2,3,4,5,6,7,8,10,11,13,14]:
# print x
# os.system("ssh node{} pkill Server".format(x))
# os.system("ssh node{} pkill Validator".format(x))
# #os.system("ssh node{} pkill Server".format(x))
time.sleep(10)