[
https://issues.apache.org/jira/browse/YARN-11897?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18060337#comment-18060337
]
ASF GitHub Bot commented on YARN-11897:
---------------------------------------
Hean-Chhinling commented on code in PR #8227:
URL: https://github.com/apache/hadoop/pull/8227#discussion_r2840813405
##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServices.java:
##########
@@ -901,53 +929,51 @@ private static String getRedirectURL(String url) {
private List<ContainerLogsInfo> readEntity(Response response) throws
JSONException {
JSONObject jsonObject = response.readEntity(JSONObject.class);
- Iterator<String> keys = jsonObject.keys();
List<ContainerLogsInfo> list = new ArrayList<>();
- while (keys.hasNext()) {
- String key = keys.next();
- JSONObject subJsonObject = jsonObject.getJSONObject(key);
- Iterator<String> subKeys = subJsonObject.keys();
- while (subKeys.hasNext()) {
- String subKeyItem = subKeys.next();
- Object object = subJsonObject.get(subKeyItem);
-
- if (object instanceof JSONObject) {
- JSONObject subKeyItemValue = subJsonObject.getJSONObject(subKeyItem);
- ContainerLogsInfo containerLogsInfo =
parseContainerLogsInfo(subKeyItemValue);
- list.add(containerLogsInfo);
- }
+ Object containerLogsTypeInfo = jsonObject.get("containerLogsInfo");
- if(object instanceof JSONArray) {
- JSONArray jsonArray = subJsonObject.getJSONArray(subKeyItem);
- for (int i = 0; i < jsonArray.length(); i++) {
- JSONObject subKeyItemValue = jsonArray.getJSONObject(i);
- ContainerLogsInfo containerLogsInfo =
parseContainerLogsInfo(subKeyItemValue);
- list.add(containerLogsInfo);
- }
- }
+ if (containerLogsTypeInfo instanceof JSONArray) {
+ JSONArray containerLogsInfoArr = (JSONArray) containerLogsTypeInfo;
+ for (int i = 0; i < containerLogsInfoArr.length(); i++) {
+
list.add(parseContainerLogsInfo(containerLogsInfoArr.getJSONObject(i)));
}
+ } else if (containerLogsTypeInfo instanceof JSONObject) {
+ list.add(parseContainerLogsInfo((JSONObject) containerLogsTypeInfo));
}
return list;
}
- private ContainerLogsInfo parseContainerLogsInfo(JSONObject subKeyItemValue)
+ private ContainerLogsInfo parseContainerLogsInfo(JSONObject jsonLogsInfo)
throws JSONException {
- String logAggregationType =
subKeyItemValue.getString("logAggregationType");
- String containerId = subKeyItemValue.getString("containerId");
- String nodeId = subKeyItemValue.getString("nodeId");
-
- JSONObject containerLogInfo =
subKeyItemValue.getJSONObject("containerLogInfo");
- String fileName = containerLogInfo.getString("fileName");
- String fileSize = containerLogInfo.getString("fileSize");
- String lastModifiedTime = containerLogInfo.getString("lastModifiedTime");
+ String logAggregationType = jsonLogsInfo.getString("logAggregationType");
+ String containerId = jsonLogsInfo.getString("containerId");
+ String nodeId = jsonLogsInfo.getString("nodeId");
ContainerLogMeta containerLogMeta = new ContainerLogMeta(containerId,
nodeId);
- containerLogMeta.addLogMeta(fileName, fileSize, lastModifiedTime);
- ContainerLogsInfo containerLogsInfo =
- new ContainerLogsInfo(containerLogMeta, logAggregationType);
- return containerLogsInfo;
+
+ Object containerLogTypeInfo = jsonLogsInfo.get("containerLogInfo");
+ if (containerLogTypeInfo instanceof JSONArray) {
+ JSONArray containerLogInfoArr = (JSONArray) containerLogTypeInfo;
Review Comment:
it will check the response has size 2 already,
[here](https://github.com/apache/hadoop/blob/17cc6ee2ec42d8dbb7479ace2c6942222bbbb3a8/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServices.java#L741).
I do not think we need to check here as well
> NodeManager REST API backward compatibility with Jersey1
> --------------------------------------------------------
>
> Key: YARN-11897
> URL: https://issues.apache.org/jira/browse/YARN-11897
> Project: Hadoop YARN
> Issue Type: Improvement
> Components: yarn
> Affects Versions: 3.5.0
> Reporter: Peter Szucs
> Assignee: chhinlinghean
> Priority: Major
> Labels: pull-request-available
>
> Jersey 2 upgrade broke NM REST API, so nodes applications page is not
> rendering in yarn UI v2 and also logs CLI cannot retrieve container logs.
> To fix this we need to:
> * introduce moxy in NM similar to YARN-11874
> * "/containers/\{containerid}/logs" endpoint returns a list, which will
> always be generated as a JSON array with Jersey 2. In Jersey 1 it returned a
> JSON object in case the list had a single element, and logs CLI expects a
> JSON object as well when calling this endpoint. That should be changed to
> keep backward compatibility. With returning a wrapper object instead of a
> list we could achieve the same behaviour.
> * Fix unit tests
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]