From c01d15ab2731b6710c94ff3bfa37d496a87b0c9f Mon Sep 17 00:00:00 2001 From: Junping Du Date: Tue, 21 Mar 2017 00:28:05 -0700 Subject: [PATCH] YARN-6367. YARN logs CLI needs alway check containerLogsInfo/containerLogInfo before parse the JSON object from NMWebService. Contributed by Xuan Gong. --- .../java/org/apache/hadoop/yarn/client/cli/LogsCLI.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/LogsCLI.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/LogsCLI.java index 8407b1930d..4125a81f00 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/LogsCLI.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/LogsCLI.java @@ -430,6 +430,9 @@ private List> getContainerLogFiles( try { JSONArray array = new JSONArray(); JSONObject json = response.getEntity(JSONObject.class); + if (!json.has("containerLogsInfo")) { + return logFileInfos; + } Object logsInfoObj = json.get("containerLogsInfo"); if (logsInfoObj instanceof JSONObject) { array.put((JSONObject)logsInfoObj); @@ -443,6 +446,9 @@ private List> getContainerLogFiles( JSONObject log = array.getJSONObject(i); String aggregateType = log.has("logAggregationType") ? log.getString("logAggregationType") : "N/A"; + if (!log.has("containerLogInfo")) { + continue; + } Object ob = log.get("containerLogInfo"); if (ob instanceof JSONArray) { JSONArray obArray = (JSONArray)ob;