Ignore:
Timestamp:
03/19/14 18:22:27 (11 years ago)
Author:
wojtekp
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • DCWoRMS/branches/coolemall/src/simulator/stats/MetricsCalculator.java

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