slfan1989 commented on code in PR #4892:
URL: https://github.com/apache/hadoop/pull/4892#discussion_r985217861
##########
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router/src/main/java/org/apache/hadoop/yarn/server/router/webapp/FederationInterceptorREST.java:
##########
@@ -1456,28 +1460,178 @@ public Response
cancelDelegationToken(HttpServletRequest hsr)
@Override
public Response createNewReservation(HttpServletRequest hsr)
throws AuthorizationException, IOException, InterruptedException {
- throw new NotImplementedException("Code is not implemented");
+ long startTime = clock.getTime();
+
+ Map<SubClusterId, SubClusterInfo> subClustersActive;
+ try {
+ subClustersActive = federationFacade.getSubClusters(true);
+ } catch (YarnException e) {
+ routerMetrics.incrGetNewReservationFailedRetrieved();
+ return Response.status(Status.INTERNAL_SERVER_ERROR).
+ entity(e.getLocalizedMessage()).build();
+ }
+
+ List<SubClusterId> blacklist = new ArrayList<>();
+
+ for (int i = 0; i < numSubmitRetries; ++i) {
+ SubClusterId subClusterId = null;
+ try {
+ subClusterId = getRandomActiveSubCluster(subClustersActive, blacklist);
+ SubClusterInfo subClusterInfo = subClustersActive.get(subClusterId);
+ DefaultRequestInterceptorREST interceptor =
getOrCreateInterceptorForSubCluster(
+ subClusterId, subClusterInfo.getRMWebServiceAddress());
+ Response response = interceptor.createNewReservation(hsr);
+ LOG.info("createNewReservation try #{} on SubCluster {}.", i,
subClusterId);
+ if (response != null && response.getStatus() ==
HttpServletResponse.SC_OK) {
+ long stopTime = clock.getTime();
+ routerMetrics.succeededGetNewReservationRetrieved(stopTime -
startTime);
+ return response;
+ } else {
+ // Empty response from the ResourceManager.
+ // Blacklist this subCluster for this request.
+ blacklist.add(subClusterId);
+ }
+ } catch (YarnException e) {
+ routerMetrics.incrGetNewReservationFailedRetrieved();
+ subClustersActive.remove(subClusterId);
Review Comment:
In this part of the code `getRandomActiveSubCluster`, After removeAll
blackList from activeSubclusters, we should check whether there are any
available SubClusterIds, because all SubClusterIds may be added to the
blacklist.
--
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]