slfan1989 commented on code in PR #4618:
URL: https://github.com/apache/hadoop/pull/4618#discussion_r929582201
##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/clientrm/FederationClientInterceptor.java:
##########
@@ -280,47 +281,47 @@ private SubClusterId getRandomActiveSubCluster(
public GetNewApplicationResponse getNewApplication(
GetNewApplicationRequest request) throws YarnException, IOException {
- long startTime = clock.getTime();
+ if (request == null) {
+ routerMetrics.incrAppsFailedCreated();
+ String errMsg = "Missing getNewApplication request.";
+ RouterAuditLogger.logFailure(user.getShortUserName(), GET_NEW_APP,
UNKNOWN,
+ TARGET_CLIENT_RM_SERVICE, errMsg);
+ RouterServerUtil.logAndThrowException(errMsg, null);
+ }
+ long startTime = clock.getTime();
Map<SubClusterId, SubClusterInfo> subClustersActive =
federationFacade.getSubClusters(true);
+ GetNewApplicationResponse response = null;
+
for (int i = 0; i < numSubmitRetries; ++i) {
SubClusterId subClusterId = getRandomActiveSubCluster(subClustersActive);
- LOG.debug(
- "getNewApplication try #{} on SubCluster {}", i, subClusterId);
- ApplicationClientProtocol clientRMProxy =
- getClientRMProxyForSubCluster(subClusterId);
- GetNewApplicationResponse response = null;
+ LOG.info("getNewApplication try #{} on SubCluster {}.", i, subClusterId);
+ ApplicationClientProtocol clientRMProxy =
getClientRMProxyForSubCluster(subClusterId);
+ response = null;
try {
response = clientRMProxy.getNewApplication(request);
} catch (Exception e) {
- LOG.warn("Unable to create a new ApplicationId in SubCluster "
- + subClusterId.getId(), e);
+ LOG.warn("Unable to create a new ApplicationId in SubCluster {}.",
subClusterId.getId(), e);
+ subClustersActive.remove(subClusterId);
}
if (response != null) {
-
long stopTime = clock.getTime();
routerMetrics.succeededAppsCreated(stopTime - startTime);
- RouterAuditLogger.logSuccess(user.getShortUserName(),
- RouterAuditLogger.AuditConstants.GET_NEW_APP,
- "RouterClientRMService", response.getApplicationId());
+ RouterAuditLogger.logSuccess(user.getShortUserName(), GET_NEW_APP,
+ TARGET_CLIENT_RM_SERVICE, response.getApplicationId());
return response;
- } else {
- // Empty response from the ResourceManager.
- // Blacklist this subcluster for this request.
- subClustersActive.remove(subClusterId);
}
-
}
routerMetrics.incrAppsFailedCreated();
- String errMsg = "Fail to create a new application.";
- RouterAuditLogger.logFailure(user.getShortUserName(),
- RouterAuditLogger.AuditConstants.GET_NEW_APP, "UNKNOWN",
- "RouterClientRMService", errMsg);
- throw new YarnException(errMsg);
+ String errMsg = "Failed to create a new application.";
+ RouterAuditLogger.logFailure(user.getShortUserName(), GET_NEW_APP, UNKNOWN,
+ TARGET_CLIENT_RM_SERVICE, errMsg);
+ RouterServerUtil.logAndThrowException(errMsg, null);
+ return response;
Review Comment:
Your suggestion is right, I will throw exception directly,thank you.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]