Exemplo n.º 1
0
  private String makeStats(Map<String, TaskStats> taskCounts, boolean includeTaskDetails) {
    // We want <# map tasks><tab><# reduce tasks><tab><task details>
    // where <task details> looks like <flowname|stepname=mapcount,reducecount;
    // flowname|stepname=mapcount,reducecount>
    int mapCount = 0;
    int reduceCount = 0;
    StringBuilder taskDetails = new StringBuilder();

    for (TaskStats stats : taskCounts.values()) {

      if ((stats.getMapCount() == 0) && (stats.getReduceCount() == 0)) {
        // TODO Figure out why we don't get any total map/reduce time values.
        // taskDetails.append(String.format("%s|%s=%dms,%dms; ", stats.getFlowName(),
        // stats.getStepName(), stats.getMapTime(), stats.getReduceTime()));
      } else {
        mapCount += stats.getMapCount();
        reduceCount += stats.getReduceCount();

        if (includeTaskDetails) {
          taskDetails.append(
              String.format(
                  "%s|%s=%d,%d; ",
                  stats.getFlowName(),
                  stats.getStepName(),
                  stats.getMapCount(),
                  stats.getReduceCount()));
        }
      }
    }

    return String.format("%d\t%d\t%s", mapCount, reduceCount, taskDetails.toString());
  }