goiri commented on code in PR #4274: URL: https://github.com/apache/hadoop/pull/4274#discussion_r870905206
########## hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/FederationClientInterceptor.java: ########## @@ -790,8 +791,32 @@ <R> Map<SubClusterId, R> invokeConcurrent(Collection<SubClusterId> clusterIds, @Override public GetClusterNodesResponse getClusterNodes(GetClusterNodesRequest request) - throws YarnException, IOException { - throw new NotImplementedException("Code is not implemented"); + throws YarnException, IOException { + if (request == null) { + routerMetrics.incrClusterNodesFailedRetrieved(); + RouterServerUtil.logAndThrowException( Review Comment: Single line. ########## hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/RouterMetrics.java: ########## @@ -112,6 +116,10 @@ private RouterMetrics() { getClusterMetricsLatency = registry.newQuantiles("getClusterMetricsLatency", "latency of get cluster metrics", "ops", "latency", 10); + + getClusterNodesLatency = + registry.newQuantiles("getClusterNodesLatency", Review Comment: Yetus seems not to be running the checkstyle. Can you run it by hand and fix indentation? CC @ayushtkn any idea on why the checkstyle is not being ran? ########## hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/FederationClientInterceptor.java: ########## @@ -790,8 +791,32 @@ <R> Map<SubClusterId, R> invokeConcurrent(Collection<SubClusterId> clusterIds, @Override public GetClusterNodesResponse getClusterNodes(GetClusterNodesRequest request) - throws YarnException, IOException { - throw new NotImplementedException("Code is not implemented"); + throws YarnException, IOException { Review Comment: Indentation ########## hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/FederationClientInterceptor.java: ########## @@ -790,8 +791,32 @@ <R> Map<SubClusterId, R> invokeConcurrent(Collection<SubClusterId> clusterIds, @Override public GetClusterNodesResponse getClusterNodes(GetClusterNodesRequest request) - throws YarnException, IOException { - throw new NotImplementedException("Code is not implemented"); + throws YarnException, IOException { + if (request == null) { + routerMetrics.incrClusterNodesFailedRetrieved(); + RouterServerUtil.logAndThrowException( + "Missing getClusterNodes request.", null); + } + long startTime = clock.getTime(); + Map<SubClusterId, SubClusterInfo> subclusters = + federationFacade.getSubClusters(true); + Map<SubClusterId, GetClusterNodesResponse> clusterNodes = Maps.newHashMap(); + for (Map.Entry<SubClusterId, SubClusterInfo> entry : subclusters.entrySet()) { Review Comment: You don't use the values. We shouldn't use entrySet() but keys() ########## hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/clientrm/TestFederationClientInterceptor.java: ########## @@ -641,4 +643,18 @@ public void testGetApplicationsApplicationStateNotExists() throws Exception{ Assert.assertNotNull(responseGet); Assert.assertTrue(responseGet.getApplicationList().isEmpty()); } + + @Test + public void testGetClusterNodesRequest() throws Exception { + LOG.info("Test FederationClientInterceptor : Get Cluster Nodeds request"); + // null request + LambdaTestUtils.intercept(YarnException.class, + "Missing getClusterNodes request.", () -> interceptor.getClusterNodes(null)); + + // normal request. + GetClusterNodesResponse response = + interceptor.getClusterNodes(GetClusterNodesRequest.newInstance()); + Assert.assertEquals(subClusters.size(), Review Comment: Can we assert some metrics? -- 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: common-issues-unsubscr...@hadoop.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org