source: DCWoRMS/branches/coolemall/src/test/simpat/SimpatMetricsCalculator.java @ 1469

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