goiri commented on code in PR #4657:
URL: https://github.com/apache/hadoop/pull/4657#discussion_r933392504
##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/FederationInterceptorREST.java:
##########
@@ -1161,7 +1165,33 @@ public NodeToLabelsInfo
getNodeToLabels(HttpServletRequest hsr)
@Override
public LabelsToNodesInfo getLabelsToNodes(Set<String> labels)
throws IOException {
- throw new NotImplementedException("Code is not implemented");
+ try {
+ Map<SubClusterId, SubClusterInfo> subClustersActive =
getActiveSubclusters();
+ Class[] argsClasses = new Class[]{Set.class};
+ Object[] args = new Object[]{labels};
+ ClientMethod remoteMethod = new ClientMethod("getLabelsToNodes",
argsClasses, args);
+ Map<SubClusterInfo, LabelsToNodesInfo> labelsToNodesInfoMap =
+ invokeConcurrent(subClustersActive.values(), remoteMethod,
LabelsToNodesInfo.class);
+
+ Map<NodeLabelInfo, NodeIDsInfo> labelToNodesMap = new HashMap<>();
+ labelsToNodesInfoMap.values().forEach(labelsToNode -> {
+ Map<NodeLabelInfo, NodeIDsInfo> values =
labelsToNode.getLabelsToNodes();
+ for (Map.Entry<NodeLabelInfo, NodeIDsInfo> item : values.entrySet()) {
+ NodeLabelInfo key = item.getKey();
+ NodeIDsInfo leftValue = item.getValue();
+ NodeIDsInfo rightValue = labelToNodesMap.getOrDefault(key, null);
+ NodeIDsInfo newValue = NodeIDsInfo.add(leftValue, rightValue);
+ labelToNodesMap.put(key, newValue);
+ }
+ });
+ return new LabelsToNodesInfo(labelToNodesMap);
+ } catch (NotFoundException e) {
+ LOG.error("Get all active sub cluster(s) error.", e);
Review Comment:
Didn't we have the log and throw?
--
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]