/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.flink.runtime.executiongraph;

import org.apache.flink.api.common.time.Time;
import org.apache.flink.runtime.clusterframework.types.SlotProfile;
import org.apache.flink.runtime.instance.SlotSharingGroupId;
import org.apache.flink.runtime.jobgraph.ScheduleMode;
import org.apache.flink.runtime.jobmanager.scheduler.ScheduledUnit;
import org.apache.flink.runtime.jobmaster.LogicalSlot;
import org.apache.flink.runtime.jobmaster.SlotRequestId;
import org.apache.flink.runtime.jobmaster.slotpool.SlotProvider;
import org.apache.flink.util.Preconditions;

import javax.annotation.Nullable;

import java.util.concurrent.CompletableFuture;

/**
 * Strategy to switch between different {@link SlotProvider} allocation strategies.
 */
abstract class SlotProviderStrategy {

	protected final SlotProvider slotProvider;

	protected final boolean allowQueuedScheduling;

	SlotProviderStrategy(SlotProvider slotProvider, boolean allowQueuedScheduling) {
		this.slotProvider = Preconditions.checkNotNull(slotProvider);
		this.allowQueuedScheduling = allowQueuedScheduling;
	}

	boolean isQueuedSchedulingAllowed() {
		return allowQueuedScheduling;
	}

	/**
	 * Allocating slot with specific requirement.
	 *
	 * @param slotRequestId identifying the slot request
	 * @param scheduledUnit The task to allocate the slot for
	 * @param slotProfile profile of the requested slot
	 * @return The future of the allocation
	 */
	abstract CompletableFuture<LogicalSlot> allocateSlot(
		SlotRequestId slotRequestId,
		ScheduledUnit scheduledUnit,
		SlotProfile slotProfile);

	/**
	 * Cancels the slot request with the given {@link SlotRequestId} and {@link SlotSharingGroupId}.
	 *
	 * @param slotRequestId identifying the slot request to cancel
	 * @param slotSharingGroupId identifying the slot request to cancel
	 * @param cause of the cancellation
	 */
	void cancelSlotRequest(
		SlotRequestId slotRequestId,
		@Nullable SlotSharingGroupId slotSharingGroupId,
		Throwable cause) {
		slotProvider.cancelSlotRequest(slotRequestId, slotSharingGroupId, cause);
	}

	static SlotProviderStrategy from(
		ScheduleMode scheduleMode,
		SlotProvider slotProvider,
		Time allocationTimeout,
		boolean allowQueuedScheduling) {

		switch (scheduleMode) {
			case LAZY_FROM_SOURCES_WITH_BATCH_SLOT_REQUEST:
				return new BatchSlotProviderStrategy(slotProvider, allowQueuedScheduling);
			case LAZY_FROM_SOURCES:
			case EAGER:
				return new NormalSlotProviderStrategy(slotProvider, allocationTimeout, allowQueuedScheduling);
			default:
				throw new IllegalArgumentException(String.format("Unknown scheduling mode: %s", scheduleMode));
		}
	}

	SlotProvider asSlotProvider() {
		return slotProvider;
	}

	static class BatchSlotProviderStrategy extends SlotProviderStrategy {

		BatchSlotProviderStrategy(SlotProvider slotProvider, boolean allowQueuedScheduling) {
			super(slotProvider, allowQueuedScheduling);
		}

		@Override
		public CompletableFuture<LogicalSlot> allocateSlot(SlotRequestId slotRequestId, ScheduledUnit scheduledUnit, SlotProfile slotProfile) {
			return slotProvider.allocateBatchSlot(slotRequestId, scheduledUnit, slotProfile, allowQueuedScheduling);
		}
	}

	static class NormalSlotProviderStrategy extends SlotProviderStrategy {
		private final Time allocationTimeout;

		NormalSlotProviderStrategy(SlotProvider slotProvider, Time allocationTimeout, boolean allowQueuedScheduling) {
			super(slotProvider, allowQueuedScheduling);
			this.allocationTimeout = Preconditions.checkNotNull(allocationTimeout);
		}

		@Override
		public CompletableFuture<LogicalSlot> allocateSlot(SlotRequestId slotRequestId, ScheduledUnit scheduledUnit, SlotProfile slotProfile) {
			return slotProvider.allocateSlot(slotRequestId, scheduledUnit, slotProfile, allowQueuedScheduling, allocationTimeout);
		}
	}
}

@@ -1545,16 +1545,23 @@
 es.%0A */%0A
+public 
 abstract
@@ -2233,16 +2233,23 @@
 n%0A%09 */%0A%09
+public 
 abstract
@@ -2668,16 +2668,23 @@
 n%0A%09 */%0A%09
+public 
 void can
@@ -2879,24 +2879,31 @@
 ause);%0A%09%7D%0A%0A%09
+public 
 static SlotP

Make SlotProviderStrategy class public