-
Notifications
You must be signed in to change notification settings - Fork 1
/
AppendCaseSummary.py
228 lines (195 loc) · 10.6 KB
/
AppendCaseSummary.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
import re
import argparse
from operator import add
from operator import sub
parser = argparse.ArgumentParser()
parser.add_argument("-caseresult_dir", "--caseresult_dir", help="Result Dir")
parser.add_argument("-case", "--case", help="Case")
parser.add_argument("-loc", "--loc", help="loc")
parser.add_argument("-cluster_config_type", "--cluster_config_type",help="cluster config type")
parser.add_argument("-hbase_config_type", "--hbase_config_type",help="hbase config type")
parser.add_argument("-table_config_type", "--table_config_type",help="table config type")
parser.add_argument("-phase","--phase",help="Phase")
#parser.add_argument("-workload_type","--workload_type",help="workload type")
args = parser.parse_args()
#extract the workload type
def get_workload_type():
workload_type=''
with open(args.caseresult_dir + '/case' + args.case + '/case' + args.case + '.log', 'r') as caselog:
f = caselog.read()
if re.findall('\+ load=true', f):
workload_type='load'
elif re.findall('\+ random_read=true', f):
workload_type='random_read'
elif re.findall('\+ workloada=true', f):
workload_type='workloada'
elif re.findall('\+ workloadb=true', f):
workload_type='workloadb'
elif re.findall('\+ workloadc=true', f):
workload_type='workloadc'
return workload_type
workload_type = get_workload_type()
print(workload_type)
summary = args.case+ ',' + args.cluster_config_type + ',' + args.hbase_config_type + ',' + args.table_config_type + ',' + args.phase + ',' + workload_type + ','
def getNumOperations(filename, operation_type):
number_of_operations=0
with open(filename, 'r') as ycsb_log:
for line in ycsb_log:
words = line.strip().split()
if len(words) == 3:
if words[0] == '[' + operation_type + '],' and words[1] == 'Operations,':
number_of_operations = int(words[2])
return number_of_operations
def getThroughput(filename):
throuput=0.0
with open(filename, 'r') as ycsb_log:
for line in ycsb_log:
words = line.strip().split()
if len(words) == 3:
if words[0] == '[OVERALL],' and words[1] == 'Throughput(ops/sec),':
throughput = float(words[2])
return throughput
def getAvgLatency(filename, operation_type):
avg_latency = 0
with open(filename, 'r') as ycsb_log:
for line in ycsb_log:
words = line.strip().split()
if len(words) == 3:
if words[0] == '['+ operation_type + '],' and words[1] == 'AverageLatency(us),':
avg_latency = float(words[2])
return avg_latency
number_of_insert_ops = getNumOperations( args.caseresult_dir + '/case' + args.case + '/' + workload_type + '_1.dat', 'INSERT')
number_of_update_ops = getNumOperations( args.caseresult_dir + '/case' + args.case + '/' + workload_type + '_1.dat', 'UPDATE')
number_of_read_ops = getNumOperations( args.caseresult_dir + '/case' + args.case + '/' + workload_type + '_1.dat', 'READ')
number_of_scan_ops = getNumOperations( args.caseresult_dir + '/case' + args.case + '/' + workload_type + '_1.dat', 'SCAN')
number_of_delete_ops = getNumOperations( args.caseresult_dir + '/case' + args.case + '/' + workload_type + '_1.dat', 'DELETE')
total_number_ops = number_of_insert_ops + number_of_update_ops + number_of_read_ops + number_of_scan_ops + number_of_delete_ops
summary = summary + str(total_number_ops) + ','
summary = summary + str(getThroughput( args.caseresult_dir + '/case' + args.case + '/' + workload_type + '_1.dat')) + ','
def getAsyncProcessErrorCount(filename):
errorCount=0
with open(filename, 'r') as caselog:
for line in caselog:
tokens = line.strip().split()
return errorCount
summary = summary + str(number_of_insert_ops) + ','
summary = summary + str(getAvgLatency( args.caseresult_dir + '/case' + args.case + '/' + workload_type + '_1.dat', 'INSERT')) + ','
summary = summary + str(number_of_read_ops) + ','
summary = summary + str(getAvgLatency( args.caseresult_dir + '/case' + args.case + '/' + workload_type + '_1.dat', 'READ')) + ','
summary = summary + str(number_of_update_ops) + ','
summary = summary + str(getAvgLatency( args.caseresult_dir + '/case' + args.case + '/' + workload_type + '_1.dat', 'UPDATE')) + ','
summary = summary + str(number_of_scan_ops) + ','
summary = summary + str(getAvgLatency( args.caseresult_dir + '/case' + args.case + '/' + workload_type + '_1.dat', 'SCAN')) + ','
summary = summary + str(number_of_delete_ops) + ','
summary = summary + str(getAvgLatency( args.caseresult_dir + '/case' + args.case + '/' + workload_type + '_1.dat', 'DELETE')) + ','
def getMetric(filename, metric):
metric_val=0
with open(filename, 'r') as file:
for line in file:
tokens = line.strip().split()
for token in tokens:
words=token.strip(',').split('=')
if metric == words[0]:
metric_val = float(words[1])
return(metric_val)
def get_avgtime_metric(filename1, filename2, metric1, metric2):
metric_val=0
master_total_ops=0
master_total_opstime=0
with open(args.caseresult_dir + '/case' + args.case + filename1, 'r') as master_datanode_metric:
for line in master_datanode_metric:
tokens = line.strip().split()
for token in tokens:
words=token.strip(',').split('=')
if metric1 == words[0]:
ops = float(words[1])
if metric2 == words[0]:
ops_avg_time = float(words[1])
master_total_opstime = master_total_opstime + ops_avg_time*(ops - master_total_ops)
#print('master total ops time: ' + str(master_total_opstime))
#print('master total num ops: ' + str(ops))
master_total_ops=ops
slave1_total_ops=0
slave1_total_opstime=0
with open(args.caseresult_dir + '/case' + args.case + filename2, 'r') as slave1_datanode_metric:
for line in slave1_datanode_metric:
tokens = line.strip().split()
for token in tokens:
words=token.strip(',').split('=')
if metric1 == words[0]:
ops = float(words[1])
if metric2 == words[0]:
ops_avg_time = float(words[1])
slave1_total_opstime = slave1_total_opstime + ops_avg_time*(ops - slave1_total_ops)
#print('slave1 total ops time: ' + str(slave1_total_opstime))
#print('slave1 total num ops: ' + str(ops))
slave1_total_ops=ops
metric_val = (master_total_opstime+slave1_total_opstime)/(master_total_ops+slave1_total_ops)
return metric_val
summary = summary + str(getMetric(args.caseresult_dir + '/case' + args.case + '/master/namenode-metrics.out', 'CapacityUsed')/(1024*1024*1024)) + ','
def get_dfs_metric(metric):
dfs_master_metric_val = getMetric(args.caseresult_dir + '/case' + args.case + '/master/datanode-metrics.out', metric)
dfs_slave1_metric_val = getMetric(args.caseresult_dir + '/case' + args.case + '/slave1/datanode-metrics.out', metric)
dfs_metric_val = float(dfs_master_metric_val) + float(dfs_slave1_metric_val)
return dfs_metric_val
summary = summary + str(get_dfs_metric('bytes_written')/(1024*1024*1024)) + ','
summary = summary + str(get_dfs_metric('bytes_read')/(1024*1024*1024)) + ','
summary = summary + str(get_dfs_metric('blocks_written')) + ','
summary = summary + str(get_dfs_metric('blocks_read')) + ','
summary = summary + str(get_dfs_metric('writes_from_remote_client')) + ','
summary = summary + str(get_dfs_metric('writes_from_local_client')) + ','
summary = summary + str(get_dfs_metric('reads_from_remote_client')) + ','
summary = summary + str(get_dfs_metric('reads_from_local_client')) + ','
summary = summary + str(get_dfs_metric('readBlockOp_num_ops')) + ','
summary = summary + str(get_avgtime_metric('/master/datanode-metrics.out', '/slave1/datanode-metrics.out', 'readBlockOp_num_ops', 'readBlockOp_avg_time')) + ','
summary = summary + str(get_dfs_metric('writeBlockOp_num_ops')) + ','
summary = summary + str(get_avgtime_metric('/master/datanode-metrics.out', '/slave1/datanode-metrics.out', 'writeBlockOp_num_ops', 'writeBlockOp_avg_time')) + ','
summary = summary + str(get_dfs_metric('gcTimeMillis')) + ','
def get_from_all_metric(metric):
master_metric_val = getMetric(args.caseresult_dir + '/case' + args.case + '/master/all.metrics', metric)
slave1_metric_val = getMetric(args.caseresult_dir + '/case' + args.case + '/slave1/all.metrics', metric)
metric_val = float(master_metric_val) + float(slave1_metric_val)
return metric_val
summary = summary + str(get_from_all_metric('storeFileCount')) + ','
summary = summary + str(get_from_all_metric('storeFileSize')/(1024*1024*1024)) + ','
summary = summary + str(get_from_all_metric('hlogFileCount')) + ','
summary = summary + str(get_from_all_metric('hlogFileSize')/(1024*1024*1024)) + ','
summary = summary + str(get_from_all_metric('blockCacheFreeSize')/(1024*1024*1024)) + ','
summary = summary + str(get_from_all_metric('blockCacheCount')) + ','
summary = summary + str(get_from_all_metric('blockCacheSize')/(1024*1024*1024)) + ','
summary = summary + str(get_from_all_metric('blockCacheHitCount')) + ','
summary = summary + str(get_from_all_metric('blockCacheMissCount')) + ','
summary = summary + str(get_from_all_metric('blockCacheEvictionCount')) + ','
summary = summary + str(get_from_all_metric('gcTimeMillis')) + ','
def getSummationOfMetric(filename, metric, avg):
metric_val=0
count=0
with open(filename, 'r') as file:
for line in file:
words=line.split()
for word in words:
kv = word.strip(',').split('=')
p = re.compile(metric)
if p.match(kv[0]):
metric_val = metric_val + int(kv[1])
count=count+1
if avg == True:
metric_val=metric_val/count
return metric_val
def getTotalCompactionMetric(metric):
master_compactionMetric = getSummationOfMetric(args.caseresult_dir + '/case' + args.case + '/master/all.metrics', metric, False)
slave1_compactionMetric = getSummationOfMetric(args.caseresult_dir + '/case' + args.case + '/slave1/all.metrics', metric, False)
compactionMetric = int(master_compactionMetric) + int(slave1_compactionMetric)
return compactionMetric
summary = summary + str(getTotalCompactionMetric('namespace_default_table_usertable_region_\w*_metric_numBytesCompactedCount')/(1024*1024*1024)) + ','
summary = summary + str(getTotalCompactionMetric('namespace_default_table_usertable_region_\w*_metric_numFilesCompactedCount')) + ','
summary = summary + str(getTotalCompactionMetric('namespace_default_table_usertable_region_\w*_metric_compactionsCompletedCount')) + ','
def getAvgQueueSize(metric):
master_queueSize = getSummationOfMetric(args.caseresult_dir + '/case' + args.case + '/master/all.metrics', metric, True)
slave1_queueSize = getSummationOfMetric(args.caseresult_dir + '/case' + args.case + '/slave1/all.metrics', metric, True)
avg_queueSize = .5*(master_queueSize+slave1_queueSize)
return avg_queueSize
summary = summary + str(getAvgQueueSize('queueSize')/1000000) + ','
summary = summary + str(get_avgtime_metric('/master/all.metrics', '/slave1/all.metrics', 'get_num_ops', 'get_mean'))
with open('collected_metrics.csv','a') as out:
out.write(summary+'\n')