private void incrementCounts( Map<String, TaskStats> counts, String countsKey, String flowName, String stepName, int mapCount, int reduceCount, long mapTime, long reduceTime) { // If they're all zero, just ignore the call so we don't get extra entries. if ((mapCount == 0) && (reduceCount == 0) && (mapTime == 0) && (reduceTime == 0)) { return; } TaskStats curStats = counts.get(countsKey); if (curStats == null) { curStats = new TaskStats(flowName, stepName); } curStats.incMapCount(mapCount); curStats.incReduceCount(reduceCount); curStats.incMapTime(mapTime); curStats.incReduceTime(reduceTime); counts.put(countsKey, curStats); }
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()); }
/** mark the end of a task */ public synchronized void markTaskEnd(TaskStats stats, int count) { int numParallelTasks = nextTaskRunNum - 1 - stats.getTaskRunNum(); // note: if the stats were cleared, might be that this stats object is // no longer in points, but this is just ok. stats.markEnd(numParallelTasks, count); }