tez-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jl...@apache.org
Subject tez git commit: TEZ-3940. Reduce time to convert TaskFinishedEvent to string (Jonathan Eagles via jlowe)
Date Thu, 24 May 2018 14:00:24 GMT
Repository: tez
Updated Branches:
  refs/heads/branch-0.9 15d853787 -> fa5c9f3a4


TEZ-3940. Reduce time to convert TaskFinishedEvent to string (Jonathan Eagles via jlowe)

(cherry picked from commit 7111078e98bddd26520a2f89cfc5c161f669ceea)


Project: http://git-wip-us.apache.org/repos/asf/tez/repo
Commit: http://git-wip-us.apache.org/repos/asf/tez/commit/fa5c9f3a
Tree: http://git-wip-us.apache.org/repos/asf/tez/tree/fa5c9f3a
Diff: http://git-wip-us.apache.org/repos/asf/tez/diff/fa5c9f3a

Branch: refs/heads/branch-0.9
Commit: fa5c9f3a43271e8fa8573d9aee1af37888dcdec5
Parents: 15d8537
Author: Jason Lowe <jlowe@apache.org>
Authored: Thu May 24 08:44:03 2018 -0500
Committer: Jason Lowe <jlowe@apache.org>
Committed: Thu May 24 08:48:21 2018 -0500

----------------------------------------------------------------------
 .../events/TaskAttemptFinishedEvent.java        | 81 +++++++++++++++-----
 .../dag/history/events/TaskFinishedEvent.java   | 48 +++++++++---
 2 files changed, 98 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tez/blob/fa5c9f3a/tez-dag/src/main/java/org/apache/tez/dag/history/events/TaskAttemptFinishedEvent.java
----------------------------------------------------------------------
diff --git a/tez-dag/src/main/java/org/apache/tez/dag/history/events/TaskAttemptFinishedEvent.java
b/tez-dag/src/main/java/org/apache/tez/dag/history/events/TaskAttemptFinishedEvent.java
index 96dc099..1859649 100644
--- a/tez-dag/src/main/java/org/apache/tez/dag/history/events/TaskAttemptFinishedEvent.java
+++ b/tez-dag/src/main/java/org/apache/tez/dag/history/events/TaskAttemptFinishedEvent.java
@@ -25,6 +25,8 @@ import java.util.List;
 import com.google.protobuf.CodedInputStream;
 import com.google.protobuf.CodedOutputStream;
 import org.apache.tez.common.TezConverterUtils;
