[ https://issues.apache.org/jira/browse/YARN-11221?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17677852#comment-17677852 ]
ASF GitHub Bot commented on YARN-11221: --------------------------------------- goiri commented on code in PR #5302: URL: https://github.com/apache/hadoop/pull/5302#discussion_r1072513487 ########## hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/FederationInterceptorREST.java: ########## @@ -1345,16 +1350,124 @@ public LabelsToNodesInfo getLabelsToNodes(Set<String> labels) "getLabelsToNodes by labels = %s Failed.", StringUtils.join(labels, ",")); } + /** + * This method replaces all the node labels for specific nodes, and it is + * reachable by using {@link RMWSConsts#REPLACE_NODE_TO_LABELS}. + * + * @see ResourceManagerAdministrationProtocol#replaceLabelsOnNode + * @param newNodeToLabels the list of new labels. It is a content param. + * @param hsr the servlet request + * @return Response containing the status code + * @throws IOException if an exception happened + */ @Override public Response replaceLabelsOnNodes(NodeToLabelsEntryList newNodeToLabels, HttpServletRequest hsr) throws IOException { - throw new NotImplementedException("Code is not implemented"); + try { + // Step1. Check the parameters to ensure that the parameters are not empty. + if (newNodeToLabels == null) { + throw new IllegalArgumentException("Parameter error, newNodeToLabels must not be empty."); + } + List<NodeToLabelsEntry> nodeToLabelsEntries = newNodeToLabels.getNodeToLabels(); + if(CollectionUtils.isEmpty(nodeToLabelsEntries)){ Review Comment: Spaces ########## hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/NodeToLabelsEntry.java: ########## @@ -44,6 +44,11 @@ public NodeToLabelsEntry(String nodeId, ArrayList<String> labels) { this.labels = labels; } + public NodeToLabelsEntry(String nodeId, Collection<String> labels) { + this.nodeId = nodeId; + this.labels.addAll(labels); Review Comment: Do we need to clean the existing? This usually also complains as name clashing, we should probably use pLabels for the arg. ########## hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/FederationInterceptorREST.java: ########## @@ -1345,16 +1350,124 @@ public LabelsToNodesInfo getLabelsToNodes(Set<String> labels) "getLabelsToNodes by labels = %s Failed.", StringUtils.join(labels, ",")); } + /** + * This method replaces all the node labels for specific nodes, and it is + * reachable by using {@link RMWSConsts#REPLACE_NODE_TO_LABELS}. + * + * @see ResourceManagerAdministrationProtocol#replaceLabelsOnNode + * @param newNodeToLabels the list of new labels. It is a content param. + * @param hsr the servlet request + * @return Response containing the status code + * @throws IOException if an exception happened + */ @Override public Response replaceLabelsOnNodes(NodeToLabelsEntryList newNodeToLabels, HttpServletRequest hsr) throws IOException { - throw new NotImplementedException("Code is not implemented"); + try { + // Step1. Check the parameters to ensure that the parameters are not empty. + if (newNodeToLabels == null) { Review Comment: This validations should probably be outside the try > [Federation] Add replaceLabelsOnNodes, replaceLabelsOnNode REST APIs for > Router > ------------------------------------------------------------------------------- > > Key: YARN-11221 > URL: https://issues.apache.org/jira/browse/YARN-11221 > Project: Hadoop YARN > Issue Type: Sub-task > Components: federation > Affects Versions: 3.4.0, 3.3.4 > Reporter: Shilun Fan > Assignee: Shilun Fan > Priority: Major > Labels: pull-request-available > -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: yarn-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: yarn-issues-h...@hadoop.apache.org