YARN-6367. YARN logs CLI needs alway check containerLogsInfo/containerLogInfo before parse the JSON object from NMWebService. Contributed by Xuan Gong.

(cherry picked from commit c01d15ab27)

Conflicts:

	hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/LogsCLI.java
This commit is contained in:
Junping Du 2017-03-21 00:28:05 -07:00
parent 84e2c11f96
commit dabe96a72e
1 changed files with 6 additions and 0 deletions

View File

@ -431,6 +431,9 @@ private List<Pair<PerContainerLogFileInfo, String>> getContainerLogFiles(
JSONArray array = new JSONArray(); JSONArray array = new JSONArray();
JSONObject json = JSONObject json =
response.getEntity(JSONObject.class); response.getEntity(JSONObject.class);
if (!json.has("containerLogsInfo")) {
return logFileInfos;
}
Object logsInfoObj = json.get("containerLogsInfo"); Object logsInfoObj = json.get("containerLogsInfo");
if (logsInfoObj instanceof JSONObject) { if (logsInfoObj instanceof JSONObject) {
array.put((JSONObject)logsInfoObj); array.put((JSONObject)logsInfoObj);
@ -444,6 +447,9 @@ private List<Pair<PerContainerLogFileInfo, String>> getContainerLogFiles(
JSONObject log = array.getJSONObject(i); JSONObject log = array.getJSONObject(i);
String aggregateType = log.has("logAggregationType") ? String aggregateType = log.has("logAggregationType") ?
log.getString("logAggregationType") : "N/A"; log.getString("logAggregationType") : "N/A";
if (!log.has("containerLogInfo")) {
continue;
}
Object ob = log.get("containerLogInfo"); Object ob = log.get("containerLogInfo");
if (ob instanceof JSONArray) { if (ob instanceof JSONArray) {
JSONArray obArray = (JSONArray)ob; JSONArray obArray = (JSONArray)ob;