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