azagrebin commented on a change in pull request #6734: [FLINK-9455][RM] Add 
support for multi task slot TaskExecutors
URL: https://github.com/apache/flink/pull/6734#discussion_r220105200
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/resourcemanager/slotmanager/SlotManager.java
 ##########
 @@ -530,14 +541,53 @@ private void registerSlot(
                        removeSlot(slotId);
                }
 
-               TaskManagerSlot slot = new TaskManagerSlot(
+               final TaskManagerSlot slot = 
createAndRegisterTaskManagerSlot(slotId, resourceProfile, 
taskManagerConnection);
+
+               final PendingTaskManagerSlot pendingTaskManagerSlot;
+
+               if (allocationId == null) {
+                       pendingTaskManagerSlot = 
findExactlyMatchingPendingTaskManagerSlot(resourceProfile);
+               } else {
+                       pendingTaskManagerSlot = null;
+               }
+
+               if (pendingTaskManagerSlot == null) {
+                       updateSlot(slotId, allocationId, jobId);
+               } else {
+                       
pendingSlots.remove(pendingTaskManagerSlot.getTaskManagerSlotId());
+                       final PendingSlotRequest assignedPendingSlotRequest = 
pendingTaskManagerSlot.getAssignedPendingSlotRequest();
+
+                       if (assignedPendingSlotRequest == null) {
+                               handleFreeSlot(slot);
+                       } else {
+                               
assignedPendingSlotRequest.unassignPendingTaskManagerSlot();
+                               allocateSlot(slot, assignedPendingSlotRequest);
+                       }
+               }
+       }
+
+       @Nonnull
+       private TaskManagerSlot createAndRegisterTaskManagerSlot(SlotID slotId, 
ResourceProfile resourceProfile, TaskExecutorConnection taskManagerConnection) {
+               final TaskManagerSlot slot = new TaskManagerSlot(
                        slotId,
                        resourceProfile,
                        taskManagerConnection);
-
                slots.put(slotId, slot);
+               return slot;
+       }
+
+       @Nullable
+       private PendingTaskManagerSlot 
findExactlyMatchingPendingTaskManagerSlot(ResourceProfile resourceProfile) {
+               for (PendingTaskManagerSlot pendingTaskManagerSlot : 
pendingSlots.values()) {
+                       if 
(pendingTaskManagerSlot.getResourceProfile().equals(resourceProfile)) {
+                               return pendingTaskManagerSlot;
+                       }
+               }
+
+               return null;
+       }
 
-               updateSlot(slotId, allocationId, jobId);
+       private void completePendingTaskManagerSlot(ResourceProfile 
resourceProfile) {
 
 Review comment:
   is this `completePendingTaskManagerSlot` some leftover? looks unused

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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