Repository: tez Updated Branches: refs/heads/master 00508f898 -> cb0890d58
TEZ-2799. SimpleHistoryParser NPE (rbalamohan) Project: http://git-wip-us.apache.org/repos/asf/tez/repo Commit: http://git-wip-us.apache.org/repos/asf/tez/commit/cb0890d5 Tree: http://git-wip-us.apache.org/repos/asf/tez/tree/cb0890d5 Diff: http://git-wip-us.apache.org/repos/asf/tez/diff/cb0890d5 Branch: refs/heads/master Commit: cb0890d58ae5639522aefe765e99e6d70f211fc7 Parents: 00508f8 Author: Rajesh Balamohan <[email protected]> Authored: Thu Sep 10 19:11:37 2015 +0530 Committer: Rajesh Balamohan <[email protected]> Committed: Thu Sep 10 19:11:37 2015 +0530 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../tez/history/parser/SimpleHistoryParser.java | 49 +++++++++++--------- 2 files changed, 29 insertions(+), 21 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tez/blob/cb0890d5/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 2439370..6310134 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -7,6 +7,7 @@ Release 0.8.1: Unreleased INCOMPATIBLE CHANGES ALL CHANGES: + TEZ-2799. SimpleHistoryParser NPE TEZ-2643. Minimize number of empty spills in Pipelined Sorter TEZ-2783. Refactor analyzers to extend TezAnalyzerBase TEZ-2784. optimize TaskImpl.isFinished() http://git-wip-us.apache.org/repos/asf/tez/blob/cb0890d5/tez-plugins/tez-history-parser/src/main/java/org/apache/tez/history/parser/SimpleHistoryParser.java ---------------------------------------------------------------------- diff --git a/tez-plugins/tez-history-parser/src/main/java/org/apache/tez/history/parser/SimpleHistoryParser.java b/tez-plugins/tez-history-parser/src/main/java/org/apache/tez/history/parser/SimpleHistoryParser.java index 09c010a..863cc40 100644 --- a/tez-plugins/tez-history-parser/src/main/java/org/apache/tez/history/parser/SimpleHistoryParser.java +++ b/tez-plugins/tez-history-parser/src/main/java/org/apache/tez/history/parser/SimpleHistoryParser.java @@ -32,6 +32,7 @@ import org.apache.tez.history.parser.datamodel.DagInfo; import org.apache.tez.history.parser.datamodel.TaskAttemptInfo; import org.apache.tez.history.parser.datamodel.TaskInfo; import org.apache.tez.history.parser.datamodel.VertexInfo; +import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONObject; import org.slf4j.Logger; @@ -204,30 +205,36 @@ public class SimpleHistoryParser extends BaseParser { * "entitytype":"containerId"} and populate it in otherInfo object so that in-memory * representation can parse it correctly */ - JSONObject subJsonObject = jsonObject.optJSONArray(Constants.RELATED_ENTITIES) - .optJSONObject(0); - if (subJsonObject != null) { - String nodeId = subJsonObject.optString(Constants.ENTITY_TYPE); - if (!Strings.isNullOrEmpty(nodeId) && nodeId.equalsIgnoreCase(Constants.NODE_ID)) { - //populate it in otherInfo - JSONObject otherInfo = jsonObject.optJSONObject(Constants.OTHER_INFO); - String nodeIdVal = subJsonObject.optString(Constants.ENTITY); - if (otherInfo != null && nodeIdVal != null) { - otherInfo.put(Constants.NODE_ID, nodeIdVal); + JSONArray relatedEntities = jsonObject.optJSONArray(Constants.RELATED_ENTITIES); + if (relatedEntities == null) { + //This can happen when CONTAINER_EXITED abruptly. (e.g Container failed, exitCode=1) + LOG.debug("entity {} did not have related entities", + jsonObject.optJSONObject(Constants.ENTITY)); + } else { + JSONObject subJsonObject = relatedEntities.optJSONObject(0); + if (subJsonObject != null) { + String nodeId = subJsonObject.optString(Constants.ENTITY_TYPE); + if (!Strings.isNullOrEmpty(nodeId) && nodeId.equalsIgnoreCase(Constants.NODE_ID)) { + //populate it in otherInfo + JSONObject otherInfo = jsonObject.optJSONObject(Constants.OTHER_INFO); + String nodeIdVal = subJsonObject.optString(Constants.ENTITY); + if (otherInfo != null && nodeIdVal != null) { + otherInfo.put(Constants.NODE_ID, nodeIdVal); + } } } - } - subJsonObject = jsonObject.optJSONArray(Constants.RELATED_ENTITIES) - .optJSONObject(1); - if (subJsonObject != null) { - String containerId = subJsonObject.optString(Constants.ENTITY_TYPE); - if (!Strings.isNullOrEmpty(containerId) && containerId.equalsIgnoreCase(Constants.CONTAINER_ID)) { - //populate it in otherInfo - JSONObject otherInfo = jsonObject.optJSONObject(Constants.OTHER_INFO); - String containerIdVal = subJsonObject.optString(Constants.ENTITY); - if (otherInfo != null && containerIdVal != null) { - otherInfo.put(Constants.CONTAINER_ID, containerIdVal); + subJsonObject = relatedEntities.optJSONObject(1); + if (subJsonObject != null) { + String containerId = subJsonObject.optString(Constants.ENTITY_TYPE); + if (!Strings.isNullOrEmpty(containerId) && containerId + .equalsIgnoreCase(Constants.CONTAINER_ID)) { + //populate it in otherInfo + JSONObject otherInfo = jsonObject.optJSONObject(Constants.OTHER_INFO); + String containerIdVal = subJsonObject.optString(Constants.ENTITY); + if (otherInfo != null && containerIdVal != null) { + otherInfo.put(Constants.CONTAINER_ID, containerIdVal); + } } } }
