tillrohrmann commented on a change in pull request #9928: [FLINK-12122] Add 
support for spreading slots out across all TaskExecutors
URL: https://github.com/apache/flink/pull/9928#discussion_r338519275
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/slotmanager/SlotManagerImpl.java
 ##########
 @@ -746,26 +747,28 @@ private void updateSlotState(
         */
        private void internalRequestSlot(PendingSlotRequest pendingSlotRequest) 
throws ResourceManagerException {
                final ResourceProfile resourceProfile = 
pendingSlotRequest.getResourceProfile();
-               TaskManagerSlot taskManagerSlot = 
findMatchingSlot(resourceProfile);
 
-               if (taskManagerSlot != null) {
-                       allocateSlot(taskManagerSlot, pendingSlotRequest);
-               } else {
-                       Optional<PendingTaskManagerSlot> 
pendingTaskManagerSlotOptional = 
findFreeMatchingPendingTaskManagerSlot(resourceProfile);
+               OptionalConsumer.of(findMatchingSlot(resourceProfile))
+                       .ifPresent(taskManagerSlot -> 
allocateSlot(taskManagerSlot, pendingSlotRequest))
+                       .ifNotPresent(() -> 
fulfillPendingSlotRequestWithPendingTaskManagerSlot(pendingSlotRequest));
+       }
 
-                       if (!pendingTaskManagerSlotOptional.isPresent()) {
-                               pendingTaskManagerSlotOptional = 
allocateResource(resourceProfile);
-                       }
+       private void 
fulfillPendingSlotRequestWithPendingTaskManagerSlot(PendingSlotRequest 
pendingSlotRequest) throws ResourceManagerException {
+               ResourceProfile resourceProfile = 
pendingSlotRequest.getResourceProfile();
+               Optional<PendingTaskManagerSlot> pendingTaskManagerSlotOptional 
= findFreeMatchingPendingTaskManagerSlot(resourceProfile);
 
-                       if (pendingTaskManagerSlotOptional.isPresent()) {
-                               
assignPendingTaskManagerSlot(pendingSlotRequest, 
pendingTaskManagerSlotOptional.get());
-                       }
-                       else {
-                               // request can not be fulfilled by any free 
slot or pending slot that can be allocated,
-                               // check whether it can be fulfilled by 
allocated slots
-                               if (failUnfulfillableRequest && 
!isFulfillableByRegisteredSlots(pendingSlotRequest.getResourceProfile())) {
-                                       throw new 
UnfulfillableSlotRequestException(pendingSlotRequest.getAllocationId(), 
pendingSlotRequest.getResourceProfile());
-                               }
+               if (!pendingTaskManagerSlotOptional.isPresent()) {
+                       pendingTaskManagerSlotOptional = 
allocateResource(resourceProfile);
+               }
+
+               if (pendingTaskManagerSlotOptional.isPresent()) {
 
 Review comment:
   Will change it.

----------------------------------------------------------------
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