You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/06/01 08:28:56 UTC

[GitHub] [flink] zhuzhurk commented on a change in pull request #12256: [FLINK-17018][runtime] Allocates slots in bulks for pipelined region scheduling

zhuzhurk commented on a change in pull request #12256:
URL: https://github.com/apache/flink/pull/12256#discussion_r433106488



##########
File path: flink-runtime/src/main/java/org/apache/flink/runtime/scheduler/DefaultExecutionSlotAllocator.java
##########
@@ -96,52 +97,88 @@ public DefaultExecutionSlotAllocator(
 
 			LOG.debug("Allocate slot with id {} for execution {}", slotRequestId, executionVertexId);
 
-			CompletableFuture<LogicalSlot> slotFuture = calculatePreferredLocations(
+			final CompletableFuture<SlotProfile> slotProfileFuture = createSlotProfile(
+				schedulingRequirements,
+				Collections.emptySet(),
+				schedulingRequirements.getPhysicalSlotResourceProfile(),
+				allPreviousAllocationIds);
+
+			final CompletableFuture<LogicalSlot> slotFuture = slotProfileFuture.thenCompose(
+				slotProfile ->
+					slotProviderStrategy.allocateSlot(
+						slotRequestId,
+						new ScheduledUnit(
+							executionVertexId,
+							slotSharingGroupId,
+							schedulingRequirements.getCoLocationConstraint()),
+						slotProfile));
+
+			final SlotExecutionVertexAssignment slotExecutionVertexAssignment =
+				createAndRegisterSlotExecutionVertexAssignment(
 					executionVertexId,
-					schedulingRequirements.getPreferredLocations(),
-					inputsLocationsRetriever,
-					Collections.emptySet()).thenCompose(
-							(Collection<TaskManagerLocation> preferredLocations) ->
-								slotProviderStrategy.allocateSlot(
-									slotRequestId,
-									new ScheduledUnit(
-										executionVertexId,
-										slotSharingGroupId,
-										schedulingRequirements.getCoLocationConstraint()),
-									SlotProfile.priorAllocation(
-										schedulingRequirements.getTaskResourceProfile(),
-										schedulingRequirements.getPhysicalSlotResourceProfile(),
-										preferredLocations,
-										Collections.singletonList(schedulingRequirements.getPreviousAllocationId()),
-										allPreviousAllocationIds)));
-
-			SlotExecutionVertexAssignment slotExecutionVertexAssignment =
-					new SlotExecutionVertexAssignment(executionVertexId, slotFuture);
-			// add to map first to avoid the future completed before added.
-			pendingSlotAssignments.put(executionVertexId, slotExecutionVertexAssignment);
-
-			slotFuture.whenComplete(
-					(ignored, throwable) -> {
-						pendingSlotAssignments.remove(executionVertexId);
-						if (throwable != null) {
-							slotProviderStrategy.cancelSlotRequest(slotRequestId, slotSharingGroupId, throwable);
-						}
-					});
+					slotFuture,
+					slotRequestId,
+					slotSharingGroupId);
 
 			slotExecutionVertexAssignments.add(slotExecutionVertexAssignment);
 		}
 
 		return slotExecutionVertexAssignments;
 	}
 
-	private void validateSchedulingRequirements(Collection<ExecutionVertexSchedulingRequirements> schedulingRequirements) {
+	protected void validateSchedulingRequirements(Collection<ExecutionVertexSchedulingRequirements> schedulingRequirements) {
 		schedulingRequirements.stream()
 			.map(ExecutionVertexSchedulingRequirements::getExecutionVertexId)
 			.forEach(id -> checkState(
 				!pendingSlotAssignments.containsKey(id),
 				"BUG: vertex %s tries to allocate a slot when its previous slot request is still pending", id));
 	}
 
+	protected CompletableFuture<SlotProfile> createSlotProfile(

Review comment:
       PR #12423 is opened which is based on this PR.




----------------------------------------------------------------
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:
users@infra.apache.org