Skip to content

Commit 24234ac

Browse files
author
slfan1989
committed
YARN-11180. Fix CheckStyle.
1 parent 975d9bf commit 24234ac

File tree

1 file changed

+19
-24
lines changed
  • hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm

1 file changed

+19
-24
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/FederationClientInterceptor.java

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -790,8 +790,7 @@ public GetClusterNodesResponse getClusterNodes(GetClusterNodesRequest request)
790790
clusterNodes.put(subClusterId, response);
791791
} catch (Exception ex) {
792792
routerMetrics.incrClusterNodesFailedRetrieved();
793-
LOG.error("Unable to get cluster nodes due to exception.", ex);
794-
throw ex;
793+
RouterServerUtil.logAndThrowException("Unable to get cluster nodes due to exception.", ex);
795794
}
796795
}
797796
long stopTime = clock.getTime();
@@ -836,14 +835,13 @@ public GetQueueUserAclsInfoResponse getQueueUserAcls(
836835
long startTime = clock.getTime();
837836
ClientMethod remoteMethod = new ClientMethod("getQueueUserAcls",
838837
new Class[] {GetQueueUserAclsInfoRequest.class}, new Object[] {request});
839-
Collection<GetQueueUserAclsInfoResponse> queueUserAcls;
838+
Collection<GetQueueUserAclsInfoResponse> queueUserAcls = null;
840839
try {
841840
queueUserAcls = invokeAppClientProtocolMethod(true, remoteMethod,
842841
GetQueueUserAclsInfoResponse.class);
843842
} catch (Exception ex) {
844843
routerMetrics.incrQueueUserAclsFailedRetrieved();
845-
LOG.error("Unable to get queue user Acls due to exception.", ex);
846-
throw ex;
844+
RouterServerUtil.logAndThrowException("Unable to get queue user Acls due to exception.", ex);
847845
}
848846
long stopTime = clock.getTime();
849847
routerMetrics.succeededGetQueueUserAclsRetrieved(stopTime - startTime);
@@ -917,14 +915,14 @@ public ReservationListResponse listReservations(
917915
long startTime = clock.getTime();
918916
ClientMethod remoteMethod = new ClientMethod("listReservations",
919917
new Class[] {ReservationListRequest.class}, new Object[] {request});
920-
Collection<ReservationListResponse> listResponses;
918+
Collection<ReservationListResponse> listResponses = null;
921919
try {
922920
listResponses = invokeAppClientProtocolMethod(true, remoteMethod,
923921
ReservationListResponse.class);
924922
} catch (Exception ex) {
925923
routerMetrics.incrListReservationsFailedRetrieved();
926-
LOG.error("Unable to list reservations node due to exception.", ex);
927-
throw ex;
924+
RouterServerUtil.logAndThrowException(
925+
"Unable to list reservations node due to exception.", ex);
928926
}
929927
long stopTime = clock.getTime();
930928
routerMetrics.succeededListReservationsRetrieved(stopTime - startTime);
@@ -972,14 +970,13 @@ public GetNodesToLabelsResponse getNodeToLabels(
972970
long startTime = clock.getTime();
973971
ClientMethod remoteMethod = new ClientMethod("getNodeToLabels",
974972
new Class[] {GetNodesToLabelsRequest.class}, new Object[] {request});
975-
Collection<GetNodesToLabelsResponse> clusterNodes;
973+
Collection<GetNodesToLabelsResponse> clusterNodes = null;
976974
try {
977975
clusterNodes = invokeAppClientProtocolMethod(true, remoteMethod,
978976
GetNodesToLabelsResponse.class);
979977
} catch (Exception ex) {
980978
routerMetrics.incrNodeToLabelsFailedRetrieved();
981-
LOG.error("Unable to get label node due to exception.", ex);
982-
throw ex;
979+
RouterServerUtil.logAndThrowException("Unable to get node label due to exception.", ex);
983980
}
984981
long stopTime = clock.getTime();
985982
routerMetrics.succeededGetNodeToLabelsRetrieved(stopTime - startTime);
@@ -997,14 +994,13 @@ public GetLabelsToNodesResponse getLabelsToNodes(
997994
long startTime = clock.getTime();
998995
ClientMethod remoteMethod = new ClientMethod("getLabelsToNodes",
999996
new Class[] {GetLabelsToNodesRequest.class}, new Object[] {request});
1000-
Collection<GetLabelsToNodesResponse> labelNodes;
997+
Collection<GetLabelsToNodesResponse> labelNodes = null;
1001998
try {
1002999
labelNodes = invokeAppClientProtocolMethod(true, remoteMethod,
10031000
GetLabelsToNodesResponse.class);
10041001
} catch (Exception ex) {
10051002
routerMetrics.incrLabelsToNodesFailedRetrieved();
1006-
LOG.error("Unable to get label node due to exception.", ex);
1007-
throw ex;
1003+
RouterServerUtil.logAndThrowException("Unable to get label node due to exception.", ex);
10081004
}
10091005
long stopTime = clock.getTime();
10101006
routerMetrics.succeededGetLabelsToNodesRetrieved(stopTime - startTime);
@@ -1022,14 +1018,14 @@ public GetClusterNodeLabelsResponse getClusterNodeLabels(
10221018
long startTime = clock.getTime();
10231019
ClientMethod remoteMethod = new ClientMethod("getClusterNodeLabels",
10241020
new Class[] {GetClusterNodeLabelsRequest.class}, new Object[] {request});
1025-
Collection<GetClusterNodeLabelsResponse> nodeLabels;
1021+
Collection<GetClusterNodeLabelsResponse> nodeLabels = null;
10261022
try {
10271023
nodeLabels = invokeAppClientProtocolMethod(true, remoteMethod,
10281024
GetClusterNodeLabelsResponse.class);
10291025
} catch (Exception ex) {
10301026
routerMetrics.incrClusterNodeLabelsFailedRetrieved();
1031-
LOG.error("Unable to get cluster nodeLabels due to exception.", ex);
1032-
throw ex;
1027+
RouterServerUtil.logAndThrowException("Unable to get cluster nodeLabels due to exception.",
1028+
ex);
10331029
}
10341030
long stopTime = clock.getTime();
10351031
routerMetrics.succeededGetClusterNodeLabelsRetrieved(stopTime - startTime);
@@ -1082,15 +1078,15 @@ public GetApplicationAttemptReportResponse getApplicationAttemptReport(
10821078
ApplicationClientProtocol clientRMProxy =
10831079
getClientRMProxyForSubCluster(subClusterId);
10841080

1085-
GetApplicationAttemptReportResponse response;
1081+
GetApplicationAttemptReportResponse response = null;
10861082
try {
10871083
response = clientRMProxy.getApplicationAttemptReport(request);
10881084
} catch (Exception e) {
10891085
routerMetrics.incrAppAttemptsFailedRetrieved();
1090-
LOG.error("Unable to get the applicationAttempt report for {} "
1091-
+ "to SubCluster {}, error = {}.",
1092-
request.getApplicationAttemptId(), subClusterId.getId(), e);
1093-
throw e;
1086+
String msg = String.format(
1087+
"Unable to get the applicationAttempt report for %s to SubCluster %s.",
1088+
request.getApplicationAttemptId(), subClusterId.getId());
1089+
RouterServerUtil.logAndThrowException(msg, e);
10941090
}
10951091

10961092
if (response == null) {
@@ -1314,8 +1310,7 @@ public UpdateApplicationPriorityResponse updateApplicationPriority(
13141310
} catch (YarnException e) {
13151311
routerMetrics.incrUpdateAppPriorityFailedRetrieved();
13161312
RouterServerUtil.logAndThrowException("Application " +
1317-
request.getApplicationId() +
1318-
" does not exist in FederationStateStore.", e);
1313+
request.getApplicationId() + " does not exist in FederationStateStore.", e);
13191314
}
13201315

13211316
ApplicationClientProtocol clientRMProxy = getClientRMProxyForSubCluster(subClusterId);

0 commit comments

Comments
 (0)