Skip to content

Commit

Permalink
YARN-11180. Fix CheckStyle.
Browse files Browse the repository at this point in the history
  • Loading branch information
slfan1989 committed Jul 24, 2022
1 parent a8150e4 commit 975d9bf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -669,14 +669,13 @@ public GetApplicationsResponse getApplications(GetApplicationsRequest request)
federationFacade.getSubClusters(true);
ClientMethod remoteMethod = new ClientMethod("getApplications",
new Class[] {GetApplicationsRequest.class}, new Object[] {request});
Map<SubClusterId, GetApplicationsResponse> applications;
Map<SubClusterId, GetApplicationsResponse> applications = null;
try {
applications = invokeConcurrent(subclusters.keySet(), remoteMethod,
GetApplicationsResponse.class);
} catch (Exception ex) {
routerMetrics.incrMultipleAppsFailedRetrieved();
LOG.error("Unable to get applications due to exception.", ex);
throw ex;
RouterServerUtil.logAndThrowException("Unable to get applications due to exception.", ex);
}
long stopTime = clock.getTime();
routerMetrics.succeededMultipleAppsRetrieved(stopTime - startTime);
Expand All @@ -687,23 +686,23 @@ public GetApplicationsResponse getApplications(GetApplicationsRequest request)
@Override
public GetClusterMetricsResponse getClusterMetrics(
GetClusterMetricsRequest request) throws YarnException, IOException {
if (request == null) {
routerMetrics.incrGetClusterMetricsFailedRetrieved();
RouterServerUtil.logAndThrowException("Missing getClusterMetrics request.", null);
}
long startTime = clock.getTime();
Map<SubClusterId, SubClusterInfo> subclusters =
Map<SubClusterId, SubClusterInfo> subClusters =
federationFacade.getSubClusters(true);
ClientMethod remoteMethod = new ClientMethod("getClusterMetrics",
new Class[] {GetClusterMetricsRequest.class}, new Object[] {request});
Map<SubClusterId, GetClusterMetricsResponse> clusterMetrics;

Map<SubClusterId, GetClusterMetricsResponse> clusterMetrics = null;
try {
clusterMetrics = invokeConcurrent(subclusters.keySet(), remoteMethod,
clusterMetrics = invokeConcurrent(subClusters.keySet(), remoteMethod,
GetClusterMetricsResponse.class);

} catch (Exception ex) {
routerMetrics.incrGetClusterMetricsFailedRetrieved();
LOG.error("Unable to get cluster metrics due to exception.", ex);
throw ex;
RouterServerUtil.logAndThrowException("Unable to get cluster metrics due to exception.", ex);
}

long stopTime = clock.getTime();
routerMetrics.succeededGetClusterMetricsRetrieved(stopTime - startTime);
return RouterYarnClientUtils.merge(clusterMetrics.values());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,14 +580,14 @@ public void testGetApplicationAttemptEmptyRequest()


@Test
public void testGetClusterMetricsRequest() throws YarnException, IOException {
public void testGetClusterMetricsRequest() throws Exception {
LOG.info("Test FederationClientInterceptor : Get Cluster Metrics request");
// null request
GetClusterMetricsResponse response = interceptor.getClusterMetrics(null);
Assert.assertEquals(subClusters.size(),
response.getClusterMetrics().getNumNodeManagers());
LambdaTestUtils.intercept(YarnException.class, "Missing getClusterMetrics request.",
() -> interceptor.getClusterMetrics(null));

// normal request.
response =
GetClusterMetricsResponse response =
interceptor.getClusterMetrics(GetClusterMetricsRequest.newInstance());
Assert.assertEquals(subClusters.size(),
response.getClusterMetrics().getNumNodeManagers());
Expand Down

0 comments on commit 975d9bf

Please sign in to comment.