1 | package simulator.stats; |
---|
2 | |
---|
3 | import java.util.ArrayList; |
---|
4 | import java.util.List; |
---|
5 | |
---|
6 | import simulator.stats.implementation.MetricsStats; |
---|
7 | import example.energy.coolemall.CoolEmAllTestbedMeasurements; |
---|
8 | |
---|
9 | public class CoolEmAllMetricsCalculator extends AbstractMetricsCalculator{ |
---|
10 | |
---|
11 | public CoolEmAllMetricsCalculator (long startTime, long endTime, long timestamp){ |
---|
12 | super(startTime, endTime, timestamp); |
---|
13 | } |
---|
14 | |
---|
15 | public List<MetricsStats> calulateMetrics(){ |
---|
16 | List<MetricsStats> metrics = new ArrayList<MetricsStats>(); |
---|
17 | /*for(String resourceTypeName: metricsData.keySet()){ |
---|
18 | MetricsStats metric = new MetricsStats(resourceTypeName, "energyUsage", metricsData.get(resourceTypeName).getMax()); |
---|
19 | metrics.add(metric);} |
---|
20 | }*/ |
---|
21 | metrics.add(calculateITComputingEnergyConsumption()); |
---|
22 | metrics.add(calculateITEnergyConsumption()); |
---|
23 | metrics.add(calculateNodeGroupFansEnergyConsumption()); |
---|
24 | |
---|
25 | metrics.add(calculateRackEnergyConsumption()); |
---|
26 | metrics.add(calculateDataCenterFansEnergyConsumption()); |
---|
27 | metrics.add(calculateCoolingDeviceEnergyConsumption()); |
---|
28 | metrics.add(calculateOtherDevicesEnergyConsumption()); |
---|
29 | |
---|
30 | metrics.add(calculateTotalEnergyConsumption()); |
---|
31 | |
---|
32 | metrics.add(calculateMeanRackPower()); |
---|
33 | metrics.add(calculateMeanPower()); |
---|
34 | metrics.add(calculateMaxRackPower()); |
---|
35 | metrics.add(calculateMaxPower()); |
---|
36 | |
---|
37 | metrics.add(calculatePUE()); |
---|
38 | metrics.add(calculatePUELevel4()); |
---|
39 | metrics.add(calculateEnergyWasteRate()); |
---|
40 | |
---|
41 | metrics.add(calculateUsefulWork()); |
---|
42 | metrics.add(calculateProductivity()); |
---|
43 | |
---|
44 | return metrics; |
---|
45 | } |
---|
46 | |
---|
47 | private MetricsStats calculateTotalEnergyConsumption(){ |
---|
48 | |
---|
49 | MetricsStats metric; |
---|
50 | try{ |
---|
51 | |
---|
52 | double roomPower = 0; |
---|
53 | for(DCwormsAccumulator acc: metricsData.get("Room")){ |
---|
54 | roomPower = roomPower + acc.getSum(); |
---|
55 | } |
---|
56 | metric = new MetricsStats("CoolEmAllTestbed", "Total_energy_consumption", roomPower, timestamp, "Wh"); |
---|
57 | } catch (Exception e){ |
---|
58 | metric = new MetricsStats("CoolEmAllTestbed", "Total_energy_consumption", -1, timestamp, "Wh"); |
---|
59 | } |
---|
60 | return metric; |
---|
61 | } |
---|
62 | |
---|
63 | private MetricsStats calculateITComputingEnergyConsumption(){ |
---|
64 | |
---|
65 | MetricsStats metric; |
---|
66 | try{ |
---|
67 | double itComputingPower = 0; |
---|
68 | for(DCwormsAccumulator acc: metricsData.get("Processor")){ |
---|
69 | itComputingPower = itComputingPower + acc.getSum(); |
---|
70 | } |
---|
71 | metric = new MetricsStats("CoolEmAllTestbed", "Total_processors_energy_consumption", (itComputingPower), timestamp, "Wh"); |
---|
72 | } catch (Exception e){ |
---|
73 | metric = new MetricsStats("CoolEmAllTestbed", "Total_processors_energy_consumption", -1, timestamp, "Wh"); |
---|
74 | } |
---|
75 | return metric; |
---|
76 | } |
---|
77 | |
---|
78 | private MetricsStats calculateITEnergyConsumption(){ |
---|
79 | |
---|
80 | MetricsStats metric; |
---|
81 | try{ |
---|
82 | double totalSitePower = 0; |
---|
83 | for(DCwormsAccumulator acc: metricsData.get("Rack")){ |
---|
84 | totalSitePower = totalSitePower + acc.getSum(); |
---|
85 | } |
---|
86 | double nodeComputingPower = 0; |
---|
87 | for(DCwormsAccumulator acc: metricsData.get("Node")){ |
---|
88 | nodeComputingPower = nodeComputingPower+ acc.getSum(); |
---|
89 | } |
---|
90 | double itComputingPower = 0; |
---|
91 | for(DCwormsAccumulator acc: metricsData.get("Processor")){ |
---|
92 | itComputingPower = itComputingPower + acc.getSum(); |
---|
93 | } |
---|
94 | double nodeGroupFansPowerConumspion = nodeComputingPower - itComputingPower; |
---|
95 | metric = new MetricsStats("CoolEmAllTestbed", "Total_IT_energy_consumption", (totalSitePower * CoolEmAllTestbedMeasurements.POWER_SUPPLY_EFFICIENCY - nodeGroupFansPowerConumspion), timestamp, "Wh"); |
---|
96 | } catch (Exception e){ |
---|
97 | metric = new MetricsStats("CoolEmAllTestbed", "Total_IT_energy_consumption", -1, timestamp, "Wh"); |
---|
98 | } |
---|
99 | return metric; |
---|
100 | } |
---|
101 | |
---|
102 | private MetricsStats calculateNodeGroupFansEnergyConsumption(){ |
---|
103 | |
---|
104 | MetricsStats metric; |
---|
105 | try{ |
---|
106 | double nodeComputingPower = 0; |
---|
107 | for(DCwormsAccumulator acc: metricsData.get("Node")){ |
---|
108 | nodeComputingPower = nodeComputingPower+ acc.getSum(); |
---|
109 | } |
---|
110 | double itComputingPower = 0; |
---|
111 | for(DCwormsAccumulator acc: metricsData.get("Processor")){ |
---|
112 | itComputingPower = itComputingPower + acc.getSum(); |
---|
113 | } |
---|
114 | double nodeGroupFansPowerConumspion = nodeComputingPower - itComputingPower; |
---|
115 | metric = new MetricsStats("CoolEmAllTestbed", "Total_node_group_fans_energy_consumption", nodeGroupFansPowerConumspion, timestamp, "Wh"); |
---|
116 | } catch (Exception e){ |
---|
117 | metric = new MetricsStats("CoolEmAllTestbed", "Total_node_group_fans_energy_consumption", -1, timestamp, "Wh"); |
---|
118 | } |
---|
119 | return metric; |
---|
120 | } |
---|
121 | |
---|
122 | private MetricsStats calculatePUELevel4(){ |
---|
123 | |
---|
124 | MetricsStats metric; |
---|
125 | try{ |
---|
126 | |
---|
127 | double roomPower = 0; |
---|
128 | for(DCwormsAccumulator acc: metricsData.get("Room")){ |
---|
129 | roomPower = roomPower + acc.getSum(); |
---|
130 | } |
---|
131 | |
---|
132 | double totalSitePower = 0; |
---|
133 | for(DCwormsAccumulator acc: metricsData.get("Rack")){ |
---|
134 | totalSitePower = totalSitePower + acc.getSum(); |
---|
135 | } |
---|
136 | |
---|
137 | |
---|
138 | double nodeComputingPower = 0; |
---|
139 | for(DCwormsAccumulator acc: metricsData.get("Node")){ |
---|
140 | nodeComputingPower = nodeComputingPower+ acc.getSum(); |
---|
141 | } |
---|
142 | double itComputingPower = 0; |
---|
143 | for(DCwormsAccumulator acc: metricsData.get("Processor")){ |
---|
144 | itComputingPower = itComputingPower + acc.getSum(); |
---|
145 | } |
---|
146 | double nodeGroupFansPowerConumspion = nodeComputingPower - itComputingPower; |
---|
147 | |
---|
148 | metric = new MetricsStats("CoolEmAllTestbed", "PUE_Level_4", roomPower/(totalSitePower * CoolEmAllTestbedMeasurements.POWER_SUPPLY_EFFICIENCY - nodeGroupFansPowerConumspion), timestamp, ""); |
---|
149 | } catch (Exception e){ |
---|
150 | metric = new MetricsStats("CoolEmAllTestbed", "PUE_Level_4", -1, timestamp, ""); |
---|
151 | } |
---|
152 | return metric; |
---|
153 | } |
---|
154 | |
---|
155 | private MetricsStats calculatePUE(){ |
---|
156 | |
---|
157 | MetricsStats metric; |
---|
158 | try{ |
---|
159 | |
---|
160 | double roomPower = 0; |
---|
161 | for(DCwormsAccumulator acc: metricsData.get("Room")){ |
---|
162 | roomPower = roomPower + acc.getSum(); |
---|
163 | } |
---|
164 | |
---|
165 | double totalSitePower = 0; |
---|
166 | for(DCwormsAccumulator acc: metricsData.get("Rack")){ |
---|
167 | totalSitePower = totalSitePower + acc.getSum(); |
---|
168 | } |
---|
169 | |
---|
170 | |
---|
171 | metric = new MetricsStats("CoolEmAllTestbed", "PUE", roomPower/totalSitePower, timestamp, ""); |
---|
172 | } catch (Exception e){ |
---|
173 | metric = new MetricsStats("CoolEmAllTestbed", "PUE", -1, timestamp, ""); |
---|
174 | } |
---|
175 | return metric; |
---|
176 | } |
---|
177 | |
---|
178 | private MetricsStats calculateUsefulWork(){ |
---|
179 | |
---|
180 | MetricsStats metric; |
---|
181 | try{ |
---|
182 | double usefulWork = 0; |
---|
183 | for(String key: metricsData.keySet()){ |
---|
184 | if(key.contains("UW_")){ |
---|
185 | for(DCwormsAccumulator acc: metricsData.get(key)){ |
---|
186 | usefulWork= usefulWork + acc.getSum(); |
---|
187 | } |
---|
188 | } |
---|
189 | } |
---|
190 | metric = new MetricsStats("CoolEmAllTestbed", "Useful_Work", usefulWork, timestamp, "UW units"); |
---|
191 | } catch (Exception e){ |
---|
192 | metric = new MetricsStats("CoolEmAllTestbed", "Useful_Work", -1, timestamp, "UW units"); |
---|
193 | } |
---|
194 | |
---|
195 | return metric; |
---|
196 | } |
---|
197 | |
---|
198 | private MetricsStats calculateProductivity(){ |
---|
199 | |
---|
200 | MetricsStats metric; |
---|
201 | try{ |
---|
202 | double usefulWork = 0; |
---|
203 | for(String key: metricsData.keySet()){ |
---|
204 | if(key.contains("/")){ |
---|
205 | for(DCwormsAccumulator acc: metricsData.get(key)){ |
---|
206 | usefulWork= usefulWork + acc.getSum(); |
---|
207 | } |
---|
208 | } |
---|
209 | } |
---|
210 | double totalSitePower = 0; |
---|
211 | for(DCwormsAccumulator acc: metricsData.get("Rack")){ |
---|
212 | totalSitePower = totalSitePower + acc.getSum(); |
---|
213 | } |
---|
214 | |
---|
215 | metric = new MetricsStats("CoolEmAllTestbed", "Productivity", usefulWork/totalSitePower, timestamp, "UW units/Wh"); |
---|
216 | } catch (Exception e){ |
---|
217 | metric = new MetricsStats("CoolEmAllTestbed", "Productivity", -1, timestamp, "UW units/Wh"); |
---|
218 | } |
---|
219 | |
---|
220 | return metric; |
---|
221 | } |
---|
222 | |
---|
223 | |
---|
224 | private MetricsStats calculateMaxRackPower(){ |
---|
225 | |
---|
226 | MetricsStats metric; |
---|
227 | try{ |
---|
228 | double maxPower = 0; |
---|
229 | |
---|
230 | for(DCwormsAccumulator acc: metricsData.get("Rack_MAX")){ |
---|
231 | maxPower = maxPower + acc.getSum(); |
---|
232 | } |
---|
233 | |
---|
234 | metric = new MetricsStats("CoolEmAllTestbed", "Max_rack_power", maxPower, timestamp, "W"); |
---|
235 | } catch (Exception e){ |
---|
236 | metric = new MetricsStats("CoolEmAllTestbed", "Max_rack_power", -1, timestamp, "W"); |
---|
237 | } |
---|
238 | |
---|
239 | return metric; |
---|
240 | } |
---|
241 | |
---|
242 | private MetricsStats calculateMaxPower(){ |
---|
243 | |
---|
244 | MetricsStats metric; |
---|
245 | try{ |
---|
246 | double maxPower = 0; |
---|
247 | |
---|
248 | for(DCwormsAccumulator acc: metricsData.get("Room_MAX")){ |
---|
249 | maxPower = maxPower + acc.getSum(); |
---|
250 | } |
---|
251 | |
---|
252 | metric = new MetricsStats("CoolEmAllTestbed", "Max_power", maxPower, timestamp, "W"); |
---|
253 | } catch (Exception e){ |
---|
254 | metric = new MetricsStats("CoolEmAllTestbed", "Max_power", -1, timestamp, "W"); |
---|
255 | } |
---|
256 | |
---|
257 | return metric; |
---|
258 | } |
---|
259 | |
---|
260 | private MetricsStats calculateDataCenterFansEnergyConsumption(){ |
---|
261 | |
---|
262 | MetricsStats metric; |
---|
263 | try{ |
---|
264 | double inletsPower = 0; |
---|
265 | for(DCwormsAccumulator acc: metricsData.get("Inlet")){ |
---|
266 | inletsPower = inletsPower + acc.getSum(); |
---|
267 | } |
---|
268 | |
---|
269 | double outletsPower = 0; |
---|
270 | for(DCwormsAccumulator acc: metricsData.get("Outlet")){ |
---|
271 | outletsPower = outletsPower + acc.getSum(); |
---|
272 | } |
---|
273 | |
---|
274 | double nodeComputingPower = 0; |
---|
275 | for(DCwormsAccumulator acc: metricsData.get("Node")){ |
---|
276 | nodeComputingPower = nodeComputingPower+ acc.getSum(); |
---|
277 | } |
---|
278 | double itComputingPower = 0; |
---|
279 | for(DCwormsAccumulator acc: metricsData.get("Processor")){ |
---|
280 | itComputingPower = itComputingPower + acc.getSum(); |
---|
281 | } |
---|
282 | double nodeGroupFansPowerConumspion = nodeComputingPower - itComputingPower; |
---|
283 | |
---|
284 | metric = new MetricsStats("CoolEmAllTestbed", "Total_data_center_fans_energy_consumption", (inletsPower + outletsPower - nodeGroupFansPowerConumspion), timestamp, "Wh"); |
---|
285 | } catch (Exception e){ |
---|
286 | metric = new MetricsStats("CoolEmAllTestbed", "Total_data_center_fans_energy_consumption", -1, timestamp, "Wh"); |
---|
287 | } |
---|
288 | return metric; |
---|
289 | } |
---|
290 | |
---|
291 | private MetricsStats calculateRackEnergyConsumption(){ |
---|
292 | |
---|
293 | MetricsStats metric; |
---|
294 | try{ |
---|
295 | double roomPower = 0; |
---|
296 | for(DCwormsAccumulator acc: metricsData.get("Rack")){ |
---|
297 | roomPower = roomPower + acc.getSum(); |
---|
298 | } |
---|
299 | metric = new MetricsStats("CoolEmAllTestbed", "Total_rack_energy_consumption", roomPower, timestamp, "Wh"); |
---|
300 | } catch (Exception e){ |
---|
301 | metric = new MetricsStats("CoolEmAllTestbed", "Total_rack_energy_consumption", -1, timestamp, "Wh"); |
---|
302 | } |
---|
303 | return metric; |
---|
304 | } |
---|
305 | |
---|
306 | private MetricsStats calculateCoolingDeviceEnergyConsumption(){ |
---|
307 | |
---|
308 | MetricsStats metric; |
---|
309 | try{ |
---|
310 | double coolingDevicePower = 0; |
---|
311 | for(DCwormsAccumulator acc: metricsData.get("CoolingDevice")){ |
---|
312 | coolingDevicePower = coolingDevicePower + acc.getSum(); |
---|
313 | } |
---|
314 | metric = new MetricsStats("CoolEmAllTestbed", "Total_cooling_device_energy_consumption", coolingDevicePower, timestamp, "Wh"); |
---|
315 | } catch (Exception e){ |
---|
316 | metric = new MetricsStats("CoolEmAllTestbed", "Total_cooling_device_energy_consumption", -1, timestamp, "Wh"); |
---|
317 | } |
---|
318 | return metric; |
---|
319 | } |
---|
320 | |
---|
321 | private MetricsStats calculateDataCenterFansEnergyConsumptionOld(){ |
---|
322 | |
---|
323 | MetricsStats metric; |
---|
324 | try{ |
---|
325 | |
---|
326 | double flowPump = 0; |
---|
327 | for(String key: metricsData.keySet()){ |
---|
328 | if(key.contains("FlowPump")){ |
---|
329 | for(DCwormsAccumulator acc: metricsData.get(key)){ |
---|
330 | flowPump = flowPump + acc.getSum(); |
---|
331 | } |
---|
332 | } |
---|
333 | } |
---|
334 | |
---|
335 | metric = new MetricsStats("CoolEmAllTestbed", "Total_data_center_fans_energy_consumption", (flowPump), timestamp, "Wh"); |
---|
336 | } catch (Exception e){ |
---|
337 | metric = new MetricsStats("CoolEmAllTestbed", "Total_data_center_fans_energy_consumption", -1, timestamp, "Wh"); |
---|
338 | } |
---|
339 | return metric; |
---|
340 | } |
---|
341 | |
---|
342 | |
---|
343 | private MetricsStats calculateOtherDevicesEnergyConsumption(){ |
---|
344 | |
---|
345 | MetricsStats metric; |
---|
346 | try{ |
---|
347 | double roomPower = 0; |
---|
348 | for(DCwormsAccumulator acc: metricsData.get("Room")){ |
---|
349 | roomPower = roomPower + acc.getSum(); |
---|
350 | } |
---|
351 | |
---|
352 | double totalSitePower = 0; |
---|
353 | for(DCwormsAccumulator acc: metricsData.get("Rack")){ |
---|
354 | totalSitePower = totalSitePower + acc.getSum(); |
---|
355 | } |
---|
356 | |
---|
357 | double coolingDevicePower = 0; |
---|
358 | for(DCwormsAccumulator acc: metricsData.get("CoolingDevice")){ |
---|
359 | coolingDevicePower = coolingDevicePower + acc.getSum(); |
---|
360 | } |
---|
361 | |
---|
362 | double inletsPower = 0; |
---|
363 | for(DCwormsAccumulator acc: metricsData.get("Inlet")){ |
---|
364 | inletsPower = inletsPower + acc.getSum(); |
---|
365 | } |
---|
366 | |
---|
367 | double outletsPower = 0; |
---|
368 | for(DCwormsAccumulator acc: metricsData.get("Outlet")){ |
---|
369 | outletsPower = outletsPower + acc.getSum(); |
---|
370 | } |
---|
371 | |
---|
372 | double nodeComputingPower = 0; |
---|
373 | for(DCwormsAccumulator acc: metricsData.get("Node")){ |
---|
374 | nodeComputingPower = nodeComputingPower+ acc.getSum(); |
---|
375 | } |
---|
376 | double itComputingPower = 0; |
---|
377 | for(DCwormsAccumulator acc: metricsData.get("Processor")){ |
---|
378 | itComputingPower = itComputingPower + acc.getSum(); |
---|
379 | } |
---|
380 | double nodeGroupFansPowerConumspion = nodeComputingPower - itComputingPower; |
---|
381 | |
---|
382 | metric = new MetricsStats("CoolEmAllTestbed", "Total_other_devices_energy_consumption", roomPower - (totalSitePower + coolingDevicePower + (inletsPower + outletsPower - nodeGroupFansPowerConumspion)), timestamp, "Wh"); |
---|
383 | } catch (Exception e){ |
---|
384 | metric = new MetricsStats("CoolEmAllTestbed", "Total_other_devices_energy_consumption", -1, timestamp, "Wh"); |
---|
385 | } |
---|
386 | return metric; |
---|
387 | } |
---|
388 | |
---|
389 | |
---|
390 | private MetricsStats calculateMeanPower(){ |
---|
391 | |
---|
392 | MetricsStats metric; |
---|
393 | try{ |
---|
394 | |
---|
395 | double roomPower = 0; |
---|
396 | for(DCwormsAccumulator acc: metricsData.get("Room")){ |
---|
397 | roomPower = roomPower + acc.getSum(); |
---|
398 | } |
---|
399 | metric = new MetricsStats("CoolEmAllTestbed", "Mean_power", roomPower/((this.endTime - this.startTime)/(SEC_IN_HOUR * MILLI_SEC)), timestamp, "W"); |
---|
400 | } catch (Exception e){ |
---|
401 | metric = new MetricsStats("CoolEmAllTestbed", "Mean_power", -1, timestamp, "W"); |
---|
402 | } |
---|
403 | return metric; |
---|
404 | } |
---|
405 | |
---|
406 | |
---|
407 | private MetricsStats calculateMeanRackPower(){ |
---|
408 | |
---|
409 | MetricsStats metric; |
---|
410 | try{ |
---|
411 | |
---|
412 | double roomPower = 0; |
---|
413 | for(DCwormsAccumulator acc: metricsData.get("Rack")){ |
---|
414 | roomPower = roomPower + acc.getSum(); |
---|
415 | } |
---|
416 | metric = new MetricsStats("CoolEmAllTestbed", "Mean_rack_power", roomPower/((this.endTime - this.startTime)/(SEC_IN_HOUR * MILLI_SEC)), timestamp, "W"); |
---|
417 | } catch (Exception e){ |
---|
418 | metric = new MetricsStats("CoolEmAllTestbed", "Mean_rack_power", -1, timestamp, "W"); |
---|
419 | } |
---|
420 | return metric; |
---|
421 | } |
---|
422 | |
---|
423 | private MetricsStats calculateEnergyWasteRate(){ |
---|
424 | |
---|
425 | MetricsStats metric; |
---|
426 | try{ |
---|
427 | double itComputingEnergy = 0; |
---|
428 | |
---|
429 | for(DCwormsAccumulator acc: metricsData.get("Processor_CALC")){ |
---|
430 | itComputingEnergy = itComputingEnergy + acc.getSum(); |
---|
431 | } |
---|
432 | |
---|
433 | double itEnergy = calculateITEnergyConsumption().getValue(); |
---|
434 | |
---|
435 | metric = new MetricsStats("CoolEmAllTestbed", "Energy_waste_rate", (1 - itComputingEnergy/itEnergy) * 100, timestamp, "%"); |
---|
436 | } catch (Exception e){ |
---|
437 | metric = new MetricsStats("CoolEmAllTestbed", "Energy_waste_rate", -1, timestamp, "%"); |
---|
438 | } |
---|
439 | |
---|
440 | return metric; |
---|
441 | } |
---|
442 | |
---|
443 | } |
---|