tillrohrmann commented on a change in pull request #11353: [FLINK-16438][yarn] 
Make YarnResourceManager starts workers using WorkerResourceSpec requested by 
SlotManager
URL: https://github.com/apache/flink/pull/11353#discussion_r409608614
 
 

 ##########
 File path: 
flink-yarn/src/main/java/org/apache/flink/yarn/YarnResourceManager.java
 ##########
 @@ -552,38 +581,44 @@ private FinalApplicationStatus 
getYarnStatus(ApplicationStatus status) {
         * Request new container if pending containers cannot satisfy pending 
slot requests.
         */
        private void requestYarnContainerIfRequired() {
-               int requiredTaskManagers = getNumberRequiredWorkers();
-
-               while (requiredTaskManagers-- > numPendingContainerRequests) {
-                       requestYarnContainer();
-               }
+               
getNumberRequiredWorkersPerWorkerResourceSpec().entrySet().stream()
+                       .filter(entry -> entry.getValue() > 
getNumPendingWorkersFor(entry.getKey()))
+                       .forEach(entry -> requestYarnContainer(entry.getKey()));
 
 Review comment:
   `forEach` is always an indicator that one could do the same with a `while` 
loop. In this case I would suggest to keep it simple and stupid:
   
   ```suggestion
                for (Map.Entry<WorkerResourceSpec, Integer> 
requiredWorkersPerResourceSpec : 
getNumberRequiredWorkersPerWorkerResourceSpec().entrySet()) {
                        final WorkerResourceSpec workerResourceSpec = 
requiredWorkersPerResourceSpec.getKey();
                        while (requiredWorkersPerResourceSpec.getValue() > 
getNumPendingWorkersFor(workerResourceSpec)) {
                                requestYarnContainer(workerResourceSpec);
                        }
                }
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to