slfan1989 commented on code in PR #4610:
URL: https://github.com/apache/hadoop/pull/4610#discussion_r928005084


##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/RouterYarnClientUtils.java:
##########
@@ -468,5 +474,65 @@ public static GetResourceProfileResponse 
mergeClusterResourceProfileResponse(
     profileResponse.setResource(resource);
     return profileResponse;
   }
+
+  /**
+   * Merges a list of GetAttributesToNodesResponse.
+   *
+   * @param responses a list of GetAttributesToNodesResponse to merge.
+   * @return the merged GetAttributesToNodesResponse.
+   */
+  public static GetAttributesToNodesResponse mergeAttributesToNodesResponse(
+      Collection<GetAttributesToNodesResponse> responses) {
+    GetAttributesToNodesResponse attributesToNodesResponse =
+        GetAttributesToNodesResponse.newInstance(new HashMap<>());
+    Map<NodeAttributeKey, List<NodeToAttributeValue>> nodeAttributeMap = new 
HashMap<>();
+    for (GetAttributesToNodesResponse response : responses) {
+      if (response != null && response.getAttributesToNodes() != null) {
+        nodeAttributeMap.putAll(response.getAttributesToNodes());
+      }
+    }
+    attributesToNodesResponse.setAttributeToNodes(nodeAttributeMap);
+    return attributesToNodesResponse;

Review Comment:
   Thanks for your suggestion, I will modify the code.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to