flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GJL <...@git.apache.org>
Subject [GitHub] flink pull request #5091: [FLINK-7956] [flip6] Add support for queued schedu...
Date Thu, 07 Dec 2017 17:37:30 GMT
Github user GJL commented on a diff in the pull request:

    https://github.com/apache/flink/pull/5091#discussion_r155590317
  
    --- Diff: flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPool.java
---
    @@ -266,104 +279,367 @@ public void disconnectResourceManager() {
     	// ------------------------------------------------------------------------
     
     	@Override
    -	public CompletableFuture<SimpleSlot> allocateSlot(
    -			SlotRequestID requestId,
    -			ScheduledUnit task,
    -			ResourceProfile resources,
    -			Iterable<TaskManagerLocation> locationPreferences,
    +	public CompletableFuture<LogicalSlot> allocateSlot(
    +			SlotRequestId slotRequestId,
    +			ScheduledUnit scheduledUnit,
    +			ResourceProfile resourceProfile,
    +			Collection<TaskManagerLocation> locationPreferences,
    +			boolean allowQueuedScheduling,
     			Time timeout) {
     
    -		return internalAllocateSlot(requestId, task, resources, locationPreferences);
    +		return internalAllocateSlot(
    +			slotRequestId,
    +			scheduledUnit,
    +			resourceProfile,
    +			locationPreferences,
    +			allowQueuedScheduling);
     	}
     
    -	@Override
    -	public void returnAllocatedSlot(Slot slot) {
    -		internalReturnAllocatedSlot(slot);
    +	private CompletableFuture<LogicalSlot> internalAllocateSlot(
    +			SlotRequestId slotRequestId,
    +			ScheduledUnit task,
    +			ResourceProfile resourceProfile,
    +			Collection<TaskManagerLocation> locationPreferences,
    +			boolean allowQueuedScheduling) {
    +
    +		final SlotSharingGroupId slotSharingGroupId = task.getSlotSharingGroupId();
    +
    +		if (slotSharingGroupId != null) {
    +			// allocate slot with slot sharing
    +			final SlotSharingManager multiTaskSlotManager = slotSharingManagers.computeIfAbsent(
    +				slotSharingGroupId,
    +				id -> new SlotSharingManager(
    +					id,
    +					this,
    +					providerAndOwner));
    +
    +			final SlotSharingManager.MultiTaskSlotLocality multiTaskSlotFuture;
    +
    +			try {
    +				if (task.getCoLocationConstraint() != null) {
    +					multiTaskSlotFuture = allocateCoLocatedMultiTaskSlot(
    +						task.getCoLocationConstraint(),
    +						multiTaskSlotManager,
    +						resourceProfile,
    +						locationPreferences,
    +						allowQueuedScheduling);
    +				} else {
    +					multiTaskSlotFuture = allocateMultiTaskSlot(
    +						task.getJobVertexId(), multiTaskSlotManager,
    +						resourceProfile,
    +						locationPreferences,
    +						allowQueuedScheduling);
    +				}
    +			} catch (NoResourceAvailableException noResourceException) {
    +				return FutureUtils.completedExceptionally(noResourceException);
    +			}
    +
    +			// sanity check
    +			Preconditions.checkState(!multiTaskSlotFuture.getMultiTaskSlot().contains(task.getJobVertexId()));
    +
    +			final SlotSharingManager.SingleTaskSlot leave = multiTaskSlotFuture.getMultiTaskSlot().allocateSingleTaskSlot(
    --- End diff --
    
    nit: variable name should be *leaf* 
    
    https://www.dict.cc/?s=leaf


---

Mime
View raw message