+import org.apache.tez.common.counters.CounterGroup;
+import org.apache.tez.common.counters.TezCounter;
 import org.apache.tez.runtime.api.TaskFailureType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -241,27 +243,68 @@ public class TaskAttemptFinishedEvent implements HistoryEvent {
 
   @Override
   public String toString() {
-    String counterStr = "";
+    StringBuilder sb = new StringBuilder();
+    sb.append("vertexName=");
+    sb.append(vertexName);
+    sb.append(", taskAttemptId=");
+    sb.append(taskAttemptId);
+    sb.append(", creationTime=");
+    sb.append(creationTime);
+    sb.append(", allocationTime=");
+    sb.append(allocationTime);
+    sb.append(", startTime=");
+    sb.append(startTime);
+    sb.append(", finishTime=");
+    sb.append(finishTime);
+    sb.append(", timeTaken=");
+    sb.append(finishTime - startTime);
+    sb.append(", status=");
+    sb.append(state.name());
+
+    if (taskFailureType != null) {
+      sb.append(", taskFailureType=");
+      sb.append(taskFailureType);
+    }
+    if (error != null) {
+      sb.append(", errorEnum=");
+      sb.append(error);
+    }
+    if (diagnostics != null) {
+      sb.append(", diagnostics=");
+      sb.append(diagnostics);
+    }
+    if (containerId != null) {
+      sb.append(", containerId=");
+      sb.append(containerId);
+    }
+    if (nodeId != null) {
+      sb.append(", nodeId=");
+      sb.append(nodeId);
+    }
+    if (nodeHttpAddress != null) {
+      sb.append(", nodeHttpAddress=");
+      sb.append(nodeHttpAddress);
+    }
+
     if (state != TaskAttemptState.SUCCEEDED) {
-      counterStr = ", counters=" + ( tezCounters == null ? "null" :
-        tezCounters.toString()
-        .replaceAll("\\n", ", ").replaceAll("\\s+", " "));
+      sb.append(", counters=");
+      if (tezCounters == null) {
+        sb.append("null");
+      } else {
+        sb.append("Counters: ");
+        sb.append(tezCounters.countCounters());
+        for (CounterGroup group : tezCounters) {
+          sb.append(", ");
+          sb.append(group.getDisplayName());
+          for (TezCounter counter : group) {
+            sb.append(", ");
+            sb.append(counter.getDisplayName()).append("=")
+                .append(counter.getValue());
+          }
+        }
+      }
     }
-    return "vertexName=" + vertexName
-        + ", taskAttemptId=" + taskAttemptId
-        + ", creationTime=" + creationTime
-        + ", allocationTime=" + allocationTime
-        + ", startTime=" + startTime
-        + ", finishTime=" + finishTime
-        + ", timeTaken=" + (finishTime - startTime)
-        + ", status=" + state.name()
-        + (taskFailureType != null ? ", taskFailureType=" + taskFailureType : "")
-        + (error != null ? ", errorEnum=" + error.name() : "")
-        + (diagnostics != null ? ", diagnostics=" + diagnostics : "")
-        + (containerId != null ? ", containerId=" + containerId.toString() : "")
-        + (nodeId != null ? ", nodeId=" + nodeId.toString() : "")
-        + (nodeHttpAddress != null ? ", nodeHttpAddress=" + nodeHttpAddress : "")
-        + counterStr;
+    return sb.toString();
   }
 
   public TezTaskAttemptID getTaskAttemptID() {

http://git-wip-us.apache.org/repos/asf/tez/blob/fa5c9f3a/tez-dag/src/main/java/org/apache/tez/dag/history/events/TaskFinishedEvent.java
----------------------------------------------------------------------
diff --git a/tez-dag/src/main/java/org/apache/tez/dag/history/events/TaskFinishedEvent.java
b/tez-dag/src/main/java/org/apache/tez/dag/history/events/TaskFinishedEvent.java
index 6befa1a..dd7afdf 100644
--- a/tez-dag/src/main/java/org/apache/tez/dag/history/events/TaskFinishedEvent.java
+++ b/tez-dag/src/main/java/org/apache/tez/dag/history/events/TaskFinishedEvent.java
@@ -22,6 +22,8 @@ import java.io.IOException;
 
 import com.google.protobuf.CodedInputStream;
 import com.google.protobuf.CodedOutputStream;
+import org.apache.tez.common.counters.CounterGroup;
+import org.apache.tez.common.counters.TezCounter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.tez.common.counters.TezCounters;
@@ -122,18 +124,40 @@ public class TaskFinishedEvent implements HistoryEvent {
 
   @Override
   public String toString() {
-    return "vertexName=" + vertexName
-        + ", taskId=" + taskID
-        + ", startTime=" + startTime
-        + ", finishTime=" + finishTime
-        + ", timeTaken=" + (finishTime - startTime)
-        + ", status=" + state.name()
-        + ", successfulAttemptID=" + (successfulAttemptID == null ? "null" :
-            successfulAttemptID.toString())
-        + ", diagnostics=" + diagnostics
-        + ", counters=" + ( tezCounters == null ? "null" :
-          tezCounters.toString()
-            .replaceAll("\\n", ", ").replaceAll("\\s+", " "));
+    StringBuilder sb = new StringBuilder();
+    sb.append("vertexName=");
+    sb.append(vertexName);
+    sb.append(", taskId=");
+    sb.append(taskID);
+    sb.append(", startTime=");
+    sb.append(startTime);
+    sb.append(", finishTime=");
+    sb.append(finishTime);
+    sb.append(", timeTaken=");
+    sb.append(finishTime - startTime);
+    sb.append(", status=");
+    sb.append(state.name());
+    sb.append(", successfulAttemptID=");
+    sb.append(successfulAttemptID);
+    sb.append(", diagnostics=");
+    sb.append(diagnostics);
+    sb.append(", counters=");
+    if (tezCounters == null) {
+      sb.append("null");
+    } else {
+      sb.append("Counters: ");
+      sb.append(tezCounters.countCounters());
+      for (CounterGroup group : tezCounters) {
+        sb.append(", ");
+        sb.append(group.getDisplayName());
+        for (TezCounter counter : group) {
+          sb.append(", ");
+          sb.append(counter.getDisplayName()).append("=")
+              .append(counter.getValue());
+        }
+      }
+    }
+    return sb.toString();
   }
 
   public TezTaskID getTaskID() {


Mime
View raw message