From 7bd96751466caaba61ef9409fc2509d5d23990bf Mon Sep 17 00:00:00 2001 From: slfan1989 Date: Sun, 1 May 2022 23:29:26 -0700 Subject: [PATCH 01/17] YARN-11122:Implement the method of getting ClusterNode, including related Metrics --- .../yarn/server/router/RouterMetrics.java | 29 ++++++++++++++++- .../clientrm/FederationClientInterceptor.java | 29 +++++++++++++++-- .../clientrm/RouterYarnClientUtils.java | 31 ++++++++++++++----- 3 files changed, 79 insertions(+), 10 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/RouterMetrics.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/RouterMetrics.java index 271d1fead5546..902a6551afc29 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/RouterMetrics.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/RouterMetrics.java @@ -55,6 +55,8 @@ public final class RouterMetrics { private MutableGaugeInt numAppAttemptsFailedRetrieved; @Metric("# of getClusterMetrics failed to be retrieved") private MutableGaugeInt numGetClusterMetricsFailedRetrieved; + @Metric("# of getClusterNodes failed to be retrieved") + private MutableGaugeInt numGetClusterNodesFailedRetrieved; // Aggregate metrics are shared, and don't have to be looked up per call @Metric("Total number of successful Submitted apps and latency(ms)") @@ -74,7 +76,9 @@ public final class RouterMetrics { @Metric("Total number of successful Retrieved getClusterMetrics and " + "latency(ms)") private MutableRate totalSucceededGetClusterMetricsRetrieved; - + @Metric("Total number of successful Retrieved getClusterNodes and " + + "latency(ms)") + private MutableRate totalSucceededGetClusterNodesRetrieved; /** * Provide quantile counters for all latencies. @@ -86,6 +90,7 @@ public final class RouterMetrics { private MutableQuantiles getApplicationsReportLatency; private MutableQuantiles getApplicationAttemptReportLatency; private MutableQuantiles getClusterMetricsLatency; + private MutableQuantiles getClusterNodesLatency; private static volatile RouterMetrics INSTANCE = null; private static MetricsRegistry registry; @@ -112,6 +117,10 @@ private RouterMetrics() { getClusterMetricsLatency = registry.newQuantiles("getClusterMetricsLatency", "latency of get cluster metrics", "ops", "latency", 10); + + getClusterNodesLatency = + registry.newQuantiles("getClusterNodesLatency", + "latency of get cluster nodes", "ops", "latency", 10); } public static RouterMetrics getMetrics() { @@ -168,6 +177,11 @@ public long getNumSucceededGetClusterMetricsRetrieved(){ return totalSucceededGetClusterMetricsRetrieved.lastStat().numSamples(); } + @VisibleForTesting + public long getNumSucceededGetClusterNodesRetrieved(){ + return totalSucceededGetClusterNodesRetrieved.lastStat().numSamples(); + } + @VisibleForTesting public double getLatencySucceededAppsCreated() { return totalSucceededAppsCreated.lastStat().mean(); @@ -203,6 +217,11 @@ public double getLatencySucceededGetClusterMetricsRetrieved() { return totalSucceededGetClusterMetricsRetrieved.lastStat().mean(); } + @VisibleForTesting + public double getLatencySucceededGetClusterNodesRetrieved() { + return totalSucceededGetClusterNodesRetrieved.lastStat().mean(); + } + @VisibleForTesting public int getAppsFailedCreated() { return numAppsFailedCreated.value(); @@ -273,6 +292,11 @@ public void succeededGetClusterMetricsRetrieved(long duration) { getClusterMetricsLatency.add(duration); } + public void succeededGetClusterNodesRetrieved(long duration) { + totalSucceededGetClusterNodesRetrieved.add(duration); + getClusterNodesLatency.add(duration); + } + public void incrAppsFailedCreated() { numAppsFailedCreated.incr(); } @@ -301,4 +325,7 @@ public void incrGetClusterMetricsFailedRetrieved() { numGetClusterMetricsFailedRetrieved.incr(); } + public void incrClusterNodesFailedRetrieved() { + numGetClusterNodesFailedRetrieved.incr(); + } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/FederationClientInterceptor.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/FederationClientInterceptor.java index de80a35f49b78..721e7797d688a 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/FederationClientInterceptor.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/FederationClientInterceptor.java @@ -18,6 +18,7 @@ package org.apache.hadoop.yarn.server.router.clientrm; +import org.apache.hadoop.thirdparty.com.google.common.collect.Maps; import org.apache.hadoop.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder; import java.io.IOException; import java.lang.reflect.Method; @@ -790,8 +791,32 @@ Map invokeConcurrent(Collection 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 subclusters = + federationFacade.getSubClusters(true); + Map clusterNodes = Maps.newHashMap(); + for (Map.Entry entry : subclusters.entrySet()) { + SubClusterId subClusterId = entry.getKey(); + ApplicationClientProtocol client = null; + try { + client = getClientRMProxyForSubCluster(subClusterId); + GetClusterNodesResponse response = client.getClusterNodes(request); + clusterNodes.put(subClusterId, response); + } catch (Exception ex) { + routerMetrics.incrClusterNodesFailedRetrieved(); + LOG.error("Unable to get cluster nodes due to exception.", ex); + } + } + long stopTime = clock.getTime(); + routerMetrics.succeededGetClusterNodesRetrieved(stopTime - startTime); + // Merge the NodesResponse + return RouterYarnClientUtils.mergeClusterNodesResponse(clusterNodes.values()); } @Override diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/RouterYarnClientUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/RouterYarnClientUtils.java index 934636b104df6..76fa384a012ed 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/RouterYarnClientUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/RouterYarnClientUtils.java @@ -17,17 +17,14 @@ */ package org.apache.hadoop.yarn.server.router.clientrm; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; +import java.util.*; import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsResponse; -import org.apache.hadoop.yarn.api.records.ApplicationId; -import org.apache.hadoop.yarn.api.records.ApplicationReport; -import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport; -import org.apache.hadoop.yarn.api.records.YarnClusterMetrics; +import org.apache.hadoop.yarn.api.protocolrecords.GetClusterNodesResponse; +import org.apache.hadoop.yarn.api.records.*; import org.apache.hadoop.yarn.server.uam.UnmanagedApplicationManager; +import org.apache.hadoop.yarn.util.Records; import org.apache.hadoop.yarn.util.resource.Resources; /** @@ -194,4 +191,24 @@ private static boolean mergeUamToReport(String appName, return !(appName.startsWith(UnmanagedApplicationManager.APP_NAME) || appName.startsWith(PARTIAL_REPORT)); } + + /** + * Merges a list of GetClusterNodesResponse. + * + * @param responses a list of GetClusterNodesResponse to merge + * @return the merged GetClusterNodesResponse + */ + public static GetClusterNodesResponse mergeClusterNodesResponse( + Collection responses) { + GetClusterNodesResponse clusterNodesResponse = Records.newRecord( + GetClusterNodesResponse.class); + List nodeReports = new ArrayList<>(); + for (GetClusterNodesResponse response : responses) { + if (response != null && response.getNodeReports() != null) { + nodeReports.addAll(response.getNodeReports()); + } + } + clusterNodesResponse.setNodeReports(nodeReports); + return clusterNodesResponse; + } } From 2af73f56a71f2e87a6c00a9c8c5755e87897da8a Mon Sep 17 00:00:00 2001 From: slfan1989 Date: Fri, 6 May 2022 19:59:03 -0700 Subject: [PATCH 02/17] YARN-11122: Finish Juint Test With getClusterNodes --- .../TestFederationClientInterceptor.java | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/clientrm/TestFederationClientInterceptor.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/clientrm/TestFederationClientInterceptor.java index 74d10a44c52b5..7eb1f6b5f37f4 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/clientrm/TestFederationClientInterceptor.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/clientrm/TestFederationClientInterceptor.java @@ -30,20 +30,7 @@ import org.apache.hadoop.test.LambdaTestUtils; import org.apache.hadoop.yarn.MockApps; -import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportRequest; -import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportResponse; -import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest; -import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportResponse; -import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest; -import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsResponse; -import org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsRequest; -import org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsResponse; -import org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationRequest; -import org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationResponse; -import org.apache.hadoop.yarn.api.protocolrecords.KillApplicationRequest; -import org.apache.hadoop.yarn.api.protocolrecords.KillApplicationResponse; -import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationRequest; -import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationResponse; +import org.apache.hadoop.yarn.api.protocolrecords.*; import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext; @@ -641,4 +628,19 @@ 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(), + response.getNodeReports().size()); + } } From 87277d1549e101b6e0ea490e979bccd38a4d5b02 Mon Sep 17 00:00:00 2001 From: slfan1989 Date: Sat, 7 May 2022 01:08:13 -0700 Subject: [PATCH 03/17] YARN-11122:Fix CheckStyle --- .../TestFederationClientInterceptor.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/clientrm/TestFederationClientInterceptor.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/clientrm/TestFederationClientInterceptor.java index 7eb1f6b5f37f4..3180fd6502514 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/clientrm/TestFederationClientInterceptor.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/clientrm/TestFederationClientInterceptor.java @@ -30,7 +30,22 @@ import org.apache.hadoop.test.LambdaTestUtils; import org.apache.hadoop.yarn.MockApps; -import org.apache.hadoop.yarn.api.protocolrecords.*; +import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportRequest; +import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationAttemptReportResponse; +import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportRequest; +import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationReportResponse; +import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest; +import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsResponse; +import org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsRequest; +import org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsResponse; +import org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationRequest; +import org.apache.hadoop.yarn.api.protocolrecords.GetNewApplicationResponse; +import org.apache.hadoop.yarn.api.protocolrecords.KillApplicationRequest; +import org.apache.hadoop.yarn.api.protocolrecords.KillApplicationResponse; +import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationRequest; +import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationResponse; +import org.apache.hadoop.yarn.api.protocolrecords.GetClusterNodesResponse; +import org.apache.hadoop.yarn.api.protocolrecords.GetClusterNodesRequest; import org.apache.hadoop.yarn.api.records.ApplicationAttemptId; import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext; From 6630ce6df52e3a0e696e0d95f10a404168cbe17c Mon Sep 17 00:00:00 2001 From: slfan1989 Date: Sat, 7 May 2022 16:04:11 -0700 Subject: [PATCH 04/17] YARN-11122:Fix CheckStyle --- .../router/clientrm/TestFederationClientInterceptor.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/clientrm/TestFederationClientInterceptor.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/clientrm/TestFederationClientInterceptor.java index 3180fd6502514..a41aa14ec6ac5 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/clientrm/TestFederationClientInterceptor.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/clientrm/TestFederationClientInterceptor.java @@ -649,8 +649,7 @@ 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)); + "Missing getClusterNodes request.", () -> interceptor.getClusterNodes(null)); // normal request. GetClusterNodesResponse response = From 07f609015cfbaac4d21b498e2f23149719c36a27 Mon Sep 17 00:00:00 2001 From: slfan1989 Date: Mon, 9 May 2022 20:17:07 -0700 Subject: [PATCH 05/17] YARN-11122. Fix CheckStyle. --- .../hadoop/yarn/server/router/RouterMetrics.java | 3 +-- .../router/clientrm/RouterYarnClientUtils.java | 12 ++++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/RouterMetrics.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/RouterMetrics.java index 902a6551afc29..0230fdfe2bb83 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/RouterMetrics.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/RouterMetrics.java @@ -76,8 +76,7 @@ public final class RouterMetrics { @Metric("Total number of successful Retrieved getClusterMetrics and " + "latency(ms)") private MutableRate totalSucceededGetClusterMetricsRetrieved; - @Metric("Total number of successful Retrieved getClusterNodes and " - + "latency(ms)") + @Metric("Total number of successful Retrieved getClusterNodes and latency(ms)") private MutableRate totalSucceededGetClusterNodesRetrieved; /** diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/RouterYarnClientUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/RouterYarnClientUtils.java index 76fa384a012ed..28b64b28538d0 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/RouterYarnClientUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/RouterYarnClientUtils.java @@ -17,12 +17,20 @@ */ package org.apache.hadoop.yarn.server.router.clientrm; -import java.util.*; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.List; +import java.util.ArrayList; import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetClusterMetricsResponse; import org.apache.hadoop.yarn.api.protocolrecords.GetClusterNodesResponse; -import org.apache.hadoop.yarn.api.records.*; +import org.apache.hadoop.yarn.api.records.ApplicationId; +import org.apache.hadoop.yarn.api.records.ApplicationReport; +import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport; +import org.apache.hadoop.yarn.api.records.YarnClusterMetrics; +import org.apache.hadoop.yarn.api.records.NodeReport; import org.apache.hadoop.yarn.server.uam.UnmanagedApplicationManager; import org.apache.hadoop.yarn.util.Records; import org.apache.hadoop.yarn.util.resource.Resources; From 1bf7332b463894d563ec9ac57154ff74b0cee914 Mon Sep 17 00:00:00 2001 From: slfan1989 Date: Tue, 10 May 2022 15:28:51 -0700 Subject: [PATCH 06/17] YARN-11122. Fix CheckStyle --- .../server/router/clientrm/RouterYarnClientUtils.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/RouterYarnClientUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/RouterYarnClientUtils.java index 28b64b28538d0..44a9f6f92d662 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/RouterYarnClientUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/RouterYarnClientUtils.java @@ -203,14 +203,16 @@ private static boolean mergeUamToReport(String appName, /** * Merges a list of GetClusterNodesResponse. * - * @param responses a list of GetClusterNodesResponse to merge - * @return the merged GetClusterNodesResponse + * @param responses a list of GetClusterNodesResponse to merge. + * @return the merged GetClusterNodesResponse. */ public static GetClusterNodesResponse mergeClusterNodesResponse( Collection responses) { - GetClusterNodesResponse clusterNodesResponse = Records.newRecord( - GetClusterNodesResponse.class); + + GetClusterNodesResponse clusterNodesResponse = Records.newRecord(GetClusterNodesResponse.class); + List nodeReports = new ArrayList<>(); + for (GetClusterNodesResponse response : responses) { if (response != null && response.getNodeReports() != null) { nodeReports.addAll(response.getNodeReports()); From b4867c0d12d30cd8f000ace87053b19641fafd27 Mon Sep 17 00:00:00 2001 From: slfan1989 Date: Wed, 11 May 2022 23:43:38 -0700 Subject: [PATCH 07/17] YARN-11122: Fix Code Style, indentation --- .../hadoop/yarn/server/router/RouterMetrics.java | 2 +- .../clientrm/FederationClientInterceptor.java | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/RouterMetrics.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/RouterMetrics.java index 0230fdfe2bb83..f2fc945901d0e 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/RouterMetrics.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/RouterMetrics.java @@ -118,7 +118,7 @@ private RouterMetrics() { "latency of get cluster metrics", "ops", "latency", 10); getClusterNodesLatency = - registry.newQuantiles("getClusterNodesLatency", + registry.newQuantiles("getClusterNodesLatency", "latency of get cluster nodes", "ops", "latency", 10); } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/FederationClientInterceptor.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/FederationClientInterceptor.java index 721e7797d688a..e2f055fb80b12 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/FederationClientInterceptor.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/FederationClientInterceptor.java @@ -791,19 +791,17 @@ Map invokeConcurrent(Collection clusterIds, @Override public GetClusterNodesResponse getClusterNodes(GetClusterNodesRequest request) - throws YarnException, IOException { + throws YarnException, IOException { if (request == null) { routerMetrics.incrClusterNodesFailedRetrieved(); - RouterServerUtil.logAndThrowException( - "Missing getClusterNodes request.", null); + RouterServerUtil.logAndThrowException("Missing getClusterNodes request.", null); } long startTime = clock.getTime(); - Map subclusters = + Map subClusters = federationFacade.getSubClusters(true); Map clusterNodes = Maps.newHashMap(); - for (Map.Entry entry : subclusters.entrySet()) { - SubClusterId subClusterId = entry.getKey(); - ApplicationClientProtocol client = null; + for (SubClusterId subClusterId : subClusters.keySet()) { + ApplicationClientProtocol client; try { client = getClientRMProxyForSubCluster(subClusterId); GetClusterNodesResponse response = client.getClusterNodes(request); @@ -811,6 +809,7 @@ public GetClusterNodesResponse getClusterNodes(GetClusterNodesRequest request) } catch (Exception ex) { routerMetrics.incrClusterNodesFailedRetrieved(); LOG.error("Unable to get cluster nodes due to exception.", ex); + throw ex; } } long stopTime = clock.getTime(); From aa49c3a788a026bfb9443974ba67784142fa2303 Mon Sep 17 00:00:00 2001 From: slfan1989 Date: Thu, 12 May 2022 00:05:03 -0700 Subject: [PATCH 08/17] YARN-11122: Add GetClusterNodes Metric Junit Test. --- .../yarn/server/router/RouterMetrics.java | 5 +++ .../yarn/server/router/TestRouterMetrics.java | 34 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/RouterMetrics.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/RouterMetrics.java index f2fc945901d0e..9a2498a7016fe 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/RouterMetrics.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/RouterMetrics.java @@ -256,6 +256,11 @@ public int getClusterMetricsFailedRetrieved() { return numGetClusterMetricsFailedRetrieved.value(); } + @VisibleForTesting + public int getClusterNodesFailedRetrieved() { + return numGetClusterNodesFailedRetrieved.value(); + } + public void succeededAppsCreated(long duration) { totalSucceededAppsCreated.add(duration); getNewApplicationLatency.add(duration); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/TestRouterMetrics.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/TestRouterMetrics.java index 4d4838a560b48..2cde7aa0bad02 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/TestRouterMetrics.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/TestRouterMetrics.java @@ -346,6 +346,11 @@ public void getClusterMetrics() { LOG.info("Mocked: failed getClusterMetrics call"); metrics.incrGetClusterMetricsFailedRetrieved(); } + + public void getClusterNodes() { + LOG.info("Mocked: failed getClusterNodes call"); + metrics.incrClusterNodesFailedRetrieved(); + } } // Records successes for all calls @@ -392,5 +397,34 @@ public void getClusterMetrics(long duration){ duration); metrics.succeededGetClusterMetricsRetrieved(duration); } + + public void getClusterNodes(long duration) { + LOG.info("Mocked: successful getClusterNodes call with duration {}", + duration); + metrics.succeededGetClusterNodesRetrieved(duration); + } + } + + @Test + public void testSucceededGetClusterNodes() { + long totalGoodBefore = metrics.getNumSucceededGetClusterNodesRetrieved(); + goodSubCluster.getClusterNodes(150); + Assert.assertEquals(totalGoodBefore + 1, + metrics.getNumSucceededGetClusterNodesRetrieved()); + Assert.assertEquals(150, metrics.getLatencySucceededGetClusterNodesRetrieved(), + 0); + goodSubCluster.getClusterNodes(300); + Assert.assertEquals(totalGoodBefore + 2, + metrics.getNumSucceededGetClusterNodesRetrieved()); + Assert.assertEquals(225, metrics.getLatencySucceededGetClusterNodesRetrieved(), + 0); + } + + @Test + public void testGetClusterNodesFailed() { + long totalBadBefore = metrics.getClusterNodesFailedRetrieved(); + badSubCluster.getClusterNodes(); + Assert.assertEquals(totalBadBefore + 1, + metrics.getClusterNodesFailedRetrieved()); } } From c6e404bbfd417e1f474348d82c0052d05f829a33 Mon Sep 17 00:00:00 2001 From: slfan1989 Date: Thu, 12 May 2022 00:59:56 -0700 Subject: [PATCH 09/17] YARN-11122: Fix CodeStyle. --- .../yarn/server/router/TestRouterMetrics.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/TestRouterMetrics.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/TestRouterMetrics.java index 2cde7aa0bad02..5ee11923c74d9 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/TestRouterMetrics.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/TestRouterMetrics.java @@ -399,8 +399,7 @@ public void getClusterMetrics(long duration){ } public void getClusterNodes(long duration) { - LOG.info("Mocked: successful getClusterNodes call with duration {}", - duration); + LOG.info("Mocked: successful getClusterNodes call with duration {}", duration); metrics.succeededGetClusterNodesRetrieved(duration); } } @@ -410,14 +409,14 @@ public void testSucceededGetClusterNodes() { long totalGoodBefore = metrics.getNumSucceededGetClusterNodesRetrieved(); goodSubCluster.getClusterNodes(150); Assert.assertEquals(totalGoodBefore + 1, - metrics.getNumSucceededGetClusterNodesRetrieved()); + metrics.getNumSucceededGetClusterNodesRetrieved()); Assert.assertEquals(150, metrics.getLatencySucceededGetClusterNodesRetrieved(), - 0); + 0); goodSubCluster.getClusterNodes(300); Assert.assertEquals(totalGoodBefore + 2, - metrics.getNumSucceededGetClusterNodesRetrieved()); + metrics.getNumSucceededGetClusterNodesRetrieved()); Assert.assertEquals(225, metrics.getLatencySucceededGetClusterNodesRetrieved(), - 0); + 0); } @Test @@ -425,6 +424,6 @@ public void testGetClusterNodesFailed() { long totalBadBefore = metrics.getClusterNodesFailedRetrieved(); badSubCluster.getClusterNodes(); Assert.assertEquals(totalBadBefore + 1, - metrics.getClusterNodesFailedRetrieved()); + metrics.getClusterNodesFailedRetrieved()); } } From c7ccca5bfdd9aa5a5ccadcfd63b9209da0573296 Mon Sep 17 00:00:00 2001 From: slfan1989 Date: Thu, 12 May 2022 01:09:58 -0700 Subject: [PATCH 10/17] YARN-11122: Fix CodeStyle. --- .../org/apache/hadoop/yarn/server/router/RouterMetrics.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/RouterMetrics.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/RouterMetrics.java index 9a2498a7016fe..a30009f233d3d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/RouterMetrics.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/RouterMetrics.java @@ -119,7 +119,7 @@ private RouterMetrics() { getClusterNodesLatency = registry.newQuantiles("getClusterNodesLatency", - "latency of get cluster nodes", "ops", "latency", 10); + "latency of get cluster nodes", "ops", "latency", 10); } public static RouterMetrics getMetrics() { From 407c0393cb3d34ddffda27a6a9794a6c13005772 Mon Sep 17 00:00:00 2001 From: slfan1989 Date: Thu, 12 May 2022 01:14:55 -0700 Subject: [PATCH 11/17] YARN-11122: Fix CodeStyle. --- .../yarn/server/router/clientrm/RouterYarnClientUtils.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/RouterYarnClientUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/RouterYarnClientUtils.java index 44a9f6f92d662..54289169f1781 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/RouterYarnClientUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/RouterYarnClientUtils.java @@ -207,10 +207,8 @@ private static boolean mergeUamToReport(String appName, * @return the merged GetClusterNodesResponse. */ public static GetClusterNodesResponse mergeClusterNodesResponse( - Collection responses) { - + Collection responses) { GetClusterNodesResponse clusterNodesResponse = Records.newRecord(GetClusterNodesResponse.class); - List nodeReports = new ArrayList<>(); for (GetClusterNodesResponse response : responses) { From 7845199609d0de6dd91c63e27d90a1fdf2bd4936 Mon Sep 17 00:00:00 2001 From: slfan1989 Date: Thu, 12 May 2022 01:32:54 -0700 Subject: [PATCH 12/17] YARN-11122: Fix CodeStyle. --- .../router/clientrm/TestFederationClientInterceptor.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/clientrm/TestFederationClientInterceptor.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/clientrm/TestFederationClientInterceptor.java index a41aa14ec6ac5..6667ae6502132 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/clientrm/TestFederationClientInterceptor.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/clientrm/TestFederationClientInterceptor.java @@ -648,13 +648,12 @@ public void testGetApplicationsApplicationStateNotExists() throws Exception{ 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)); - + LambdaTestUtils.intercept(YarnException.class, "Missing getClusterNodes request.", + () -> interceptor.getClusterNodes(null)); // normal request. GetClusterNodesResponse response = - interceptor.getClusterNodes(GetClusterNodesRequest.newInstance()); + interceptor.getClusterNodes(GetClusterNodesRequest.newInstance()); Assert.assertEquals(subClusters.size(), - response.getNodeReports().size()); + response.getNodeReports().size()); } } From f16651fe443d92a368ab317d2e4de07a08908d95 Mon Sep 17 00:00:00 2001 From: slfan1989 Date: Thu, 12 May 2022 01:44:00 -0700 Subject: [PATCH 13/17] YARN-11122: Fix CodeStyle. --- .../server/router/clientrm/FederationClientInterceptor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/FederationClientInterceptor.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/FederationClientInterceptor.java index e2f055fb80b12..6b6b19aac85ee 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/FederationClientInterceptor.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/FederationClientInterceptor.java @@ -798,7 +798,7 @@ public GetClusterNodesResponse getClusterNodes(GetClusterNodesRequest request) } long startTime = clock.getTime(); Map subClusters = - federationFacade.getSubClusters(true); + federationFacade.getSubClusters(true); Map clusterNodes = Maps.newHashMap(); for (SubClusterId subClusterId : subClusters.keySet()) { ApplicationClientProtocol client; From dde385a5fa4b4e50e07bfd762f3dc59e99aeef2f Mon Sep 17 00:00:00 2001 From: slfan1989 Date: Thu, 12 May 2022 01:50:45 -0700 Subject: [PATCH 14/17] YARN-11122: Fix CodeStyle. --- .../org/apache/hadoop/yarn/server/router/TestRouterMetrics.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/TestRouterMetrics.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/TestRouterMetrics.java index 5ee11923c74d9..f47bf3c715108 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/TestRouterMetrics.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/TestRouterMetrics.java @@ -411,7 +411,7 @@ public void testSucceededGetClusterNodes() { Assert.assertEquals(totalGoodBefore + 1, metrics.getNumSucceededGetClusterNodesRetrieved()); Assert.assertEquals(150, metrics.getLatencySucceededGetClusterNodesRetrieved(), - 0); + 0); goodSubCluster.getClusterNodes(300); Assert.assertEquals(totalGoodBefore + 2, metrics.getNumSucceededGetClusterNodesRetrieved()); From 72359e0384e154322c10128135df6f0c60eec955 Mon Sep 17 00:00:00 2001 From: slfan1989 Date: Thu, 12 May 2022 04:21:21 -0700 Subject: [PATCH 15/17] YARN-11122. Fix CodeStyle. --- .../yarn/server/router/clientrm/RouterYarnClientUtils.java | 1 - 1 file changed, 1 deletion(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/RouterYarnClientUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/RouterYarnClientUtils.java index 54289169f1781..dfe20cfda1f3c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/RouterYarnClientUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/RouterYarnClientUtils.java @@ -210,7 +210,6 @@ public static GetClusterNodesResponse mergeClusterNodesResponse( Collection responses) { GetClusterNodesResponse clusterNodesResponse = Records.newRecord(GetClusterNodesResponse.class); List nodeReports = new ArrayList<>(); - for (GetClusterNodesResponse response : responses) { if (response != null && response.getNodeReports() != null) { nodeReports.addAll(response.getNodeReports()); From 0887df59dfb70c1f94d00262fab2e7219d994c2d Mon Sep 17 00:00:00 2001 From: slfan1989 Date: Thu, 12 May 2022 17:40:39 -0700 Subject: [PATCH 16/17] YARN-11122. Fix CodeStyle --- .../yarn/server/router/TestRouterMetrics.java | 17 +++++++---------- .../TestFederationClientInterceptor.java | 3 +-- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/TestRouterMetrics.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/TestRouterMetrics.java index f47bf3c715108..52d256ee17345 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/TestRouterMetrics.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/TestRouterMetrics.java @@ -38,6 +38,8 @@ public class TestRouterMetrics { private static RouterMetrics metrics = RouterMetrics.getMetrics(); + private static final Double ASSERT_DOUBLE_DELTA = 0.01; + @BeforeClass public static void init() { @@ -408,22 +410,17 @@ public void getClusterNodes(long duration) { public void testSucceededGetClusterNodes() { long totalGoodBefore = metrics.getNumSucceededGetClusterNodesRetrieved(); goodSubCluster.getClusterNodes(150); - Assert.assertEquals(totalGoodBefore + 1, - metrics.getNumSucceededGetClusterNodesRetrieved()); - Assert.assertEquals(150, metrics.getLatencySucceededGetClusterNodesRetrieved(), - 0); + Assert.assertEquals(totalGoodBefore + 1, metrics.getNumSucceededGetClusterNodesRetrieved()); + Assert.assertEquals(150, metrics.getLatencySucceededGetClusterNodesRetrieved(), ASSERT_DOUBLE_DELTA); goodSubCluster.getClusterNodes(300); - Assert.assertEquals(totalGoodBefore + 2, - metrics.getNumSucceededGetClusterNodesRetrieved()); - Assert.assertEquals(225, metrics.getLatencySucceededGetClusterNodesRetrieved(), - 0); + Assert.assertEquals(totalGoodBefore + 2, metrics.getNumSucceededGetClusterNodesRetrieved()); + Assert.assertEquals(225, metrics.getLatencySucceededGetClusterNodesRetrieved(), ASSERT_DOUBLE_DELTA); } @Test public void testGetClusterNodesFailed() { long totalBadBefore = metrics.getClusterNodesFailedRetrieved(); badSubCluster.getClusterNodes(); - Assert.assertEquals(totalBadBefore + 1, - metrics.getClusterNodesFailedRetrieved()); + Assert.assertEquals(totalBadBefore + 1, metrics.getClusterNodesFailedRetrieved()); } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/clientrm/TestFederationClientInterceptor.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/clientrm/TestFederationClientInterceptor.java index 6667ae6502132..7409a1cff169f 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/clientrm/TestFederationClientInterceptor.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/clientrm/TestFederationClientInterceptor.java @@ -653,7 +653,6 @@ public void testGetClusterNodesRequest() throws Exception { // normal request. GetClusterNodesResponse response = interceptor.getClusterNodes(GetClusterNodesRequest.newInstance()); - Assert.assertEquals(subClusters.size(), - response.getNodeReports().size()); + Assert.assertEquals(subClusters.size(), response.getNodeReports().size()); } } From dbd5cb323340e3597bedfd230df30313e0278fbd Mon Sep 17 00:00:00 2001 From: slfan1989 Date: Thu, 12 May 2022 19:24:41 -0700 Subject: [PATCH 17/17] YARN-11122. Fix CodeStyle --- .../apache/hadoop/yarn/server/router/TestRouterMetrics.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/TestRouterMetrics.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/TestRouterMetrics.java index 52d256ee17345..df8c194208aa2 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/TestRouterMetrics.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/test/java/org/apache/hadoop/yarn/server/router/TestRouterMetrics.java @@ -411,10 +411,12 @@ public void testSucceededGetClusterNodes() { long totalGoodBefore = metrics.getNumSucceededGetClusterNodesRetrieved(); goodSubCluster.getClusterNodes(150); Assert.assertEquals(totalGoodBefore + 1, metrics.getNumSucceededGetClusterNodesRetrieved()); - Assert.assertEquals(150, metrics.getLatencySucceededGetClusterNodesRetrieved(), ASSERT_DOUBLE_DELTA); + Assert.assertEquals(150, metrics.getLatencySucceededGetClusterNodesRetrieved(), + ASSERT_DOUBLE_DELTA); goodSubCluster.getClusterNodes(300); Assert.assertEquals(totalGoodBefore + 2, metrics.getNumSucceededGetClusterNodesRetrieved()); - Assert.assertEquals(225, metrics.getLatencySucceededGetClusterNodesRetrieved(), ASSERT_DOUBLE_DELTA); + Assert.assertEquals(225, metrics.getLatencySucceededGetClusterNodesRetrieved(), + ASSERT_DOUBLE_DELTA); } @Test