YARN-6126. Obtaining app logs for Running application fails with json parse error. Contributed by Xuan Gong.

This commit is contained in:
Junping Du 2017-01-27 06:31:10 -08:00
parent 165f07f51a
commit 1a16431bd0

View File

@ -426,8 +426,17 @@ private List<PerContainerLogFileInfo> getContainerLogFiles(
if (response.getStatusInfo().getStatusCode() ==
ClientResponse.Status.OK.getStatusCode()) {
try {
JSONArray array = new JSONArray();
JSONObject json = response.getEntity(JSONObject.class);
JSONArray array = json.getJSONArray("containerLogsInfo");
Object logsInfoObj = json.get("containerLogsInfo");
if (logsInfoObj instanceof JSONObject) {
array.put((JSONObject)logsInfoObj);
} else if (logsInfoObj instanceof JSONArray) {
JSONArray logsArray = (JSONArray)logsInfoObj;
for (int i=0; i < logsArray.length(); i++) {
array.put(logsArray.getJSONObject(i));
}
}
for (int i = 0; i < array.length(); i++) {
JSONObject log = array.getJSONObject(i);
Object ob = log.get("containerLogInfo");