MAPREDUCE-6720. Inconsistent values of counters across tasks and job reported to timeline service. Contributed by Varun Saxena

This commit is contained in:
Naganarasimha 2016-06-22 23:32:19 +05:30 committed by Sangjin Lee
parent 6d943038f6
commit 8bf87eede2
3 changed files with 16 additions and 7 deletions

View File

@ -1125,6 +1125,10 @@ private void processEventForTimelineServer(HistoryEvent event, JobId jobId,
org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity entity =
createBaseEntity(event, timestamp, entityType, setCreatedTime);
entity.setId(taskId);
if (event.getEventType() == EventType.TASK_STARTED) {
entity.addInfo("TASK_TYPE",
((TaskStartedEvent)event).getTaskType().toString());
}
entity.addIsRelatedToEntity(relatedJobEntity, jobId.toString());
return entity;
}

View File

@ -158,12 +158,12 @@ public TimelineEvent toTimelineEvent() {
@Override
public Set<TimelineMetric> getTimelineMetrics() {
Set<TimelineMetric> jobMetrics = JobHistoryEventUtils
.countersToTimelineMetric(getMapCounters(), finishTime);
jobMetrics.addAll(JobHistoryEventUtils
.countersToTimelineMetric(getReduceCounters(), finishTime));
jobMetrics.addAll(JobHistoryEventUtils
.countersToTimelineMetric(getTotalCounters(), finishTime));
Set<TimelineMetric> jobMetrics = JobHistoryEventUtils.
countersToTimelineMetric(getTotalCounters(), finishTime);
jobMetrics.addAll(JobHistoryEventUtils.
countersToTimelineMetric(getMapCounters(), finishTime, "MAP:"));
jobMetrics.addAll(JobHistoryEventUtils.
countersToTimelineMetric(getReduceCounters(), finishTime, "REDUCE:"));
return jobMetrics;
}
}

View File

@ -61,11 +61,16 @@ public static JsonNode countersToJSON(Counters counters) {
public static Set<TimelineMetric> countersToTimelineMetric(Counters counters,
long timestamp) {
return countersToTimelineMetric(counters, timestamp, "");
}
public static Set<TimelineMetric> countersToTimelineMetric(Counters counters,
long timestamp, String groupNamePrefix) {
Set<TimelineMetric> entityMetrics = new HashSet<TimelineMetric>();
for (CounterGroup g : counters) {
String groupName = g.getName();
for (Counter c : g) {
String name = groupName + ":" + c.getName();
String name = groupNamePrefix + groupName + ":" + c.getName();
TimelineMetric metric = new TimelineMetric();
metric.setId(name);
metric.addValue(timestamp, c.getValue());