@Override
  public void aggregate(HadoopApplicationData data) {
    _hadoopAggregatedData = new HadoopAggregatedData();

    TonyApplicationData tonyData = (TonyApplicationData) data;
    Configuration tonyConf = tonyData.getConfiguration();

    long mbSecUsed = 0;
    long mbSecWasted = 0;

    Map<String, Map<Integer, TonyTaskData>> taskMap = tonyData.getTaskMap();
    for (Map.Entry<String, Map<Integer, TonyTaskData>> entry : taskMap.entrySet()) {
      String taskType = entry.getKey();

      String memoryString = tonyConf.get(TonyConfigurationKeys.getResourceKey(taskType, Constants.MEMORY));
      String memoryStringMB = com.linkedin.tony.util.Utils.parseMemoryString(memoryString);
      long mbRequested = Long.parseLong(memoryStringMB);
      double maxMemoryMBUsed = TonyUtils.getMaxMetricForTaskTypeAndMetricName(taskMap, taskType,
          Constants.MAX_MEMORY_BYTES) / FileUtils.ONE_MB;

      for (TonyTaskData taskData : entry.getValue().values()) {
        long taskDurationSec = (taskData.getTaskEndTime() - taskData.getTaskStartTime()) / Statistics.SECOND_IN_MS;
        if (taskDurationSec < 0) {
          // Most likely TASK_FINISHED and APPLICATION_FINISHED events are missing for the task.
          continue;
        }
        mbSecUsed += mbRequested * taskDurationSec;

        if (maxMemoryMBUsed == 0) {
          // If we don't have max memory metrics, don't calculate wasted memory.
          continue;
        }
        long wastedMemory = (long) (mbRequested - maxMemoryMBUsed * MEMORY_BUFFER);
        if (wastedMemory > 0) {
          mbSecWasted += wastedMemory * taskDurationSec;
        }
      }
    }

    _hadoopAggregatedData.setResourceUsed(mbSecUsed);
    _hadoopAggregatedData.setResourceWasted(mbSecWasted);
    // TODO: Calculate and set delay
  }
Creates a new {@code TonyMetricsAggregator}.
@param unused  Dr. Elephant expects a constructor of this form but {@code TonyMetricsAggregator} does not need this
app/com/linkedin/drelephant/tony/TonyMetricsAggregator.java