You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@tez.apache.org by GitBox <gi...@apache.org> on 2021/08/06 06:44:29 UTC

[GitHub] [tez] abstractdog commented on a change in pull request #123: TEZ-4231: SimpleHistoryParser doesn't merge events correctly

abstractdog commented on a change in pull request #123:
URL: https://github.com/apache/tez/pull/123#discussion_r683987369



##########
File path: tez-tools/analyzers/job-analyzer/src/main/java/org/apache/tez/analyzer/plugins/TaskHangAnalyzer.java
##########
@@ -0,0 +1,137 @@
+/**
+ * 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 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.TaskAttemptInfo;
+import org.apache.tez.history.parser.datamodel.VertexInfo;
+
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Get the Task assignments on different nodes of the cluster.
+ */
+public class TaskHangAnalyzer extends TezAnalyzerBase implements Analyzer {
+  private final String[] headers = { "vertex", "task", " number_of_attempts", "last_attempt_id",
+      "last_attempt_status", "last_attempt_duration_ms", "last_attempt_node" };
+  private final CSVResult csvResult;
+
+  public TaskHangAnalyzer(Configuration config) {
+    super(config);
+    csvResult = new CSVResult(headers);
+  }
+
+  @Override
+  public void analyze(DagInfo dagInfo) throws TezException {
+    Map<String, Map<String, String>> taskData = new HashMap<>(); // task attempt count per task
+    for (VertexInfo vertex : dagInfo.getVertices()) {
+      taskData.clear();
+      for (TaskAttemptInfo attempt : vertex.getTaskAttempts()) {
+        String taskId = attempt.getTaskInfo().getTaskId();
+
+        int numAttemptsForTask = attempt.getTaskInfo().getNumberOfTaskAttempts();
+        Map<String, String> thisTaskData = taskData.get(taskId);
+
+        if (thisTaskData == null) {
+          thisTaskData = new HashMap<>();
+          thisTaskData.put("num_attempts", Integer.toString(numAttemptsForTask));
+          taskData.put(taskId, thisTaskData);
+        }
+
+        // attempt_1599682376162_0006_27_00_000086_1
+        int attemptNumber = Integer.parseInt(attempt.getTaskAttemptId().split("_")[6]);

Review comment:
       oh, right, what a hack this parseInt was :)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@tez.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org