diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/AMRMClientImpl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/AMRMClientImpl.java index 45279d48d2c..7994f9aa08a 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/AMRMClientImpl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/api/impl/AMRMClientImpl.java @@ -262,8 +262,30 @@ private RegisterApplicationMasterResponse registerApplicationMaster() @Override public void addSchedulingRequests( Collection schedulingRequests) { + Collection newSchedulingRequests = new LinkedList<>(); synchronized (this.batchedSchedulingRequests) { - this.batchedSchedulingRequests.add(schedulingRequests); + for (SchedulingRequest request: schedulingRequests) { + boolean isUpdated = false; + for (Collection batchedRequests: + batchedSchedulingRequests) { + for (SchedulingRequest batchedRequest: batchedRequests) { + if (isMatching(batchedRequest, request)) { + int numAllocations = batchedRequest.getResourceSizing() + .getNumAllocations() + request.getResourceSizing() + .getNumAllocations(); + batchedRequest.getResourceSizing().setNumAllocations( + numAllocations); + isUpdated = true; + LOG.info("SchedulingRequest " + batchedRequest + + " update the numAllocations as " + numAllocations); + } + } + } + if (isUpdated == false) { + newSchedulingRequests.add(request); + } + } + this.batchedSchedulingRequests.add(newSchedulingRequests); } } @@ -468,8 +490,13 @@ private void addToOutstandingSchedulingRequests( } } if (matchingReq != null) { - matchingReq.getResourceSizing().setNumAllocations( - req.getResourceSizing().getNumAllocations()); + int numAllocations = req.getResourceSizing().getNumAllocations() + + matchingReq.getResourceSizing().getNumAllocations(); + matchingReq.getResourceSizing().setNumAllocations(numAllocations); + LOG.info("SchedulingRequest " + req + " numAllocations updated from " + + req.getResourceSizing().getNumAllocations() + + " to " + numAllocations + " due to outstandingSchedRequests"); + req.getResourceSizing().setNumAllocations(numAllocations); } else { schedulingRequests.add(req); }