-
Notifications
You must be signed in to change notification settings - Fork 440
TEZ-4231: SimpleHistoryParser doesn't merge events correctly #123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -556,12 +556,12 @@ private static JSONObject convertTaskFinishedEvent(HistoryEventProto event) thro | |
| events.put(finishEvent); | ||
| jsonObject.put(ATSConstants.EVENTS, events); | ||
|
|
||
| long startTime = getLongDataValueByKey(event, ATSConstants.START_TIME); | ||
| long timeTaken = getLongDataValueByKey(event, ATSConstants.TIME_TAKEN); | ||
|
|
||
| JSONObject otherInfo = new JSONObject(); | ||
| otherInfo.put(ATSConstants.START_TIME, startTime); | ||
| otherInfo.put(ATSConstants.START_TIME, event.getEventTime() - timeTaken); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIRC, there were corner cases where events will not be properly populated. May be in cases, where vertices were shutdown due to errors or so (need to check). In such cases, this would have returned "-ve" value earlier. Current patch seem to change the start_time, depending on getEventTime. This could give a perspective that the task/vertex was there for very short time. Can you plz share more info on prev error? Were you getting -ve values earlier for which this is being modified?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually, I saw this for all protobuf history files, that's why I'm not suspecting corner case this string is what the debugger writes for a HistoryLoggerProtos$HistoryEventProto instance while doing this conversion: the root cause of this behavior would be: here I can see the builder consumes only event.getFinishTime() for the "time" parameter, and startTime is shipped indirectly...according to blame, this code part is unchanged since the introduction of proto history logger (TEZ-3915)
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the note. Earlier code didn't populate START_TIME (& had only timeTaken) causing the issue. |
||
| otherInfo.put(ATSConstants.FINISH_TIME, event.getEventTime()); | ||
| otherInfo.put(ATSConstants.TIME_TAKEN, event.getEventTime() - startTime); | ||
| otherInfo.put(ATSConstants.TIME_TAKEN, timeTaken); | ||
|
|
||
| otherInfo.put(ATSConstants.STATUS, getDataValueByKey(event, ATSConstants.STATUS)); | ||
| otherInfo.put(ATSConstants.DIAGNOSTICS, getDataValueByKey(event, ATSConstants.DIAGNOSTICS)); | ||
|
|
@@ -620,11 +620,13 @@ private static JSONObject convertVertexFinishedEvent(HistoryEventProto event) | |
| events.put(finishEvent); | ||
| jsonObject.put(ATSConstants.EVENTS, events); | ||
|
|
||
| long startTime = getLongDataValueByKey(event, ATSConstants.START_TIME); | ||
| long timeTaken = getLongDataValueByKey(event, ATSConstants.TIME_TAKEN); | ||
|
|
||
| JSONObject otherInfo = new JSONObject(); | ||
| otherInfo.put(ATSConstants.START_TIME, event.getEventTime() - timeTaken); | ||
| otherInfo.put(ATSConstants.FINISH_TIME, event.getEventTime()); | ||
| otherInfo.put(ATSConstants.TIME_TAKEN, (event.getEventTime() - startTime)); | ||
| otherInfo.put(ATSConstants.TIME_TAKEN, timeTaken); | ||
|
|
||
| otherInfo.put(ATSConstants.STATUS, getDataValueByKey(event, ATSConstants.STATUS)); | ||
| otherInfo.put(ATSConstants.DIAGNOSTICS, getDataValueByKey(event, ATSConstants.DIAGNOSTICS)); | ||
| otherInfo.put(ATSConstants.COUNTERS, getJSONDataValueByKey(event, ATSConstants.COUNTERS)); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| /** | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * <p/> | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * <p/> | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.tez.analyzer.plugins; | ||
|
|
||
| import java.text.SimpleDateFormat; | ||
| import java.util.Comparator; | ||
| import java.util.Date; | ||
|
|
||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.hadoop.util.ToolRunner; | ||
| import org.apache.tez.analyzer.Analyzer; | ||
| import org.apache.tez.analyzer.CSVResult; | ||
| import org.apache.tez.analyzer.Result; | ||
| import org.apache.tez.dag.api.TezException; | ||
| import org.apache.tez.history.parser.datamodel.DagInfo; | ||
| import org.apache.tez.history.parser.datamodel.Event; | ||
| import org.apache.tez.history.parser.datamodel.TaskAttemptInfo; | ||
| import org.apache.tez.history.parser.datamodel.TaskInfo; | ||
| import org.apache.tez.history.parser.datamodel.VertexInfo; | ||
|
|
||
| public class DagOverviewAnalyzer extends TezAnalyzerBase implements Analyzer { | ||
| private final String[] headers = | ||
| { "name", "id", "event_type", "status", "event_time", "event_time_str", "diagnostics" }; | ||
|
||
| private final CSVResult csvResult; | ||
| private static final SimpleDateFormat FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); | ||
|
|
||
| public DagOverviewAnalyzer(Configuration config) { | ||
| super(config); | ||
| csvResult = new CSVResult(headers); | ||
| } | ||
|
|
||
| @Override | ||
| public void analyze(DagInfo dagInfo) throws TezException { | ||
| for (Event event : dagInfo.getEvents()) { | ||
| csvResult.addRecord(new String[] { dagInfo.getDagId(), dagInfo.getDagId(), event.getType(), | ||
| dagInfo.getStatus(), Long.toString(event.getTime()), toDateStr(event.getTime()), "" }); | ||
| } | ||
| for (VertexInfo vertex : dagInfo.getVertices()) { | ||
| for (Event event : vertex.getEvents()) { | ||
| String vertexFailureInfoIfAny = ""; | ||
| for (TaskAttemptInfo attempt : vertex.getTaskAttempts()) { | ||
| if (attempt.getStatus().contains("FAILED")) { | ||
| vertexFailureInfoIfAny = attempt.getTaskAttemptId() + ": " | ||
| + attempt.getDiagnostics().replaceAll(",", " ").replaceAll("\n", " "); | ||
| break; | ||
| } | ||
| } | ||
| csvResult.addRecord(new String[] { vertex.getVertexName(), vertex.getVertexId(), | ||
| event.getType(), vertex.getStatus(), Long.toString(event.getTime()), | ||
| toDateStr(event.getTime()), vertexFailureInfoIfAny }); | ||
| } | ||
|
|
||
| // a failed task can lead to dag failure, so hopefully holds valuable information | ||
| for (TaskInfo failedTask : vertex.getFailedTasks()) { | ||
| for (Event failedTaskEvent : failedTask.getEvents()) { | ||
| if (failedTaskEvent.getType().equalsIgnoreCase("TASK_FINISHED")) { | ||
| csvResult.addRecord(new String[] { vertex.getVertexName(), failedTask.getTaskId(), | ||
| failedTaskEvent.getType(), failedTask.getStatus(), | ||
| Long.toString(failedTaskEvent.getTime()), toDateStr(failedTaskEvent.getTime()), | ||
| failedTask.getDiagnostics().replaceAll(",", " ").replaceAll("\n", " ") }); | ||
| } | ||
| } | ||
| // if we already found a failing task, let's scan the failing attempts as well | ||
| for (TaskAttemptInfo failedAttempt : failedTask.getFailedTaskAttempts()) { | ||
| for (Event failedTaskAttemptEvent : failedAttempt.getEvents()) { | ||
| if (failedTaskAttemptEvent.getType().equalsIgnoreCase("TASK_ATTEMPT_FINISHED")) { | ||
| csvResult.addRecord(new String[] { vertex.getVertexName(), | ||
| failedAttempt.getTaskAttemptId(), failedTaskAttemptEvent.getType(), | ||
| failedAttempt.getStatus(), Long.toString(failedTaskAttemptEvent.getTime()), | ||
| toDateStr(failedTaskAttemptEvent.getTime()), | ||
| failedAttempt.getDiagnostics().replaceAll(",", " ").replaceAll("\n", " ") }); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| csvResult.sort(new Comparator<String[]>() { | ||
| public int compare(String[] first, String[] second) { | ||
| return (int) (Long.parseLong(first[4]) - Long.parseLong(second[4])); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| private static synchronized String toDateStr(long time) { | ||
| return FORMAT.format(new Date(time)); | ||
| } | ||
|
|
||
| @Override | ||
| public Result getResult() throws TezException { | ||
| return csvResult; | ||
| } | ||
|
|
||
| @Override | ||
| public String getName() { | ||
| return "Dag overview analyzer"; | ||
| } | ||
|
|
||
| @Override | ||
| public String getDescription() { | ||
| return "High level dag events overview (dag, vertex event summary)." | ||
| + " Helps understand the overall progress of a dag by simply listing the dag/vertex related events"; | ||
| } | ||
|
|
||
| public static void main(String[] args) throws Exception { | ||
| Configuration config = new Configuration(); | ||
| DagOverviewAnalyzer analyzer = new DagOverviewAnalyzer(config); | ||
| int res = ToolRunner.run(config, analyzer, args); | ||
| analyzer.printResults(); | ||
| System.exit(res); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: fix indent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure