slfan1989 commented on code in PR #4540:
URL: https://github.com/apache/hadoop/pull/4540#discussion_r921596809
##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/RouterYarnClientUtils.java:
##########
@@ -417,5 +420,59 @@ public static GetQueueInfoResponse mergeQueues(
queueResponse.setQueueInfo(queueInfo);
return queueResponse;
}
+
+ /**
+ * Merges a list of GetAllResourceProfilesResponse.
+ *
+ * @param responses a list of GetAllResourceProfilesResponse to merge.
+ * @return the merged GetAllResourceProfilesResponse.
+ */
+ public static GetAllResourceProfilesResponse
mergeClusterResourceProfilesResponse(
+ Collection<GetAllResourceProfilesResponse> responses) {
+ GetAllResourceProfilesResponse profilesResponse =
+ Records.newRecord(GetAllResourceProfilesResponse.class);
+ Map<String, Resource> profilesMap = new HashMap<>();
+ for (GetAllResourceProfilesResponse response : responses) {
+ if (response != null && response.getResourceProfiles() != null) {
+ for (Map.Entry<String, Resource> entry :
response.getResourceProfiles().entrySet()) {
+ String key = entry.getKey();
+ Resource value = entry.getValue();
+ if (profilesMap.containsKey(key)) {
+ Resource resourceValue = profilesMap.get(key);
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]