Java Code Examples for org.apache.flink.runtime.jobmanager.scheduler.ScheduledUnit#getSlotSharingGroupId()

The following examples show how to use org.apache.flink.runtime.jobmanager.scheduler.ScheduledUnit#getSlotSharingGroupId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SchedulerImpl.java    From flink with Apache License 2.0 6 votes vote down vote up
private void internalAllocateSlot(
		CompletableFuture<LogicalSlot> allocationResultFuture,
		SlotRequestId slotRequestId,
		ScheduledUnit scheduledUnit,
		SlotProfile slotProfile,
		Time allocationTimeout) {
	CompletableFuture<LogicalSlot> allocationFuture = scheduledUnit.getSlotSharingGroupId() == null ?
		allocateSingleSlot(slotRequestId, slotProfile, allocationTimeout) :
		allocateSharedSlot(slotRequestId, scheduledUnit, slotProfile, allocationTimeout);

	allocationFuture.whenComplete((LogicalSlot slot, Throwable failure) -> {
		if (failure != null) {
			cancelSlotRequest(
				slotRequestId,
				scheduledUnit.getSlotSharingGroupId(),
				failure);
			allocationResultFuture.completeExceptionally(failure);
		} else {
			allocationResultFuture.complete(slot);
		}
	});
}
 
Example 2
Source File: SchedulerImpl.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public CompletableFuture<LogicalSlot> allocateSlot(
	SlotRequestId slotRequestId,
	ScheduledUnit scheduledUnit,
	SlotProfile slotProfile,
	boolean allowQueuedScheduling,
	Time allocationTimeout) {
	log.debug("Received slot request [{}] for task: {}", slotRequestId, scheduledUnit.getTaskToExecute());

	componentMainThreadExecutor.assertRunningInMainThread();

	final CompletableFuture<LogicalSlot> allocationResultFuture = new CompletableFuture<>();

	CompletableFuture<LogicalSlot> allocationFuture = scheduledUnit.getSlotSharingGroupId() == null ?
		allocateSingleSlot(slotRequestId, slotProfile, allowQueuedScheduling, allocationTimeout) :
		allocateSharedSlot(slotRequestId, scheduledUnit, slotProfile, allowQueuedScheduling, allocationTimeout);

	allocationFuture.whenComplete((LogicalSlot slot, Throwable failure) -> {
		if (failure != null) {
			cancelSlotRequest(
				slotRequestId,
				scheduledUnit.getSlotSharingGroupId(),
				failure);
			allocationResultFuture.completeExceptionally(failure);
		} else {
			allocationResultFuture.complete(slot);
		}
	});

	return allocationResultFuture;
}
 
Example 3
Source File: SchedulerImpl.java    From flink with Apache License 2.0 5 votes vote down vote up
private void internalAllocateSlot(
		CompletableFuture<LogicalSlot> allocationResultFuture,
		SlotRequestId slotRequestId,
		ScheduledUnit scheduledUnit,
		SlotProfile slotProfile,
		boolean allowQueuedScheduling,
		Time allocationTimeout) {
	CompletableFuture<LogicalSlot> allocationFuture = scheduledUnit.getSlotSharingGroupId() == null ?
		allocateSingleSlot(slotRequestId, slotProfile, allowQueuedScheduling, allocationTimeout) :
		allocateSharedSlot(slotRequestId, scheduledUnit, slotProfile, allowQueuedScheduling, allocationTimeout);

	allocationFuture.whenComplete((LogicalSlot slot, Throwable failure) -> {
		if (failure != null) {
			Optional<SharedSlotOversubscribedException> sharedSlotOverAllocatedException =
					ExceptionUtils.findThrowable(failure, SharedSlotOversubscribedException.class);
			if (sharedSlotOverAllocatedException.isPresent() &&
					sharedSlotOverAllocatedException.get().canRetry()) {

				// Retry the allocation
				internalAllocateSlot(
						allocationResultFuture,
						slotRequestId,
						scheduledUnit,
						slotProfile,
						allowQueuedScheduling,
						allocationTimeout);
			} else {
				cancelSlotRequest(
						slotRequestId,
						scheduledUnit.getSlotSharingGroupId(),
						failure);
				allocationResultFuture.completeExceptionally(failure);
			}
		} else {
			allocationResultFuture.complete(slot);
		}
	});
}