You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by sr...@apache.org on 2019/02/15 08:42:35 UTC

[flink] branch master updated: [FLINK-10431] Extract scheduling-related code from SlotPool

This is an automated email from the ASF dual-hosted git repository.

srichter pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/master by this push:
     new c60995d  [FLINK-10431] Extract scheduling-related code from SlotPool
c60995d is described below

commit c60995d60a3beabdbb624b8382fff63a8a371dea
Author: Stefan Richter <s....@data-artisans.com>
AuthorDate: Fri Oct 5 20:27:36 2018 +0200

    [FLINK-10431] Extract scheduling-related code from SlotPool
    
    This closes #7662.
---
 .../flink-datastream-allround-test/pom.xml         |    6 +
 .../streaming/tests/AllroundMiniClusterTest.java   |   81 +
 .../clusterframework/types/ResourceProfile.java    |    5 +
 .../flink/runtime/concurrent/FutureUtils.java      |   22 +-
 .../dispatcher/DefaultJobManagerRunnerFactory.java |    8 +-
 .../flink/runtime/executiongraph/Execution.java    |   27 +-
 .../runtime/executiongraph/ExecutionGraph.java     |    7 +-
 .../runtime/executiongraph/ExecutionJobVertex.java |    2 +
 .../runtime/executiongraph/ExecutionVertex.java    |    2 +-
 .../apache/flink/runtime/instance/Instance.java    |    9 +-
 .../apache/flink/runtime/instance/SimpleSlot.java  |   16 +-
 .../flink/runtime/instance/SimpleSlotContext.java  |   18 +
 .../instance/SlotSharingGroupAssignment.java       |    2 +-
 .../runtime/jobmanager/scheduler/Scheduler.java    |    8 +-
 .../apache/flink/runtime/jobmaster/JobMaster.java  |   62 +-
 .../flink/runtime/jobmaster/LogicalSlot.java       |   16 +-
 .../apache/flink/runtime/jobmaster/SlotInfo.java   |    8 +
 .../apache/flink/runtime/jobmaster/SlotOwner.java  |    5 +-
 .../factories/DefaultJobMasterServiceFactory.java  |    6 +
 .../runtime/jobmaster/slotpool/AllocatedSlot.java  |   57 +-
 .../jobmaster/slotpool/AllocatedSlotActions.java   |   16 +-
 .../slotpool/DefaultSchedulerFactory.java          |   57 +
 .../jobmaster/slotpool/DefaultSlotPoolFactory.java |   32 +-
 ...> LocationPreferenceSlotSelectionStrategy.java} |  115 +-
 .../{SlotInfo.java => slotpool/PhysicalSlot.java}  |   38 +-
 .../PreviousAllocationSchedulingStrategy.java      |  120 --
 .../PreviousAllocationSlotSelectionStrategy.java   |   83 +
 .../runtime/jobmaster/slotpool/Scheduler.java}     |   28 +-
 .../SchedulerFactory.java}                         |   18 +-
 .../runtime/jobmaster/slotpool/SchedulerImpl.java  |  521 ++++++
 .../jobmaster/slotpool/SchedulingStrategy.java     |   62 -
 .../jobmaster/slotpool/SingleLogicalSlot.java      |   33 +-
 .../jobmaster/slotpool/SlotAndLocality.java        |    6 +-
 .../flink/runtime/jobmaster/slotpool/SlotPool.java | 1728 +-------------------
 .../jobmaster/slotpool/SlotPoolGateway.java        |  161 --
 .../slotpool/{SlotPool.java => SlotPoolImpl.java}  |  837 +++-------
 .../runtime/jobmaster/slotpool/SlotProvider.java   |   30 +-
 .../jobmaster/slotpool/SlotSelectionStrategy.java  |   78 +
 .../jobmaster/slotpool/SlotSharingManager.java     |   73 +-
 ...ocationPreferenceSlotSelectionStrategyTest.java |  108 ++
 ...reviousAllocationSlotSelectionStrategyTest.java |   87 +
 .../clusterframework/types/SlotProfileTest.java    |  184 ---
 .../types/SlotSelectionStrategyTestBase.java       |   79 +
 .../executiongraph/ArchivedExecutionGraphTest.java |    2 +-
 ...ncurrentFailoverStrategyExecutionGraphTest.java |   10 +-
 .../ExecutionGraphCoLocationRestartTest.java       |   48 +-
 .../ExecutionGraphDeploymentTest.java              |    2 +-
 .../executiongraph/ExecutionGraphRestartTest.java  |   12 +-
 .../runtime/executiongraph/ExecutionTest.java      |   56 +-
 .../executiongraph/ExecutionVertexCancelTest.java  |   15 +-
 .../ExecutionVertexSchedulingTest.java             |    9 +-
 .../runtime/executiongraph/FailoverRegionTest.java |   20 +-
 .../executiongraph/FinalizeOnMasterTest.java       |    2 +-
 .../executiongraph/GlobalModVersionTest.java       |    4 +-
 .../executiongraph/ProgrammedSlotProvider.java     |   30 +-
 .../TestingComponentMainThreadExecutor.java        |   11 +-
 .../executiongraph/TestingSlotProvider.java        |    7 +-
 .../executiongraph/utils/SimpleSlotProvider.java   |   13 +-
 .../flink/runtime/instance/InstanceTest.java       |   11 +-
 .../scheduler/ScheduleWithCoLocationHintTest.java  |    2 +-
 .../scheduler/SchedulerIsolatedTasksTest.java      |   57 +-
 .../jobmanager/scheduler/SchedulerTestBase.java    |  159 +-
 .../runtime/jobmanager/slots/DummySlotOwner.java   |    5 +-
 .../runtime/jobmanager/slots/TestingSlotOwner.java |    5 +-
 .../flink/runtime/jobmaster/JobMasterTest.java     |   10 +-
 .../flink/runtime/jobmaster/TestingPayload.java    |    8 +-
 .../jobmaster/slotpool/AllocatedSlotsTest.java     |    2 +-
 .../jobmaster/slotpool/AvailableSlotsTest.java     |   47 +-
 .../runtime/jobmaster/slotpool/DummyPayload.java   |   25 +-
 .../jobmaster/slotpool/SingleLogicalSlotTest.java  |   51 +-
 .../jobmaster/slotpool/SlotPoolCoLocationTest.java |   31 +-
 ...lRpcTest.java => SlotPoolInteractionsTest.java} |  199 +--
 .../jobmaster/slotpool/SlotPoolResource.java       |   42 +-
 .../slotpool/SlotPoolSlotSharingTest.java          |   50 +-
 .../runtime/jobmaster/slotpool/SlotPoolTest.java   |  340 ++--
 .../jobmaster/slotpool/SlotSharingManagerTest.java |   69 +-
 .../slotpool/TestingAllocatedSlotActions.java      |   18 +-
 77 files changed, 2227 insertions(+), 4006 deletions(-)

diff --git a/flink-end-to-end-tests/flink-datastream-allround-test/pom.xml b/flink-end-to-end-tests/flink-datastream-allround-test/pom.xml
index 757d61e..22b4497 100644
--- a/flink-end-to-end-tests/flink-datastream-allround-test/pom.xml
+++ b/flink-end-to-end-tests/flink-datastream-allround-test/pom.xml
@@ -51,6 +51,12 @@ under the License.
 			<artifactId>flink-avro</artifactId>
 			<version>${project.version}</version>
 		</dependency>
+		<dependency>
+			<groupId>org.apache.flink</groupId>
+			<artifactId>flink-test-utils_2.11</artifactId>
+			<version>${project.version}</version>
+			<scope>test</scope>
+		</dependency>
 	</dependencies>
 
 	<build>
diff --git a/flink-end-to-end-tests/flink-datastream-allround-test/src/test/java/org/apache/flink/streaming/tests/AllroundMiniClusterTest.java b/flink-end-to-end-tests/flink-datastream-allround-test/src/test/java/org/apache/flink/streaming/tests/AllroundMiniClusterTest.java
new file mode 100644
index 0000000..c0a2e4b
--- /dev/null
+++ b/flink-end-to-end-tests/flink-datastream-allround-test/src/test/java/org/apache/flink/streaming/tests/AllroundMiniClusterTest.java
@@ -0,0 +1,81 @@
+/*
+ * 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.streaming.tests;
+
+import org.apache.flink.configuration.CheckpointingOptions;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.runtime.testutils.MiniClusterResourceConfiguration;
+import org.apache.flink.test.util.MiniClusterWithClientResource;
+import org.apache.flink.util.TestLogger;
+
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+
+import java.io.File;
+
+import static org.apache.flink.configuration.JobManagerOptions.EXECUTION_FAILOVER_STRATEGY;
+
+/**
+ * DataStreamAllroundTestProgram on MiniCluster for manual debugging purposes.
+ */
+@Ignore("Test is already part of end-to-end tests. This is for manual debugging.")
+public class AllroundMiniClusterTest extends TestLogger {
+
+	@BeforeClass
+	public static void beforeClass() {
+		org.apache.log4j.PropertyConfigurator.configure(
+			AllroundMiniClusterTest.class.getClassLoader().getResource("log4j.properties"));
+	}
+
+	@ClassRule
+	public static MiniClusterWithClientResource miniClusterResource = new MiniClusterWithClientResource(
+		new MiniClusterResourceConfiguration.Builder()
+			.setNumberTaskManagers(4)
+			.setNumberSlotsPerTaskManager(2)
+			.setConfiguration(createConfiguration())
+			.build());
+
+	@ClassRule
+	public static TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+	private static Configuration createConfiguration() {
+		Configuration configuration = new Configuration();
+		configuration.setBoolean(CheckpointingOptions.LOCAL_RECOVERY, true);
+		configuration.setString(EXECUTION_FAILOVER_STRATEGY.key(), "region");
+		return configuration;
+	}
+
+	@Test
+	public void runTest() throws Exception {
+		File checkpointDir = temporaryFolder.newFolder();
+		DataStreamAllroundTestProgram.main(
+			new String[]{
+				"--environment.parallelism", "8",
+				"--state_backend.checkpoint_directory", checkpointDir.toURI().toString(),
+				"--state_backend", "rocks",
+				"--state_backend.rocks.incremental", "true",
+				"--test.simulate_failure", "true",
+				"--test.simulate_failure.max_failures", String.valueOf(Integer.MAX_VALUE),
+				"--test.simulate_failure.num_records", "100000"
+			});
+	}
+}
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/clusterframework/types/ResourceProfile.java b/flink-runtime/src/main/java/org/apache/flink/runtime/clusterframework/types/ResourceProfile.java
index 5b133e7..e0922c1 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/clusterframework/types/ResourceProfile.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/clusterframework/types/ResourceProfile.java
@@ -206,6 +206,11 @@ public class ResourceProfile implements Serializable, Comparable<ResourceProfile
 	 * @return true if the requirement is matched, otherwise false
 	 */
 	public boolean isMatching(ResourceProfile required) {
+
+		if (required == UNKNOWN) {
+			return true;
+		}
+
 		if (cpuCores >= required.getCpuCores() &&
 				heapMemoryInMB >= required.getHeapMemoryInMB() &&
 				directMemoryInMB >= required.getDirectMemoryInMB() &&
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/concurrent/FutureUtils.java b/flink-runtime/src/main/java/org/apache/flink/runtime/concurrent/FutureUtils.java
index 7e0bd08..61b88be 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/concurrent/FutureUtils.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/concurrent/FutureUtils.java
@@ -336,8 +336,28 @@ public class FutureUtils {
 	 * @return The timeout enriched future
 	 */
 	public static <T> CompletableFuture<T> orTimeout(CompletableFuture<T> future, long timeout, TimeUnit timeUnit) {
+		return orTimeout(future, timeout, timeUnit, Executors.directExecutor());
+	}
+
+	/**
+	 * Times the given future out after the timeout.
+	 *
+	 * @param future to time out
+	 * @param timeout after which the given future is timed out
+	 * @param timeUnit time unit of the timeout
+	 * @param timeoutFailExecutor executor that will complete the future exceptionally after the timeout is reached
+	 * @param <T> type of the given future
+	 * @return The timeout enriched future
+	 */
+	public static <T> CompletableFuture<T> orTimeout(
+		CompletableFuture<T> future,
+		long timeout,
+		TimeUnit timeUnit,
+		Executor timeoutFailExecutor) {
+
 		if (!future.isDone()) {
-			final ScheduledFuture<?> timeoutFuture = Delayer.delay(new Timeout(future), timeout, timeUnit);
+			final ScheduledFuture<?> timeoutFuture = Delayer.delay(
+				() -> timeoutFailExecutor.execute(new Timeout(future)), timeout, timeUnit);
 
 			future.whenComplete((T value, Throwable throwable) -> {
 				if (!timeoutFuture.isDone()) {
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/DefaultJobManagerRunnerFactory.java b/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/DefaultJobManagerRunnerFactory.java
index 97afe24..c6c537f 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/DefaultJobManagerRunnerFactory.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/dispatcher/DefaultJobManagerRunnerFactory.java
@@ -28,7 +28,9 @@ import org.apache.flink.runtime.jobmaster.JobMasterConfiguration;
 import org.apache.flink.runtime.jobmaster.factories.DefaultJobMasterServiceFactory;
 import org.apache.flink.runtime.jobmaster.factories.JobManagerJobMetricGroupFactory;
 import org.apache.flink.runtime.jobmaster.factories.JobMasterServiceFactory;
+import org.apache.flink.runtime.jobmaster.slotpool.DefaultSchedulerFactory;
 import org.apache.flink.runtime.jobmaster.slotpool.DefaultSlotPoolFactory;
+import org.apache.flink.runtime.jobmaster.slotpool.SchedulerFactory;
 import org.apache.flink.runtime.jobmaster.slotpool.SlotPoolFactory;
 import org.apache.flink.runtime.rpc.FatalErrorHandler;
 import org.apache.flink.runtime.rpc.RpcService;
@@ -52,13 +54,13 @@ public enum DefaultJobManagerRunnerFactory implements JobManagerRunnerFactory {
 
 		final JobMasterConfiguration jobMasterConfiguration = JobMasterConfiguration.fromConfiguration(configuration);
 
-		final SlotPoolFactory slotPoolFactory = DefaultSlotPoolFactory.fromConfiguration(
-			configuration,
-			rpcService);
+		final SlotPoolFactory slotPoolFactory = DefaultSlotPoolFactory.fromConfiguration(configuration);
+		final SchedulerFactory schedulerFactory = DefaultSchedulerFactory.fromConfiguration(configuration);
 
 		final JobMasterServiceFactory jobMasterFactory = new DefaultJobMasterServiceFactory(
 			jobMasterConfiguration,
 			slotPoolFactory,
+			schedulerFactory,
 			rpcService,
 			highAvailabilityServices,
 			jobManagerServices,
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/Execution.java b/flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/Execution.java
index ff212c2..91b3d2d 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/Execution.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/Execution.java
@@ -525,12 +525,12 @@ public class Execution implements AccessExecution, Archiveable<ArchivedExecution
 						slotProvider.allocateSlot(
 							slotRequestId,
 							toSchedule,
-							queued,
 							new SlotProfile(
 								ResourceProfile.UNKNOWN,
 								preferredLocations,
 								previousAllocationIDs,
 								allPreviousExecutionGraphAllocationIds),
+							queued,
 							allocationTimeout));
 
 			// register call back to cancel slot request in case that the execution gets canceled
@@ -545,9 +545,7 @@ public class Execution implements AccessExecution, Archiveable<ArchivedExecution
 				});
 
 			// This forces calls to the slot pool back into the main thread, for normal and exceptional completion
-			return FutureUtils.handleAsyncIfNotDone(
-				logicalSlotFuture,
-				mainThreadExecutor,
+			return logicalSlotFuture.handle(
 				(LogicalSlot logicalSlot, Throwable failure) -> {
 
 					if (failure != null) {
@@ -764,7 +762,7 @@ public class Execution implements AccessExecution, Archiveable<ArchivedExecution
 		final int numConsumers = allConsumers.size();
 
 		if (numConsumers > 1) {
-			failSync(new IllegalStateException("Currently, only a single consumer group per partition is supported."));
+			fail(new IllegalStateException("Currently, only a single consumer group per partition is supported."));
 		}
 		else if (numConsumers == 0) {
 			return;
@@ -884,20 +882,7 @@ public class Execution implements AccessExecution, Archiveable<ArchivedExecution
 	 * @param t The exception that caused the task to fail.
 	 */
 	@Override
-	public void failAsync(Throwable t) {
-		ComponentMainThreadExecutor mainThreadExecutor = vertex.getExecutionGraph().getJobMasterMainThreadExecutor();
-		mainThreadExecutor.execute(() -> failSync(t));
-	}
-
-	/**
-	 * This method fails the vertex due to an external condition. The task will move to state FAILED.
-	 * If the task was in state RUNNING or DEPLOYING before, it will send a cancel call to the TaskManager.
-	 * This method must be called from the current main thread, otherwise use {@link #failAsync(Throwable)}.
-	 *
-	 * @param t The exception that caused the task to fail.
-	 */
-	@Override
-	public void failSync(Throwable t) {
+	public void fail(Throwable t) {
 		processFail(t, false);
 	}
 
@@ -1262,7 +1247,7 @@ public class Execution implements AccessExecution, Archiveable<ArchivedExecution
 			cancelResultFuture.whenComplete(
 				(ack, failure) -> {
 					if (failure != null) {
-						failSync(new Exception("Task could not be canceled.", failure));
+						fail(new Exception("Task could not be canceled.", failure));
 					}
 				});
 		}
@@ -1299,7 +1284,7 @@ public class Execution implements AccessExecution, Archiveable<ArchivedExecution
 				(ack, failure) -> {
 					// fail if there was a failure
 					if (failure != null) {
-						failSync(new IllegalStateException("Update task on TaskManager " + taskManagerLocation +
+						fail(new IllegalStateException("Update task on TaskManager " + taskManagerLocation +
 							" failed due to:", failure));
 					}
 				}, getVertex().getExecutionGraph().getJobMasterMainThreadExecutor());
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/ExecutionGraph.java b/flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/ExecutionGraph.java
index bff3170..3a414a6 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/ExecutionGraph.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/ExecutionGraph.java
@@ -61,7 +61,7 @@ import org.apache.flink.runtime.jobgraph.tasks.CheckpointCoordinatorConfiguratio
 import org.apache.flink.runtime.jobmanager.scheduler.CoLocationGroup;
 import org.apache.flink.runtime.jobmanager.scheduler.LocationPreferenceConstraint;
 import org.apache.flink.runtime.jobmanager.scheduler.NoResourceAvailableException;
-import org.apache.flink.runtime.jobmaster.slotpool.SlotPool;
+import org.apache.flink.runtime.jobmaster.slotpool.Scheduler;
 import org.apache.flink.runtime.jobmaster.slotpool.SlotProvider;
 import org.apache.flink.runtime.query.KvStateLocationRegistry;
 import org.apache.flink.runtime.state.SharedStateRegistry;
@@ -1646,7 +1646,7 @@ public class ExecutionGraph implements AccessExecutionGraph {
 					default:
 						// we mark as failed and return false, which triggers the TaskManager
 						// to remove the task
-						attempt.failSync(new Exception("TaskManager sent illegal state update: " + state.getExecutionState()));
+						attempt.fail(new Exception("TaskManager sent illegal state update: " + state.getExecutionState()));
 						return false;
 				}
 			}
@@ -1775,8 +1775,7 @@ public class ExecutionGraph implements AccessExecutionGraph {
 	private Set<AllocationID> computeAllPriorAllocationIdsIfRequiredByScheduling() {
 		// This is a temporary optimization to avoid computing all previous allocations if not required
 		// This can go away when we progress with the implementation of the Scheduler.
-		if (slotProvider instanceof SlotPool.ProviderAndOwner
-			&& ((SlotPool.ProviderAndOwner) slotProvider).requiresPreviousAllocationsForScheduling()) {
+		if (slotProvider instanceof Scheduler && ((Scheduler) slotProvider).requiresPreviousExecutionGraphAllocations()) {
 			return computeAllPriorAllocationIds();
 		} else {
 			return Collections.emptySet();
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/ExecutionJobVertex.java b/flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/ExecutionJobVertex.java
index 94ee45d..9b81584 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/ExecutionJobVertex.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/ExecutionJobVertex.java
@@ -516,6 +516,8 @@ public class ExecutionJobVertex implements AccessExecutionJobVertex, Archiveable
 			@Nonnull Set<AllocationID> allPreviousExecutionGraphAllocationIds,
 			Time allocationTimeout) {
 		final ExecutionVertex[] vertices = this.taskVertices;
+
+		@SuppressWarnings("unchecked")
 		final CompletableFuture<Execution>[] slots = new CompletableFuture[vertices.length];
 
 		// try to acquire a slot future for each execution.
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/ExecutionVertex.java b/flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/ExecutionVertex.java
index cb93c73..3a3391f 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/ExecutionVertex.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/executiongraph/ExecutionVertex.java
@@ -669,7 +669,7 @@ public class ExecutionVertex implements AccessExecutionVertex, Archiveable<Archi
 	}
 
 	public void fail(Throwable t) {
-		this.currentExecution.failSync(t);
+		this.currentExecution.fail(t);
 	}
 
 	/**
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/instance/Instance.java b/flink-runtime/src/main/java/org/apache/flink/runtime/instance/Instance.java
index 0878f75..652c22a 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/instance/Instance.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/instance/Instance.java
@@ -36,7 +36,6 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Queue;
 import java.util.Set;
-import java.util.concurrent.CompletableFuture;
 
 import static org.apache.flink.util.Preconditions.checkArgument;
 import static org.apache.flink.util.Preconditions.checkNotNull;
@@ -283,7 +282,7 @@ public class Instance implements SlotOwner {
 	 * @return Future which is completed with true, if the slot was returned, false if not.
 	 */
 	@Override
-	public CompletableFuture<Boolean> returnAllocatedSlot(LogicalSlot logicalSlot) {
+	public void returnLogicalSlot(LogicalSlot logicalSlot) {
 		checkNotNull(logicalSlot);
 		checkArgument(logicalSlot instanceof Slot);
 
@@ -295,7 +294,7 @@ public class Instance implements SlotOwner {
 			LOG.debug("Return allocated slot {}.", slot);
 			synchronized (instanceLock) {
 				if (isDead) {
-					return CompletableFuture.completedFuture(false);
+					return;
 				}
 
 				if (this.allocatedSlots.remove(slot)) {
@@ -305,16 +304,12 @@ public class Instance implements SlotOwner {
 						this.slotAvailabilityListener.newSlotAvailable(this);
 					}
 
-					return CompletableFuture.completedFuture(true);
 				}
 				else {
 					throw new IllegalArgumentException("Slot was not allocated from this TaskManager.");
 				}
 			}
 		}
-		else {
-			return CompletableFuture.completedFuture(false);
-		}
 	}
 
 	public void cancelAndReleaseAllSlots() {
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/instance/SimpleSlot.java b/flink-runtime/src/main/java/org/apache/flink/runtime/instance/SimpleSlot.java
index ae51272..3363b15 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/instance/SimpleSlot.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/instance/SimpleSlot.java
@@ -224,7 +224,7 @@ public class SimpleSlot extends Slot implements LogicalSlot {
 
 			if (payload != null) {
 				// trigger the failure of the slot payload
-				payload.failSync(cause != null ? cause : new FlinkException("TaskManager was lost/killed: " + getTaskManagerLocation()));
+				payload.fail(cause != null ? cause : new FlinkException("TaskManager was lost/killed: " + getTaskManagerLocation()));
 
 				// wait for the termination of the payload before releasing the slot
 				terminationFuture = payload.getTerminalStateFuture();
@@ -239,14 +239,12 @@ public class SimpleSlot extends Slot implements LogicalSlot {
 					if (getParent() == null) {
 						// we have to give back the slot to the owning instance
 						if (markCancelled()) {
-							getOwner().returnAllocatedSlot(this).whenComplete(
-								(value, t) -> {
-									if (t != null) {
-										releaseFuture.completeExceptionally(t);
-									} else {
-										releaseFuture.complete(null);
-									}
-								});
+							try {
+								getOwner().returnLogicalSlot(this);
+								releaseFuture.complete(null);
+							} catch (Exception e) {
+								releaseFuture.completeExceptionally(e);
+							}
 						}
 					} else {
 						// we have to ask our parent to dispose us
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/instance/SimpleSlotContext.java b/flink-runtime/src/main/java/org/apache/flink/runtime/instance/SimpleSlotContext.java
index 282fd2c..60719e7 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/instance/SimpleSlotContext.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/instance/SimpleSlotContext.java
@@ -19,6 +19,7 @@
 package org.apache.flink.runtime.instance;
 
 import org.apache.flink.runtime.clusterframework.types.AllocationID;
+import org.apache.flink.runtime.clusterframework.types.ResourceProfile;
 import org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway;
 import org.apache.flink.runtime.jobmaster.SlotContext;
 import org.apache.flink.runtime.taskmanager.TaskManagerLocation;
@@ -37,15 +38,27 @@ public class SimpleSlotContext implements SlotContext {
 
 	private final TaskManagerGateway taskManagerGateway;
 
+	private final ResourceProfile resourceProfile;
+
 	public SimpleSlotContext(
 			AllocationID allocationId,
 			TaskManagerLocation taskManagerLocation,
 			int physicalSlotNumber,
 			TaskManagerGateway taskManagerGateway) {
+		this(allocationId, taskManagerLocation, physicalSlotNumber, taskManagerGateway, ResourceProfile.UNKNOWN);
+	}
+
+	public SimpleSlotContext(
+			AllocationID allocationId,
+			TaskManagerLocation taskManagerLocation,
+			int physicalSlotNumber,
+			TaskManagerGateway taskManagerGateway,
+			ResourceProfile resourceProfile) {
 		this.allocationId = Preconditions.checkNotNull(allocationId);
 		this.taskManagerLocation = Preconditions.checkNotNull(taskManagerLocation);
 		this.physicalSlotNumber = physicalSlotNumber;
 		this.taskManagerGateway = Preconditions.checkNotNull(taskManagerGateway);
+		this.resourceProfile = resourceProfile;
 	}
 
 	@Override
@@ -67,4 +80,9 @@ public class SimpleSlotContext implements SlotContext {
 	public TaskManagerGateway getTaskManagerGateway() {
 		return taskManagerGateway;
 	}
+
+	@Override
+	public ResourceProfile getResourceProfile() {
+		return resourceProfile;
+	}
 }
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/instance/SlotSharingGroupAssignment.java b/flink-runtime/src/main/java/org/apache/flink/runtime/instance/SlotSharingGroupAssignment.java
index 562c3c7..8b35cb4 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/instance/SlotSharingGroupAssignment.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/instance/SlotSharingGroupAssignment.java
@@ -553,7 +553,7 @@ public class SlotSharingGroupAssignment {
 		
 		if (parent == null) {
 			// root slot, return to the instance.
-			sharedSlot.getOwner().returnAllocatedSlot(sharedSlot);
+			sharedSlot.getOwner().returnLogicalSlot(sharedSlot);
 
 			// also, make sure we remove this slot from everywhere
 			allSlots.remove(sharedSlot);
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmanager/scheduler/Scheduler.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmanager/scheduler/Scheduler.java
index e0f057a..1c41c00 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmanager/scheduler/Scheduler.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmanager/scheduler/Scheduler.java
@@ -35,7 +35,6 @@ import org.apache.flink.runtime.jobgraph.JobVertexID;
 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.runtime.messages.Acknowledge;
 import org.apache.flink.runtime.taskmanager.TaskManagerLocation;
 import org.apache.flink.util.ExceptionUtils;
 import org.apache.flink.util.FlinkException;
@@ -147,8 +146,8 @@ public class Scheduler implements InstanceListener, SlotAvailabilityListener, Sl
 	public CompletableFuture<LogicalSlot> allocateSlot(
 			SlotRequestId slotRequestId,
 			ScheduledUnit task,
-			boolean allowQueued,
 			SlotProfile slotProfile,
+			boolean allowQueued,
 			Time allocationTimeout) {
 
 		try {
@@ -172,8 +171,7 @@ public class Scheduler implements InstanceListener, SlotAvailabilityListener, Sl
 	}
 
 	@Override
-	public CompletableFuture<Acknowledge> cancelSlotRequest(SlotRequestId slotRequestId, @Nullable SlotSharingGroupId slotSharingGroupId, Throwable cause) {
-		return CompletableFuture.completedFuture(Acknowledge.get());
+	public void cancelSlotRequest(SlotRequestId slotRequestId, @Nullable SlotSharingGroupId slotSharingGroupId, Throwable cause) {
 	}
 
 	/**
@@ -590,7 +588,7 @@ public class Scheduler implements InstanceListener, SlotAvailabilityListener, Sl
 							}
 							catch (Throwable t) {
 								LOG.error("Error calling allocation future for task " + vertex.getTaskNameWithSubtaskIndex(), t);
-								task.getTaskToExecute().failSync(t);
+								task.getTaskToExecute().fail(t);
 							}
 						}
 					}
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java
index 6eaec3d..f21f6e4 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/JobMaster.java
@@ -70,9 +70,10 @@ import org.apache.flink.runtime.jobmanager.OnCompletionActions;
 import org.apache.flink.runtime.jobmanager.PartitionProducerDisposedException;
 import org.apache.flink.runtime.jobmaster.exceptions.JobModificationException;
 import org.apache.flink.runtime.jobmaster.factories.JobManagerJobMetricGroupFactory;
+import org.apache.flink.runtime.jobmaster.slotpool.Scheduler;
+import org.apache.flink.runtime.jobmaster.slotpool.SchedulerFactory;
 import org.apache.flink.runtime.jobmaster.slotpool.SlotPool;
 import org.apache.flink.runtime.jobmaster.slotpool.SlotPoolFactory;
-import org.apache.flink.runtime.jobmaster.slotpool.SlotPoolGateway;
 import org.apache.flink.runtime.leaderretrieval.LeaderRetrievalListener;
 import org.apache.flink.runtime.leaderretrieval.LeaderRetrievalService;
 import org.apache.flink.runtime.messages.Acknowledge;
@@ -104,7 +105,6 @@ import org.apache.flink.runtime.taskexecutor.slot.SlotOffer;
 import org.apache.flink.runtime.taskmanager.TaskExecutionState;
 import org.apache.flink.runtime.taskmanager.TaskManagerLocation;
 import org.apache.flink.runtime.webmonitor.WebMonitorUtils;
-import org.apache.flink.types.SerializableOptional;
 import org.apache.flink.util.ExceptionUtils;
 import org.apache.flink.util.FlinkException;
 import org.apache.flink.util.InstantiationUtil;
@@ -117,8 +117,8 @@ import javax.annotation.Nullable;
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -131,7 +131,6 @@ import java.util.concurrent.CompletionException;
 import java.util.concurrent.Executor;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeoutException;
-import java.util.function.Function;
 
 import static org.apache.flink.util.Preconditions.checkNotNull;
 import static org.apache.flink.util.Preconditions.checkState;
@@ -183,7 +182,7 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
 
 	private final SlotPool slotPool;
 
-	private final SlotPoolGateway slotPoolGateway;
+	private final Scheduler scheduler;
 
 	private final RestartStrategy restartStrategy;
 
@@ -230,6 +229,7 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
 			JobGraph jobGraph,
 			HighAvailabilityServices highAvailabilityService,
 			SlotPoolFactory slotPoolFactory,
+			SchedulerFactory schedulerFactory,
 			JobManagerSharedServices jobManagerSharedServices,
 			HeartbeatServices heartbeatServices,
 			JobManagerJobMetricGroupFactory jobMetricGroupFactory,
@@ -285,7 +285,7 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
 
 		this.slotPool = checkNotNull(slotPoolFactory).createSlotPool(jobGraph.getJobID());
 
-		this.slotPoolGateway = slotPool.getSelfGateway(SlotPoolGateway.class);
+		this.scheduler = checkNotNull(schedulerFactory).createScheduler(slotPool);
 
 		this.registeredTaskManagers = new HashMap<>(4);
 
@@ -337,8 +337,7 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
 	public CompletableFuture<Acknowledge> suspend(final Exception cause) {
 		CompletableFuture<Acknowledge> suspendFuture = callAsyncWithoutFencing(
 				() -> suspendExecution(cause),
-				RpcUtils.INF_TIMEOUT)
-			.thenCompose(Function.identity());
+				RpcUtils.INF_TIMEOUT);
 
 		return suspendFuture.whenComplete((acknowledge, throwable) -> stop());
 	}
@@ -366,7 +365,7 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
 		suspendExecution(new FlinkException("JobManager is shutting down."));
 
 		// shut down will internally release all registered slots
-		final CompletableFuture<Void> slotPoolTerminationFuture = slotPool.closeAsync();
+		slotPool.close();
 
 		final CompletableFuture<Void> disposeInternalSavepointFuture;
 
@@ -376,7 +375,7 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
 			disposeInternalSavepointFuture = CompletableFuture.completedFuture(null);
 		}
 
-		return FutureUtils.completeAll(Arrays.asList(disposeInternalSavepointFuture, slotPoolTerminationFuture));
+		return FutureUtils.completeAll(Collections.singletonList(disposeInternalSavepointFuture));
 	}
 
 	//----------------------------------------------------------------------------------------------
@@ -643,7 +642,7 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
 		log.debug("Disconnect TaskExecutor {} because: {}", resourceID, cause.getMessage());
 
 		taskManagerHeartbeatManager.unmonitorTarget(resourceID);
-		CompletableFuture<Acknowledge> releaseFuture = slotPoolGateway.releaseTaskManager(resourceID, cause);
+		slotPool.releaseTaskManager(resourceID, cause);
 
 		Tuple2<TaskManagerLocation, TaskExecutorGateway> taskManagerConnection = registeredTaskManagers.remove(resourceID);
 
@@ -651,7 +650,7 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
 			taskManagerConnection.f1.disconnectJobManager(jobGraph.getJobID(), cause);
 		}
 
-		return releaseFuture;
+		return CompletableFuture.completedFuture(Acknowledge.get());
 	}
 
 	// TODO: This method needs a leader session ID
@@ -813,10 +812,11 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
 
 		final RpcTaskManagerGateway rpcTaskManagerGateway = new RpcTaskManagerGateway(taskExecutorGateway, getFencingToken());
 
-		return slotPoolGateway.offerSlots(
-			taskManagerLocation,
-			rpcTaskManagerGateway,
-			slots);
+		return CompletableFuture.completedFuture(
+			slotPool.offerSlots(
+				taskManagerLocation,
+				rpcTaskManagerGateway,
+				slots));
 	}
 
 	@Override
@@ -834,15 +834,12 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
 	}
 
 	private void internalFailAllocation(AllocationID allocationId, Exception cause) {
-		final CompletableFuture<SerializableOptional<ResourceID>> emptyTaskExecutorFuture = slotPoolGateway.failAllocation(allocationId, cause);
-
-		emptyTaskExecutorFuture.thenAcceptAsync(
-			resourceIdOptional -> resourceIdOptional.ifPresent(this::releaseEmptyTaskManager),
-			getMainThreadExecutor());
+		final Optional<ResourceID> resourceIdOptional = slotPool.failAllocation(allocationId, cause);
+		resourceIdOptional.ifPresent(this::releaseEmptyTaskManager);
 	}
 
-	private CompletableFuture<Acknowledge> releaseEmptyTaskManager(ResourceID resourceId) {
-		return disconnectTaskManager(resourceId, new FlinkException(String.format("No more slots registered at JobMaster %s.", resourceId)));
+	private void releaseEmptyTaskManager(ResourceID resourceId) {
+		disconnectTaskManager(resourceId, new FlinkException(String.format("No more slots registered at JobMaster %s.", resourceId)));
 	}
 
 	@Override
@@ -865,7 +862,7 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
 							return new RegistrationResponse.Decline(throwable.getMessage());
 						}
 
-						slotPoolGateway.registerTaskManager(taskManagerId);
+						slotPool.registerTaskManager(taskManagerId);
 						registeredTaskManagers.put(taskManagerId, Tuple2.of(taskManagerLocation, taskExecutorGateway));
 
 						// monitor the task manager as heartbeat target
@@ -1027,7 +1024,8 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
 
 	private void startJobMasterServices() throws Exception {
 		// start the slot pool make sure the slot pool now accepts messages for this leader
-		slotPool.start(getFencingToken(), getAddress());
+		slotPool.start(getFencingToken(), getAddress(), getMainThreadExecutor());
+		scheduler.start(getMainThreadExecutor());
 
 		//TODO: Remove once the ZooKeeperLeaderRetrieval returns the stored address upon start
 		// try to reconnect to previously known leader
@@ -1062,12 +1060,12 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
 	 *
 	 * @param cause The reason of why this job been suspended.
 	 */
-	private CompletableFuture<Acknowledge> suspendExecution(final Exception cause) {
+	private Acknowledge suspendExecution(final Exception cause) {
 		validateRunsInMainThread();
 
 		if (getFencingToken() == null) {
 			log.debug("Job has already been suspended or shutdown.");
-			return CompletableFuture.completedFuture(null);
+			return Acknowledge.get();
 		}
 
 		// not leader anymore --> set the JobMasterId to null
@@ -1082,12 +1080,12 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
 		suspendAndClearExecutionGraphFields(cause);
 
 		// the slot pool stops receiving messages and clears its pooled slots
-		CompletableFuture<Acknowledge> slotPoolSuspendFuture = slotPoolGateway.suspend();
+		slotPool.suspend();
 
 		// disconnect from resource manager:
 		closeResourceManagerConnection(cause);
 
-		return slotPoolSuspendFuture;
+		return Acknowledge.get();
 	}
 
 	private void assignExecutionGraph(
@@ -1167,7 +1165,7 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
 			jobMasterConfiguration.getConfiguration(),
 			scheduledExecutorService,
 			scheduledExecutorService,
-			slotPool.getSlotProvider(),
+			scheduler,
 			userCodeLoader,
 			highAvailabilityServices.getCheckpointRecoveryFactory(),
 			rpcTimeout,
@@ -1327,7 +1325,7 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
 				resourceManagerGateway,
 				resourceManagerResourceId);
 
-			slotPoolGateway.connectToResourceManager(resourceManagerGateway);
+			slotPool.connectToResourceManager(resourceManagerGateway);
 
 			resourceManagerHeartbeatManager.monitorTarget(resourceManagerResourceId, new HeartbeatTarget<Void>() {
 				@Override
@@ -1372,7 +1370,7 @@ public class JobMaster extends FencedRpcEndpoint<JobMasterId> implements JobMast
 
 		ResourceManagerGateway resourceManagerGateway = establishedResourceManagerConnection.getResourceManagerGateway();
 		resourceManagerGateway.disconnectJobManager(jobGraph.getJobID(), cause);
-		slotPoolGateway.disconnectResourceManager();
+		slotPool.disconnectResourceManager();
 	}
 
 	/**
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/LogicalSlot.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/LogicalSlot.java
index f5f7d9c..c3bccf6 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/LogicalSlot.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/LogicalSlot.java
@@ -37,13 +37,9 @@ public interface LogicalSlot {
 	Payload TERMINATED_PAYLOAD = new Payload() {
 
 		private final CompletableFuture<?> completedTerminationFuture = CompletableFuture.completedFuture(null);
-		@Override
-		public void failAsync(Throwable cause) {
-			// ignore
-		}
 
 		@Override
-		public void failSync(Throwable cause) {
+		public void fail(Throwable cause) {
 			// ignore
 		}
 
@@ -154,18 +150,10 @@ public interface LogicalSlot {
 
 		/**
 		 * Fail the payload with the given cause.
-		 * TODO this method can be removed again once the slot pool runs in the JM main thread as well.
-		 *
-		 * @param cause of the failure
-		 */
-		void failAsync(Throwable cause);
-
-		/**
-		 * Fail the payload with the given cause.
 		 *
 		 * @param cause of the failure
 		 */
-		void failSync(Throwable cause);
+		void fail(Throwable cause);
 
 		/**
 		 * Gets the terminal state future which is completed once the payload
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/SlotInfo.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/SlotInfo.java
index fd33aac..09b49f5 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/SlotInfo.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/SlotInfo.java
@@ -19,6 +19,7 @@
 package org.apache.flink.runtime.jobmaster;
 
 import org.apache.flink.runtime.clusterframework.types.AllocationID;
+import org.apache.flink.runtime.clusterframework.types.ResourceProfile;
 import org.apache.flink.runtime.taskmanager.TaskManagerLocation;
 
 /**
@@ -47,4 +48,11 @@ public interface SlotInfo {
 	 * @return The number of the slot on the TaskManager.
 	 */
 	int getPhysicalSlotNumber();
+
+	/**
+	 * Returns the resource profile of the slot.
+	 *
+	 * @return the resource profile of the slot.
+	 */
+	ResourceProfile getResourceProfile();
 }
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/SlotOwner.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/SlotOwner.java
index 9cc6f81..2cd099c 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/SlotOwner.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/SlotOwner.java
@@ -18,8 +18,6 @@
 
 package org.apache.flink.runtime.jobmaster;
 
-import java.util.concurrent.CompletableFuture;
-
 /**
  * Interface for components that hold slots and to which slots get released / recycled.
  */
@@ -29,7 +27,6 @@ public interface SlotOwner {
 	 * Return the given slot to the slot owner.
 	 *
 	 * @param logicalSlot to return
-	 * @return Future which is completed with true if the slot could be returned, otherwise with false
 	 */
-	CompletableFuture<Boolean> returnAllocatedSlot(LogicalSlot logicalSlot);
+	void returnLogicalSlot(LogicalSlot logicalSlot);
 }
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/factories/DefaultJobMasterServiceFactory.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/factories/DefaultJobMasterServiceFactory.java
index 58aa948..2ad91d1 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/factories/DefaultJobMasterServiceFactory.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/factories/DefaultJobMasterServiceFactory.java
@@ -26,6 +26,7 @@ import org.apache.flink.runtime.jobmanager.OnCompletionActions;
 import org.apache.flink.runtime.jobmaster.JobManagerSharedServices;
 import org.apache.flink.runtime.jobmaster.JobMaster;
 import org.apache.flink.runtime.jobmaster.JobMasterConfiguration;
+import org.apache.flink.runtime.jobmaster.slotpool.SchedulerFactory;
 import org.apache.flink.runtime.jobmaster.slotpool.SlotPoolFactory;
 import org.apache.flink.runtime.rpc.FatalErrorHandler;
 import org.apache.flink.runtime.rpc.RpcService;
@@ -39,6 +40,8 @@ public class DefaultJobMasterServiceFactory implements JobMasterServiceFactory {
 
 	private final SlotPoolFactory slotPoolFactory;
 
+	private final SchedulerFactory schedulerFactory;
+
 	private final RpcService rpcService;
 
 	private final HighAvailabilityServices haServices;
@@ -54,6 +57,7 @@ public class DefaultJobMasterServiceFactory implements JobMasterServiceFactory {
 	public DefaultJobMasterServiceFactory(
 			JobMasterConfiguration jobMasterConfiguration,
 			SlotPoolFactory slotPoolFactory,
+			SchedulerFactory schedulerFactory,
 			RpcService rpcService,
 			HighAvailabilityServices haServices,
 			JobManagerSharedServices jobManagerSharedServices,
@@ -62,6 +66,7 @@ public class DefaultJobMasterServiceFactory implements JobMasterServiceFactory {
 			FatalErrorHandler fatalErrorHandler) {
 		this.jobMasterConfiguration = jobMasterConfiguration;
 		this.slotPoolFactory = slotPoolFactory;
+		this.schedulerFactory = schedulerFactory;
 		this.rpcService = rpcService;
 		this.haServices = haServices;
 		this.jobManagerSharedServices = jobManagerSharedServices;
@@ -79,6 +84,7 @@ public class DefaultJobMasterServiceFactory implements JobMasterServiceFactory {
 			jobGraph,
 			haServices,
 			slotPoolFactory,
+			schedulerFactory,
 			jobManagerSharedServices,
 			heartbeatServices,
 			jobManagerJobMetricGroupFactory,
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/AllocatedSlot.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/AllocatedSlot.java
index 860d1d4..7463762 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/AllocatedSlot.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/AllocatedSlot.java
@@ -23,7 +23,6 @@ import org.apache.flink.runtime.clusterframework.types.ResourceID;
 import org.apache.flink.runtime.clusterframework.types.ResourceProfile;
 import org.apache.flink.runtime.clusterframework.types.SlotID;
 import org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway;
-import org.apache.flink.runtime.jobmaster.SlotContext;
 import org.apache.flink.runtime.taskmanager.TaskManagerLocation;
 
 import java.util.concurrent.atomic.AtomicReference;
@@ -42,7 +41,7 @@ import static org.apache.flink.util.Preconditions.checkNotNull;
  * an AllocatedSlot was allocated to the JobManager as soon as the TaskManager registered at the
  * JobManager. All slots had a default unknown resource profile. 
  */
-class AllocatedSlot implements SlotContext {
+class AllocatedSlot implements PhysicalSlot {
 
 	/** The ID under which the slot is allocated. Uniquely identifies the slot. */
 	private final AllocationID allocationId;
@@ -87,11 +86,6 @@ class AllocatedSlot implements SlotContext {
 		return new SlotID(getTaskManagerId(), physicalSlotNumber);
 	}
 
-	/**
-	 * Gets the ID under which the slot is allocated, which uniquely identifies the slot.
-	 * 
-	 * @return The ID under which the slot is allocated
-	 */
 	@Override
 	public AllocationID getAllocationId() {
 		return allocationId;
@@ -108,43 +102,21 @@ class AllocatedSlot implements SlotContext {
 		return getTaskManagerLocation().getResourceID();
 	}
 
-	/**
-	 * Gets the resource profile of the slot.
-	 *
-	 * @return The resource profile of the slot.
-	 */
+	@Override
 	public ResourceProfile getResourceProfile() {
 		return resourceProfile;
 	}
 
-	/**
-	 * Gets the location info of the TaskManager that offers this slot.
-	 *
-	 * @return The location info of the TaskManager that offers this slot
-	 */
 	@Override
 	public TaskManagerLocation getTaskManagerLocation() {
 		return taskManagerLocation;
 	}
 
-	/**
-	 * Gets the actor gateway that can be used to send messages to the TaskManager.
-	 * <p>
-	 * This method should be removed once the new interface-based RPC abstraction is in place
-	 *
-	 * @return The actor gateway that can be used to send messages to the TaskManager.
-	 */
 	@Override
 	public TaskManagerGateway getTaskManagerGateway() {
 		return taskManagerGateway;
 	}
 
-	/**
-	 * Returns the physical slot number of the allocated slot. The physical slot number corresponds
-	 * to the slot index on the TaskExecutor.
-	 *
-	 * @return Physical slot number of the allocated slot
-	 */
 	@Override
 	public int getPhysicalSlotNumber() {
 		return physicalSlotNumber;
@@ -159,13 +131,7 @@ class AllocatedSlot implements SlotContext {
 		return payloadReference.get() != null;
 	}
 
-	/**
-	 * Tries to assign the given payload to this allocated slot. This only works if there has not
-	 * been another payload assigned to this slot.
-	 *
-	 * @param payload to assign to this slot
-	 * @return true if the payload could be assigned, otherwise false
-	 */
+	@Override
 	public boolean tryAssignPayload(Payload payload) {
 		return payloadReference.compareAndSet(null, payload);
 	}
@@ -207,21 +173,4 @@ class AllocatedSlot implements SlotContext {
 	public String toString() {
 		return "AllocatedSlot " + allocationId + " @ " + taskManagerLocation + " - " + physicalSlotNumber;
 	}
-
-	// -----------------------------------------------------------------------
-	// Interfaces
-	// -----------------------------------------------------------------------
-
-	/**
-	 * Payload which can be assigned to an {@link AllocatedSlot}.
-	 */
-	interface Payload {
-
-		/**
-		 * Releases the payload
-		 *
-		 * @param cause of the payload release
-		 */
-		void release(Throwable cause);
-	}
 }
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/AllocatedSlotActions.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/AllocatedSlotActions.java
index 045678e..2ae373c 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/AllocatedSlotActions.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/AllocatedSlotActions.java
@@ -19,30 +19,22 @@
 package org.apache.flink.runtime.jobmaster.slotpool;
 
 import org.apache.flink.runtime.jobmaster.SlotRequestId;
-import org.apache.flink.runtime.instance.SlotSharingGroupId;
-import org.apache.flink.runtime.messages.Acknowledge;
 
+import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
-import java.util.concurrent.CompletableFuture;
-
 /**
  * Interface for components which have to perform actions on allocated slots.
  */
 public interface AllocatedSlotActions {
 
 	/**
-	 * Releases the slot with the given {@link SlotRequestId}. If the slot belonged to a
-	 * slot sharing group, then the corresponding {@link SlotSharingGroupId} has to be
-	 * provided. Additionally, one can provide a cause for the slot release.
+	 * Releases the slot with the given {@link SlotRequestId}. Additionally, one can provide a cause for the slot release.
 	 *
 	 * @param slotRequestId identifying the slot to release
-	 * @param slotSharingGroupId identifying the slot sharing group to which the slot belongs, null if none
 	 * @param cause of the slot release, null if none
-	 * @return Acknowledge (future) after the slot has been released
 	 */
-	CompletableFuture<Acknowledge> releaseSlot(
-		SlotRequestId slotRequestId,
-		@Nullable SlotSharingGroupId slotSharingGroupId,
+	void releaseSlot(
+		@Nonnull SlotRequestId slotRequestId,
 		@Nullable Throwable cause);
 }
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/DefaultSchedulerFactory.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/DefaultSchedulerFactory.java
new file mode 100644
index 0000000..72345df
--- /dev/null
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/DefaultSchedulerFactory.java
@@ -0,0 +1,57 @@
+/*
+ * 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.jobmaster.slotpool;
+
+import org.apache.flink.configuration.CheckpointingOptions;
+import org.apache.flink.configuration.Configuration;
+
+import javax.annotation.Nonnull;
+
+/**
+ * Default implementation of a {@link SchedulerFactory}.
+ */
+public class DefaultSchedulerFactory implements SchedulerFactory {
+
+	@Nonnull
+	private final SlotSelectionStrategy slotSelectionStrategy;
+
+	public DefaultSchedulerFactory(@Nonnull SlotSelectionStrategy slotSelectionStrategy) {
+		this.slotSelectionStrategy = slotSelectionStrategy;
+	}
+
+	@Nonnull
+	@Override
+	public Scheduler createScheduler(@Nonnull SlotPool slotPool) {
+		return new SchedulerImpl(slotSelectionStrategy, slotPool);
+	}
+
+	@Nonnull
+	private static SlotSelectionStrategy selectSlotSelectionStrategy(@Nonnull Configuration configuration) {
+		if (configuration.getBoolean(CheckpointingOptions.LOCAL_RECOVERY)) {
+			return PreviousAllocationSlotSelectionStrategy.INSTANCE;
+		} else {
+			return LocationPreferenceSlotSelectionStrategy.INSTANCE;
+		}
+	}
+
+	public static DefaultSchedulerFactory fromConfiguration(
+		@Nonnull Configuration configuration) {
+		return new DefaultSchedulerFactory(selectSlotSelectionStrategy(configuration));
+	}
+}
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/DefaultSlotPoolFactory.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/DefaultSlotPoolFactory.java
index ed14aab..709155e 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/DefaultSlotPoolFactory.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/DefaultSlotPoolFactory.java
@@ -20,11 +20,9 @@ package org.apache.flink.runtime.jobmaster.slotpool;
 
 import org.apache.flink.api.common.JobID;
 import org.apache.flink.api.common.time.Time;
-import org.apache.flink.configuration.CheckpointingOptions;
 import org.apache.flink.configuration.Configuration;
 import org.apache.flink.configuration.JobManagerOptions;
 import org.apache.flink.runtime.akka.AkkaUtils;
-import org.apache.flink.runtime.rpc.RpcService;
 import org.apache.flink.runtime.util.clock.Clock;
 import org.apache.flink.runtime.util.clock.SystemClock;
 
@@ -36,12 +34,6 @@ import javax.annotation.Nonnull;
 public class DefaultSlotPoolFactory implements SlotPoolFactory {
 
 	@Nonnull
-	private final RpcService rpcService;
-
-	@Nonnull
-	private final SchedulingStrategy schedulingStrategy;
-
-	@Nonnull
 	private final Clock clock;
 
 	@Nonnull
@@ -51,13 +43,9 @@ public class DefaultSlotPoolFactory implements SlotPoolFactory {
 	private final Time slotIdleTimeout;
 
 	public DefaultSlotPoolFactory(
-			@Nonnull RpcService rpcService,
-			@Nonnull SchedulingStrategy schedulingStrategy,
 			@Nonnull Clock clock,
 			@Nonnull Time rpcTimeout,
 			@Nonnull Time slotIdleTimeout) {
-		this.rpcService = rpcService;
-		this.schedulingStrategy = schedulingStrategy;
 		this.clock = clock;
 		this.rpcTimeout = rpcTimeout;
 		this.slotIdleTimeout = slotIdleTimeout;
@@ -66,37 +54,21 @@ public class DefaultSlotPoolFactory implements SlotPoolFactory {
 	@Override
 	@Nonnull
 	public SlotPool createSlotPool(@Nonnull JobID jobId) {
-		return new SlotPool(
-			rpcService,
+		return new SlotPoolImpl(
 			jobId,
-			schedulingStrategy,
 			clock,
 			rpcTimeout,
 			slotIdleTimeout);
 	}
 
-	public static DefaultSlotPoolFactory fromConfiguration(
-			@Nonnull Configuration configuration,
-			@Nonnull RpcService rpcService) {
+	public static DefaultSlotPoolFactory fromConfiguration(@Nonnull Configuration configuration) {
 
 		final Time rpcTimeout = AkkaUtils.getTimeoutAsTime(configuration);
 		final Time slotIdleTimeout = Time.milliseconds(configuration.getLong(JobManagerOptions.SLOT_IDLE_TIMEOUT));
 
-		final SchedulingStrategy schedulingStrategy = selectSchedulingStrategy(configuration);
-
 		return new DefaultSlotPoolFactory(
-			rpcService,
-			schedulingStrategy,
 			SystemClock.getInstance(),
 			rpcTimeout,
 			slotIdleTimeout);
 	}
-
-	private static SchedulingStrategy selectSchedulingStrategy(Configuration configuration) {
-		if (configuration.getBoolean(CheckpointingOptions.LOCAL_RECOVERY)) {
-			return PreviousAllocationSchedulingStrategy.getInstance();
-		} else {
-			return LocationPreferenceSchedulingStrategy.getInstance();
-		}
-	}
 }
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/LocationPreferenceSchedulingStrategy.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/LocationPreferenceSlotSelectionStrategy.java
similarity index 51%
rename from flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/LocationPreferenceSchedulingStrategy.java
rename to flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/LocationPreferenceSlotSelectionStrategy.java
index bc90be6..4325d91 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/LocationPreferenceSchedulingStrategy.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/LocationPreferenceSlotSelectionStrategy.java
@@ -7,7 +7,7 @@
  * "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
+ * 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,
@@ -19,72 +19,70 @@
 package org.apache.flink.runtime.jobmaster.slotpool;
 
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
+import org.apache.flink.runtime.clusterframework.types.ResourceProfile;
 import org.apache.flink.runtime.clusterframework.types.SlotProfile;
 import org.apache.flink.runtime.jobmanager.scheduler.Locality;
 import org.apache.flink.runtime.jobmaster.SlotInfo;
 import org.apache.flink.runtime.taskmanager.TaskManagerLocation;
 
 import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
 
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
+import java.util.Optional;
 import java.util.function.BiFunction;
-import java.util.function.Function;
-import java.util.function.Predicate;
-import java.util.function.Supplier;
-import java.util.stream.Stream;
 
 /**
- * Default {@link SchedulingStrategy} which tries to match a slot with its location preferences.
+ * This class implements a {@link SlotSelectionStrategy} that is based on location preference hints.
  */
-public class LocationPreferenceSchedulingStrategy implements SchedulingStrategy {
+public enum LocationPreferenceSlotSelectionStrategy implements SlotSelectionStrategy {
 
-	private static final LocationPreferenceSchedulingStrategy INSTANCE = new LocationPreferenceSchedulingStrategy();
+	INSTANCE;
 
 	/**
 	 * Calculates the candidate's locality score.
 	 */
-	private static final BiFunction<Integer, Integer, Integer> LOCALITY_EVALUATION_FUNCTION = (localWeigh, hostLocalWeigh) -> localWeigh * 10 + hostLocalWeigh;
+	private static final BiFunction<Integer, Integer, Integer> LOCALITY_EVALUATION_FUNCTION =
+		(localWeigh, hostLocalWeigh) -> localWeigh * 10 + hostLocalWeigh;
 
-	LocationPreferenceSchedulingStrategy() {}
-
-	@Nullable
 	@Override
-	public <IN, OUT> OUT findMatchWithLocality(
-			@Nonnull SlotProfile slotProfile,
-			@Nonnull Supplier<Stream<IN>> candidates,
-			@Nonnull Function<IN, SlotInfo> contextExtractor,
-			@Nonnull Predicate<IN> additionalRequirementsFilter,
-			@Nonnull BiFunction<IN, Locality, OUT> resultProducer) {
-
-		return doFindMatchWithLocality(
-			slotProfile,
-			candidates.get(),
-			contextExtractor,
-			additionalRequirementsFilter,
-			resultProducer);
-	}
+	public Optional<SlotInfoAndLocality> selectBestSlotForProfile(
+		@Nonnull Collection<? extends SlotInfo> availableSlots,
+		@Nonnull SlotProfile slotProfile) {
 
-	@Nullable
-	protected  <IN, OUT> OUT doFindMatchWithLocality(
-		@Nonnull SlotProfile slotProfile,
-		@Nonnull Stream<IN> candidates,
-		@Nonnull Function<IN, SlotInfo> contextExtractor,
-		@Nonnull Predicate<IN> additionalRequirementsFilter,
-		@Nonnull BiFunction<IN, Locality, OUT> resultProducer) {
 		Collection<TaskManagerLocation> locationPreferences = slotProfile.getPreferredLocations();
 
+		if (availableSlots.isEmpty()) {
+			return Optional.empty();
+		}
+
+		final ResourceProfile resourceProfile = slotProfile.getResourceProfile();
+
 		// if we have no location preferences, we can only filter by the additional requirements.
-		if (locationPreferences.isEmpty()) {
-			return candidates
-				.filter(additionalRequirementsFilter)
-				.findFirst()
-				.map((result) -> resultProducer.apply(result, Locality.UNCONSTRAINED))
-				.orElse(null);
+		return locationPreferences.isEmpty() ?
+			selectWithoutLocationPreference(availableSlots, resourceProfile) :
+			selectWitLocationPreference(availableSlots, locationPreferences, resourceProfile);
+	}
+
+	@Nonnull
+	private Optional<SlotInfoAndLocality> selectWithoutLocationPreference(
+		@Nonnull Collection<? extends SlotInfo> availableSlots,
+		@Nonnull ResourceProfile resourceProfile) {
+
+		for (SlotInfo candidate : availableSlots) {
+			if (candidate.getResourceProfile().isMatching(resourceProfile)) {
+				return Optional.of(SlotInfoAndLocality.of(candidate, Locality.UNCONSTRAINED));
+			}
 		}
+		return Optional.empty();
+	}
+
+	@Nonnull
+	private Optional<SlotInfoAndLocality> selectWitLocationPreference(
+		@Nonnull Collection<? extends SlotInfo> availableSlots,
+		@Nonnull Collection<TaskManagerLocation> locationPreferences,
+		@Nonnull ResourceProfile resourceProfile) {
 
 		// we build up two indexes, one for resource id and one for host names of the preferred locations.
 		final Map<ResourceID, Integer> preferredResourceIDs = new HashMap<>(locationPreferences.size());
@@ -95,41 +93,36 @@ public class LocationPreferenceSchedulingStrategy implements SchedulingStrategy
 			preferredFQHostNames.merge(locationPreference.getFQDNHostname(), 1, Integer::sum);
 		}
 
-		Iterator<IN> iterator = candidates.iterator();
-
-		IN bestCandidate = null;
+		SlotInfo bestCandidate = null;
+		Locality bestCandidateLocality = Locality.UNKNOWN;
 		int bestCandidateScore = Integer.MIN_VALUE;
-		Locality bestCandidateLocality = null;
 
-		while (iterator.hasNext()) {
-			IN candidate = iterator.next();
-			if (additionalRequirementsFilter.test(candidate)) {
-				SlotInfo slotContext = contextExtractor.apply(candidate);
+		for (SlotInfo candidate : availableSlots) {
+
+			if (candidate.getResourceProfile().isMatching(resourceProfile)) {
 
 				// this gets candidate is local-weigh
-				Integer localWeigh = preferredResourceIDs.getOrDefault(slotContext.getTaskManagerLocation().getResourceID(), 0);
+				Integer localWeigh = preferredResourceIDs.getOrDefault(
+					candidate.getTaskManagerLocation().getResourceID(), 0);
 
 				// this gets candidate is host-local-weigh
-				Integer hostLocalWeigh = preferredFQHostNames.getOrDefault(slotContext.getTaskManagerLocation().getFQDNHostname(), 0);
+				Integer hostLocalWeigh = preferredFQHostNames.getOrDefault(
+					candidate.getTaskManagerLocation().getFQDNHostname(), 0);
 
 				int candidateScore = LOCALITY_EVALUATION_FUNCTION.apply(localWeigh, hostLocalWeigh);
 				if (candidateScore > bestCandidateScore) {
 					bestCandidateScore = candidateScore;
 					bestCandidate = candidate;
-					bestCandidateLocality = localWeigh > 0 ? Locality.LOCAL : hostLocalWeigh > 0 ? Locality.HOST_LOCAL : Locality.NON_LOCAL;
+					bestCandidateLocality = localWeigh > 0 ?
+						Locality.LOCAL : hostLocalWeigh > 0 ?
+						Locality.HOST_LOCAL : Locality.NON_LOCAL;
 				}
 			}
 		}
 
 		// at the end of the iteration, we return the candidate with best possible locality or null.
-		if (bestCandidate != null) {
-			return resultProducer.apply(bestCandidate, bestCandidateLocality);
-		} else {
-			return null;
-		}
-	}
-
-	public static LocationPreferenceSchedulingStrategy getInstance() {
-		return INSTANCE;
+		return bestCandidate != null ?
+			Optional.of(SlotInfoAndLocality.of(bestCandidate, bestCandidateLocality)) :
+			Optional.empty();
 	}
 }
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/SlotInfo.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/PhysicalSlot.java
similarity index 50%
copy from flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/SlotInfo.java
copy to flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/PhysicalSlot.java
index fd33aac..54c2d8a 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/SlotInfo.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/PhysicalSlot.java
@@ -16,35 +16,35 @@
  * limitations under the License.
  */
 
-package org.apache.flink.runtime.jobmaster;
+package org.apache.flink.runtime.jobmaster.slotpool;
 
-import org.apache.flink.runtime.clusterframework.types.AllocationID;
-import org.apache.flink.runtime.taskmanager.TaskManagerLocation;
+import org.apache.flink.runtime.jobmaster.SlotContext;
 
 /**
- * Interface that provides basic information in the context of a slot.
+ * The context of an {@link AllocatedSlot}. This represent an interface to classes outside the slot pool to interact
+ * with allocated slots.
  */
-public interface SlotInfo {
+public interface PhysicalSlot extends SlotContext {
 
 	/**
-	 * Gets the id under which the slot has been allocated on the TaskManager. This id uniquely identifies the
-	 * physical slot.
+	 * Tries to assign the given payload to this allocated slot. This only works if there has not
+	 * been another payload assigned to this slot.
 	 *
-	 * @return The id under which the slot has been allocated on the TaskManager
+	 * @param payload to assign to this slot
+	 * @return true if the payload could be assigned, otherwise false
 	 */
-	AllocationID getAllocationId();
+	boolean tryAssignPayload(Payload payload);
 
 	/**
-	 * Gets the location info of the TaskManager that offers this slot.
-	 *
-	 * @return The location info of the TaskManager that offers this slot
+	 * Payload which can be assigned to an {@link AllocatedSlot}.
 	 */
-	TaskManagerLocation getTaskManagerLocation();
+	interface Payload {
 
-	/**
-	 * Gets the number of the slot.
-	 *
-	 * @return The number of the slot on the TaskManager.
-	 */
-	int getPhysicalSlotNumber();
+		/**
+		 * Releases the payload
+		 *
+		 * @param cause of the payload release
+		 */
+		void release(Throwable cause);
+	}
 }
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/PreviousAllocationSchedulingStrategy.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/PreviousAllocationSchedulingStrategy.java
deleted file mode 100644
index d2193ad..0000000
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/PreviousAllocationSchedulingStrategy.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * 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.jobmaster.slotpool;
-
-import org.apache.flink.runtime.clusterframework.types.AllocationID;
-import org.apache.flink.runtime.clusterframework.types.SlotProfile;
-import org.apache.flink.runtime.jobmanager.scheduler.Locality;
-import org.apache.flink.runtime.jobmaster.SlotInfo;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import java.util.Collection;
-import java.util.Set;
-import java.util.function.BiFunction;
-import java.util.function.Function;
-import java.util.function.Predicate;
-import java.util.function.Supplier;
-import java.util.stream.Stream;
-
-/**
- * {@link SchedulingStrategy} which tries to match a slot with its previous {@link AllocationID}.
- * If the previous allocation cannot be found, then it returns {@code null}. If the slot has not
- * been scheduled before (no assigned allocation id), it will fall back to
- * {@link LocationPreferenceSchedulingStrategy}.
- */
-public class PreviousAllocationSchedulingStrategy extends LocationPreferenceSchedulingStrategy {
-
-	private static final PreviousAllocationSchedulingStrategy INSTANCE = new PreviousAllocationSchedulingStrategy();
-
-	private PreviousAllocationSchedulingStrategy() {}
-
-	@Nullable
-	@Override
-	public <IN, OUT> OUT findMatchWithLocality(
-			@Nonnull SlotProfile slotProfile,
-			@Nonnull Supplier<Stream<IN>> candidates,
-			@Nonnull Function<IN, SlotInfo> contextExtractor,
-			@Nonnull Predicate<IN> additionalRequirementsFilter,
-			@Nonnull BiFunction<IN, Locality, OUT> resultProducer) {
-
-		Collection<AllocationID> priorAllocations = slotProfile.getPreferredAllocations();
-
-		if (priorAllocations.isEmpty()) {
-			return super.findMatchWithLocality(
-				slotProfile,
-				candidates,
-				contextExtractor,
-				additionalRequirementsFilter,
-				resultProducer);
-		} else {
-			return findPreviousAllocation(
-				slotProfile,
-				candidates,
-				contextExtractor,
-				additionalRequirementsFilter,
-				resultProducer,
-				priorAllocations);
-		}
-	}
-
-	@Nullable
-	private <IN, OUT> OUT findPreviousAllocation(
-			@Nonnull SlotProfile slotProfile,
-			@Nonnull Supplier<Stream<IN>> candidates,
-			@Nonnull Function<IN, SlotInfo> contextExtractor,
-			@Nonnull Predicate<IN> additionalRequirementsFilter,
-			@Nonnull BiFunction<IN, Locality, OUT> resultProducer,
-			@Nonnull Collection<AllocationID> priorAllocations) {
-
-		Predicate<IN> filterByAllocation =
-			(IN candidate) -> priorAllocations.contains(contextExtractor.apply(candidate).getAllocationId());
-
-		OUT previousAllocationCandidate = candidates
-			.get()
-			.filter(filterByAllocation.and(additionalRequirementsFilter))
-			.findFirst()
-			.map((IN result) -> resultProducer.apply(result, Locality.LOCAL)) // TODO introduce special locality?
-			.orElse(null);
-
-		if (previousAllocationCandidate != null) {
-			return previousAllocationCandidate;
-		}
-
-		Set<AllocationID> blackListedAllocationIDs = slotProfile.getPreviousExecutionGraphAllocations();
-		Stream<IN> candidateStream = candidates.get();
-		if (!blackListedAllocationIDs.isEmpty()) {
-			candidateStream = candidateStream.filter(
-				(IN candidate) -> !blackListedAllocationIDs.contains(
-					contextExtractor.apply(candidate).getAllocationId()));
-		}
-
-		return doFindMatchWithLocality(
-			slotProfile,
-			candidateStream,
-			contextExtractor,
-			additionalRequirementsFilter,
-			resultProducer);
-	}
-
-	public static PreviousAllocationSchedulingStrategy getInstance() {
-		return INSTANCE;
-	}
-}
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/PreviousAllocationSlotSelectionStrategy.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/PreviousAllocationSlotSelectionStrategy.java
new file mode 100644
index 0000000..e2e7bc2
--- /dev/null
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/PreviousAllocationSlotSelectionStrategy.java
@@ -0,0 +1,83 @@
+/*
+ * 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.jobmaster.slotpool;
+
+import org.apache.flink.runtime.clusterframework.types.AllocationID;
+import org.apache.flink.runtime.clusterframework.types.SlotProfile;
+import org.apache.flink.runtime.jobmanager.scheduler.Locality;
+import org.apache.flink.runtime.jobmaster.SlotInfo;
+
+import javax.annotation.Nonnull;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Optional;
+import java.util.Set;
+
+/**
+ * This class implements a {@link SlotSelectionStrategy} that is based on previous allocations and
+ * falls back to using location preference hints if there is no previous allocation.
+ */
+public enum PreviousAllocationSlotSelectionStrategy implements SlotSelectionStrategy {
+
+	INSTANCE;
+
+	@Override
+	public Optional<SlotInfoAndLocality> selectBestSlotForProfile(
+		@Nonnull Collection<? extends SlotInfo> availableSlots,
+		@Nonnull SlotProfile slotProfile) {
+
+		Collection<AllocationID> priorAllocations = slotProfile.getPreferredAllocations();
+
+		// First, if there was a prior allocation try to schedule to the same/old slot
+		if (!priorAllocations.isEmpty()) {
+			for (SlotInfo availableSlot : availableSlots) {
+				if (priorAllocations.contains(availableSlot.getAllocationId())) {
+					return Optional.of(
+						SlotInfoAndLocality.of(availableSlot, Locality.LOCAL));
+				}
+			}
+		}
+
+		// Second, select based on location preference, excluding blacklisted allocations
+		Set<AllocationID> blackListedAllocations = slotProfile.getPreviousExecutionGraphAllocations();
+		Collection<? extends SlotInfo> availableAndAllowedSlots = computeWithoutBlacklistedSlots(availableSlots, blackListedAllocations);
+		return LocationPreferenceSlotSelectionStrategy.INSTANCE.selectBestSlotForProfile(availableAndAllowedSlots, slotProfile);
+	}
+
+	@Nonnull
+	private Collection<SlotInfo> computeWithoutBlacklistedSlots(
+		@Nonnull Collection<? extends SlotInfo> availableSlots,
+		@Nonnull Set<AllocationID> blacklistedAllocations) {
+
+		if (blacklistedAllocations.isEmpty()) {
+			return Collections.unmodifiableCollection(availableSlots);
+		}
+
+		ArrayList<SlotInfo> availableAndAllowedSlots = new ArrayList<>(availableSlots.size());
+		for (SlotInfo availableSlot : availableSlots) {
+			if (!blacklistedAllocations.contains(availableSlot.getAllocationId())) {
+				availableAndAllowedSlots.add(availableSlot);
+			}
+		}
+
+		return availableAndAllowedSlots;
+	}
+}
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmanager/slots/DummySlotOwner.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/Scheduler.java
similarity index 51%
copy from flink-runtime/src/test/java/org/apache/flink/runtime/jobmanager/slots/DummySlotOwner.java
copy to flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/Scheduler.java
index add1ec2..628726d 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmanager/slots/DummySlotOwner.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/Scheduler.java
@@ -7,7 +7,7 @@
  * "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
+ * 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,
@@ -16,19 +16,27 @@
  * limitations under the License.
  */
 
-package org.apache.flink.runtime.jobmanager.slots;
+package org.apache.flink.runtime.jobmaster.slotpool;
 
-import org.apache.flink.runtime.jobmaster.LogicalSlot;
+import org.apache.flink.runtime.concurrent.ComponentMainThreadExecutor;
 import org.apache.flink.runtime.jobmaster.SlotOwner;
 
-import java.util.concurrent.CompletableFuture;
+import javax.annotation.Nonnull;
 
 /**
- * SlotOwner implementation used for testing purposes only.
+ * Basic interface for the current scheduler, which is a {@link SlotProvider} and a {@link SlotOwner}.
  */
-public class DummySlotOwner implements SlotOwner {
-	@Override
-	public CompletableFuture<Boolean> returnAllocatedSlot(LogicalSlot logicalSlot) {
-		return CompletableFuture.completedFuture(false);
-	}
+public interface Scheduler extends SlotProvider, SlotOwner {
+
+	/**
+	 * Start the scheduler by initializing the main thread executor.
+	 *
+	 * @param mainThreadExecutor the main thread executor of the job master.
+	 */
+	void start(@Nonnull ComponentMainThreadExecutor mainThreadExecutor);
+
+	/**
+	 * Returns true, iff the scheduling strategy of the scheduler requires to know about previous allocations.
+	 */
+	boolean requiresPreviousExecutionGraphAllocations();
 }
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/SlotOwner.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SchedulerFactory.java
similarity index 60%
copy from flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/SlotOwner.java
copy to flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SchedulerFactory.java
index 9cc6f81..10f7386 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/SlotOwner.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SchedulerFactory.java
@@ -7,7 +7,7 @@
  * "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
+ * 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,
@@ -16,20 +16,18 @@
  * limitations under the License.
  */
 
-package org.apache.flink.runtime.jobmaster;
+package org.apache.flink.runtime.jobmaster.slotpool;
 
-import java.util.concurrent.CompletableFuture;
+import javax.annotation.Nonnull;
 
 /**
- * Interface for components that hold slots and to which slots get released / recycled.
+ * Factory interface for {@link Scheduler}.
  */
-public interface SlotOwner {
+public interface SchedulerFactory {
 
 	/**
-	 * Return the given slot to the slot owner.
-	 *
-	 * @param logicalSlot to return
-	 * @return Future which is completed with true if the slot could be returned, otherwise with false
+	 * Creates a new scheduler instance that uses the given {@link SlotPool} to allocate slots.
 	 */
-	CompletableFuture<Boolean> returnAllocatedSlot(LogicalSlot logicalSlot);
+	@Nonnull
+	Scheduler createScheduler(@Nonnull SlotPool slotPool);
 }
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SchedulerImpl.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SchedulerImpl.java
new file mode 100644
index 0000000..aef6da1
--- /dev/null
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SchedulerImpl.java
@@ -0,0 +1,521 @@
+/*
+ * 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.jobmaster.slotpool;
+
+import org.apache.flink.annotation.VisibleForTesting;
+import org.apache.flink.api.common.time.Time;
+import org.apache.flink.runtime.clusterframework.types.SlotProfile;
+import org.apache.flink.runtime.concurrent.ComponentMainThreadExecutor;
+import org.apache.flink.runtime.concurrent.FutureUtils;
+import org.apache.flink.runtime.instance.SlotSharingGroupId;
+import org.apache.flink.runtime.jobmanager.scheduler.CoLocationConstraint;
+import org.apache.flink.runtime.jobmanager.scheduler.Locality;
+import org.apache.flink.runtime.jobmanager.scheduler.NoResourceAvailableException;
+import org.apache.flink.runtime.jobmanager.scheduler.ScheduledUnit;
+import org.apache.flink.runtime.jobmaster.LogicalSlot;
+import org.apache.flink.runtime.jobmaster.SlotContext;
+import org.apache.flink.runtime.jobmaster.SlotInfo;
+import org.apache.flink.runtime.jobmaster.SlotRequestId;
+import org.apache.flink.util.AbstractID;
+import org.apache.flink.util.FlinkException;
+import org.apache.flink.util.Preconditions;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CompletionException;
+
+/**
+ * Scheduler that assigns tasks to slots. This class is currently work in progress, comments will be updated as we
+ * move forward.
+ */
+public class SchedulerImpl implements Scheduler {
+
+	private static final Logger log = LoggerFactory.getLogger(SchedulerImpl.class);
+
+	private static final int DEFAULT_SLOT_SHARING_MANAGERS_MAP_SIZE = 128;
+
+	/** Strategy that selects the best slot for a given slot allocation request. */
+	@Nonnull
+	private final SlotSelectionStrategy slotSelectionStrategy;
+
+	/** The slot pool from which slots are allocated. */
+	@Nonnull
+	private final SlotPool slotPool;
+
+	/** Executor for running tasks in the job master's main thread. */
+	@Nonnull
+	private ComponentMainThreadExecutor componentMainThreadExecutor;
+
+	/** Managers for the different slot sharing groups. */
+	@Nonnull
+	private final Map<SlotSharingGroupId, SlotSharingManager> slotSharingManagers;
+
+	public SchedulerImpl(
+		@Nonnull SlotSelectionStrategy slotSelectionStrategy,
+		@Nonnull SlotPool slotPool) {
+		this(slotSelectionStrategy, slotPool, new HashMap<>(DEFAULT_SLOT_SHARING_MANAGERS_MAP_SIZE));
+	}
+
+	@VisibleForTesting
+	public SchedulerImpl(
+		@Nonnull SlotSelectionStrategy slotSelectionStrategy,
+		@Nonnull SlotPool slotPool,
+		@Nonnull Map<SlotSharingGroupId, SlotSharingManager> slotSharingManagers) {
+
+		this.slotSelectionStrategy = slotSelectionStrategy;
+		this.slotSharingManagers = slotSharingManagers;
+		this.slotPool = slotPool;
+		this.componentMainThreadExecutor = new ComponentMainThreadExecutor.DummyComponentMainThreadExecutor(
+			"Scheduler is not initialized with proper main thread executor. " +
+				"Call to Scheduler.start(...) required.");
+	}
+
+	@Override
+	public void start(@Nonnull ComponentMainThreadExecutor mainThreadExecutor) {
+		this.componentMainThreadExecutor = mainThreadExecutor;
+	}
+
+	//---------------------------
+
+	@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;
+	}
+
+	@Override
+	public void cancelSlotRequest(
+		SlotRequestId slotRequestId,
+		@Nullable SlotSharingGroupId slotSharingGroupId,
+		Throwable cause) {
+
+		componentMainThreadExecutor.assertRunningInMainThread();
+
+		if (slotSharingGroupId != null) {
+			releaseSharedSlot(slotRequestId, slotSharingGroupId, cause);
+		} else {
+			slotPool.releaseSlot(slotRequestId, cause);
+		}
+	}
+
+	@Override
+	public void returnLogicalSlot(LogicalSlot logicalSlot) {
+		SlotRequestId slotRequestId = logicalSlot.getSlotRequestId();
+		SlotSharingGroupId slotSharingGroupId = logicalSlot.getSlotSharingGroupId();
+		FlinkException cause = new FlinkException("Slot is being returned to the SlotPool.");
+		cancelSlotRequest(slotRequestId, slotSharingGroupId, cause);
+	}
+
+	//---------------------------
+
+	private CompletableFuture<LogicalSlot> allocateSingleSlot(
+		SlotRequestId slotRequestId,
+		SlotProfile slotProfile,
+		boolean allowQueuedScheduling,
+		Time allocationTimeout) {
+
+		Optional<SlotAndLocality> slotAndLocality = tryAllocateFromAvailable(slotRequestId, slotProfile);
+
+		if (slotAndLocality.isPresent()) {
+			// already successful from available
+			try {
+				return CompletableFuture.completedFuture(
+					completeAllocationByAssigningPayload(slotRequestId, slotAndLocality.get()));
+			} catch (FlinkException e) {
+				return FutureUtils.completedExceptionally(e);
+			}
+		} else if (allowQueuedScheduling) {
+			// we allocate by requesting a new slot
+			return slotPool
+				.requestNewAllocatedSlot(slotRequestId, slotProfile.getResourceProfile(), allocationTimeout)
+				.thenApply((PhysicalSlot allocatedSlot) -> {
+					try {
+						return completeAllocationByAssigningPayload(slotRequestId, new SlotAndLocality(allocatedSlot, Locality.UNKNOWN));
+					} catch (FlinkException e) {
+						throw new CompletionException(e);
+					}
+				});
+		} else {
+			// failed to allocate
+			return FutureUtils.completedExceptionally(
+				new NoResourceAvailableException("Could not allocate a simple slot for " + slotRequestId + '.'));
+		}
+	}
+
+	@Nonnull
+	private LogicalSlot completeAllocationByAssigningPayload(
+		@Nonnull SlotRequestId slotRequestId,
+		@Nonnull SlotAndLocality slotAndLocality) throws FlinkException {
+
+		final PhysicalSlot allocatedSlot = slotAndLocality.getSlot();
+
+		final SingleLogicalSlot singleTaskSlot = new SingleLogicalSlot(
+			slotRequestId,
+			allocatedSlot,
+			null,
+			slotAndLocality.getLocality(),
+			this);
+
+		if (allocatedSlot.tryAssignPayload(singleTaskSlot)) {
+			return singleTaskSlot;
+		} else {
+			final FlinkException flinkException =
+				new FlinkException("Could not assign payload to allocated slot " + allocatedSlot.getAllocationId() + '.');
+			slotPool.releaseSlot(slotRequestId, flinkException);
+			throw flinkException;
+		}
+	}
+
+	private Optional<SlotAndLocality> tryAllocateFromAvailable(
+		@Nonnull SlotRequestId slotRequestId,
+		@Nonnull SlotProfile slotProfile) {
+
+		Collection<SlotInfo> slotInfoList = slotPool.getAvailableSlotsInformation();
+
+		Optional<SlotSelectionStrategy.SlotInfoAndLocality> selectedAvailableSlot =
+			slotSelectionStrategy.selectBestSlotForProfile(slotInfoList, slotProfile);
+
+		return selectedAvailableSlot.flatMap(slotInfoAndLocality -> {
+			Optional<PhysicalSlot> optionalAllocatedSlot = slotPool.allocateAvailableSlot(
+				slotRequestId,
+				slotInfoAndLocality.getSlotInfo().getAllocationId());
+
+			return optionalAllocatedSlot.map(
+				allocatedSlot -> new SlotAndLocality(allocatedSlot, slotInfoAndLocality.getLocality()));
+		});
+	}
+
+	// ------------------------------- slot sharing code
+
+	private CompletableFuture<LogicalSlot> allocateSharedSlot(
+		SlotRequestId slotRequestId,
+		ScheduledUnit scheduledUnit,
+		SlotProfile slotProfile,
+		boolean allowQueuedScheduling,
+		Time allocationTimeout) {
+		// allocate slot with slot sharing
+		final SlotSharingManager multiTaskSlotManager = slotSharingManagers.computeIfAbsent(
+			scheduledUnit.getSlotSharingGroupId(),
+			id -> new SlotSharingManager(
+				id,
+				slotPool,
+				this));
+
+		final SlotSharingManager.MultiTaskSlotLocality multiTaskSlotLocality;
+		try {
+			if (scheduledUnit.getCoLocationConstraint() != null) {
+				multiTaskSlotLocality = allocateCoLocatedMultiTaskSlot(
+					scheduledUnit.getCoLocationConstraint(),
+					multiTaskSlotManager,
+					slotProfile,
+					allowQueuedScheduling,
+					allocationTimeout);
+			} else {
+				multiTaskSlotLocality = allocateMultiTaskSlot(
+					scheduledUnit.getJobVertexId(),
+					multiTaskSlotManager,
+					slotProfile,
+					allowQueuedScheduling,
+					allocationTimeout);
+			}
+		} catch (NoResourceAvailableException noResourceException) {
+			return FutureUtils.completedExceptionally(noResourceException);
+		}
+
+		// sanity check
+		Preconditions.checkState(!multiTaskSlotLocality.getMultiTaskSlot().contains(scheduledUnit.getJobVertexId()));
+
+		final SlotSharingManager.SingleTaskSlot leaf = multiTaskSlotLocality.getMultiTaskSlot().allocateSingleTaskSlot(
+			slotRequestId,
+			scheduledUnit.getJobVertexId(),
+			multiTaskSlotLocality.getLocality());
+		return leaf.getLogicalSlotFuture();
+	}
+
+	/**
+	 * Allocates a co-located {@link SlotSharingManager.MultiTaskSlot} for the given {@link CoLocationConstraint}.
+	 *
+	 * <p>If allowQueuedScheduling is true, then the returned {@link SlotSharingManager.MultiTaskSlot} can be
+	 * uncompleted.
+	 *
+	 * @param coLocationConstraint for which to allocate a {@link SlotSharingManager.MultiTaskSlot}
+	 * @param multiTaskSlotManager responsible for the slot sharing group for which to allocate the slot
+	 * @param slotProfile specifying the requirements for the requested slot
+	 * @param allowQueuedScheduling true if queued scheduling (the returned task slot must not be completed yet) is allowed, otherwise false
+	 * @param allocationTimeout timeout before the slot allocation times out
+	 * @return A {@link SlotAndLocality} which contains the allocated{@link SlotSharingManager.MultiTaskSlot}
+	 * 		and its locality wrt the given location preferences
+	 */
+	private SlotSharingManager.MultiTaskSlotLocality allocateCoLocatedMultiTaskSlot(
+		CoLocationConstraint coLocationConstraint,
+		SlotSharingManager multiTaskSlotManager,
+		SlotProfile slotProfile,
+		boolean allowQueuedScheduling,
+		Time allocationTimeout) throws NoResourceAvailableException {
+		final SlotRequestId coLocationSlotRequestId = coLocationConstraint.getSlotRequestId();
+
+		if (coLocationSlotRequestId != null) {
+			// we have a slot assigned --> try to retrieve it
+			final SlotSharingManager.TaskSlot taskSlot = multiTaskSlotManager.getTaskSlot(coLocationSlotRequestId);
+
+			if (taskSlot != null) {
+				Preconditions.checkState(taskSlot instanceof SlotSharingManager.MultiTaskSlot);
+				return SlotSharingManager.MultiTaskSlotLocality.of(((SlotSharingManager.MultiTaskSlot) taskSlot), Locality.LOCAL);
+			} else {
+				// the slot may have been cancelled in the mean time
+				coLocationConstraint.setSlotRequestId(null);
+			}
+		}
+
+		if (coLocationConstraint.isAssigned()) {
+			// refine the preferred locations of the slot profile
+			slotProfile = new SlotProfile(
+				slotProfile.getResourceProfile(),
+				Collections.singleton(coLocationConstraint.getLocation()),
+				slotProfile.getPreferredAllocations());
+		}
+
+		// get a new multi task slot
+		SlotSharingManager.MultiTaskSlotLocality multiTaskSlotLocality = allocateMultiTaskSlot(
+			coLocationConstraint.getGroupId(),
+			multiTaskSlotManager,
+			slotProfile,
+			allowQueuedScheduling,
+			allocationTimeout);
+
+		// check whether we fulfill the co-location constraint
+		if (coLocationConstraint.isAssigned() && multiTaskSlotLocality.getLocality() != Locality.LOCAL) {
+			multiTaskSlotLocality.getMultiTaskSlot().release(
+				new FlinkException("Multi task slot is not local and, thus, does not fulfill the co-location constraint."));
+
+			throw new NoResourceAvailableException("Could not allocate a local multi task slot for the " +
+				"co location constraint " + coLocationConstraint + '.');
+		}
+
+		final SlotRequestId slotRequestId = new SlotRequestId();
+		final SlotSharingManager.MultiTaskSlot coLocationSlot =
+			multiTaskSlotLocality.getMultiTaskSlot().allocateMultiTaskSlot(
+				slotRequestId,
+				coLocationConstraint.getGroupId());
+
+		// mark the requested slot as co-located slot for other co-located tasks
+		coLocationConstraint.setSlotRequestId(slotRequestId);
+
+		// lock the co-location constraint once we have obtained the allocated slot
+		coLocationSlot.getSlotContextFuture().whenComplete(
+			(SlotContext slotContext, Throwable throwable) -> {
+				if (throwable == null) {
+					// check whether we are still assigned to the co-location constraint
+					if (Objects.equals(coLocationConstraint.getSlotRequestId(), slotRequestId)) {
+						coLocationConstraint.lockLocation(slotContext.getTaskManagerLocation());
+					} else {
+						log.debug("Failed to lock colocation constraint {} because assigned slot " +
+								"request {} differs from fulfilled slot request {}.",
+							coLocationConstraint.getGroupId(),
+							coLocationConstraint.getSlotRequestId(),
+							slotRequestId);
+					}
+				} else {
+					log.debug("Failed to lock colocation constraint {} because the slot " +
+							"allocation for slot request {} failed.",
+						coLocationConstraint.getGroupId(),
+						coLocationConstraint.getSlotRequestId(),
+						throwable);
+				}
+			});
+
+		return SlotSharingManager.MultiTaskSlotLocality.of(coLocationSlot, multiTaskSlotLocality.getLocality());
+	}
+
+	/**
+	 * Allocates a {@link SlotSharingManager.MultiTaskSlot} for the given groupId which is in the
+	 * slot sharing group for which the given {@link SlotSharingManager} is responsible.
+	 *
+	 * <p>If allowQueuedScheduling is true, then the method can return an uncompleted {@link SlotSharingManager.MultiTaskSlot}.
+	 *
+	 * @param groupId for which to allocate a new {@link SlotSharingManager.MultiTaskSlot}
+	 * @param slotSharingManager responsible for the slot sharing group for which to allocate the slot
+	 * @param slotProfile slot profile that specifies the requirements for the slot
+	 * @param allowQueuedScheduling true if queued scheduling (the returned task slot must not be completed yet) is allowed, otherwise false
+	 * @param allocationTimeout timeout before the slot allocation times out
+	 * @return A {@link SlotSharingManager.MultiTaskSlotLocality} which contains the allocated {@link SlotSharingManager.MultiTaskSlot}
+	 * 		and its locality wrt the given location preferences
+	 */
+	private SlotSharingManager.MultiTaskSlotLocality allocateMultiTaskSlot(
+		AbstractID groupId,
+		SlotSharingManager slotSharingManager,
+		SlotProfile slotProfile,
+		boolean allowQueuedScheduling,
+		Time allocationTimeout) throws NoResourceAvailableException {
+
+		Collection<SlotInfo> resolvedRootSlotsInfo = slotSharingManager.listResolvedRootSlotInfo(groupId);
+
+		SlotSelectionStrategy.SlotInfoAndLocality bestResolvedRootSlotWithLocality =
+			slotSelectionStrategy.selectBestSlotForProfile(resolvedRootSlotsInfo, slotProfile).orElse(null);
+
+		final SlotSharingManager.MultiTaskSlotLocality multiTaskSlotLocality = bestResolvedRootSlotWithLocality != null ?
+			new SlotSharingManager.MultiTaskSlotLocality(
+				slotSharingManager.getResolvedRootSlot(bestResolvedRootSlotWithLocality.getSlotInfo()),
+				bestResolvedRootSlotWithLocality.getLocality()) :
+			null;
+
+		if (multiTaskSlotLocality != null && multiTaskSlotLocality.getLocality() == Locality.LOCAL) {
+			return multiTaskSlotLocality;
+		}
+
+		final SlotRequestId allocatedSlotRequestId = new SlotRequestId();
+		final SlotRequestId multiTaskSlotRequestId = new SlotRequestId();
+
+		Optional<SlotAndLocality> optionalPoolSlotAndLocality = tryAllocateFromAvailable(allocatedSlotRequestId, slotProfile);
+
+		if (optionalPoolSlotAndLocality.isPresent()) {
+			SlotAndLocality poolSlotAndLocality = optionalPoolSlotAndLocality.get();
+			if (poolSlotAndLocality.getLocality() == Locality.LOCAL || bestResolvedRootSlotWithLocality == null) {
+
+				final PhysicalSlot allocatedSlot = poolSlotAndLocality.getSlot();
+				final SlotSharingManager.MultiTaskSlot multiTaskSlot = slotSharingManager.createRootSlot(
+					multiTaskSlotRequestId,
+					CompletableFuture.completedFuture(poolSlotAndLocality.getSlot()),
+					allocatedSlotRequestId);
+
+				if (allocatedSlot.tryAssignPayload(multiTaskSlot)) {
+					return SlotSharingManager.MultiTaskSlotLocality.of(multiTaskSlot, poolSlotAndLocality.getLocality());
+				} else {
+					multiTaskSlot.release(new FlinkException("Could not assign payload to allocated slot " +
+						allocatedSlot.getAllocationId() + '.'));
+				}
+			}
+		}
+
+		if (multiTaskSlotLocality != null) {
+			// prefer slot sharing group slots over unused slots
+			if (optionalPoolSlotAndLocality.isPresent()) {
+				slotPool.releaseSlot(
+					allocatedSlotRequestId,
+					new FlinkException("Locality constraint is not better fulfilled by allocated slot."));
+			}
+			return multiTaskSlotLocality;
+		}
+
+		if (allowQueuedScheduling) {
+			// there is no slot immediately available --> check first for uncompleted slots at the slot sharing group
+			SlotSharingManager.MultiTaskSlot multiTaskSlot = slotSharingManager.getUnresolvedRootSlot(groupId);
+
+			if (multiTaskSlot == null) {
+				// it seems as if we have to request a new slot from the resource manager, this is always the last resort!!!
+				final CompletableFuture<PhysicalSlot> slotAllocationFuture = slotPool.requestNewAllocatedSlot(
+					allocatedSlotRequestId,
+					slotProfile.getResourceProfile(),
+					allocationTimeout);
+
+				multiTaskSlot = slotSharingManager.createRootSlot(
+					multiTaskSlotRequestId,
+					slotAllocationFuture,
+					allocatedSlotRequestId);
+
+				slotAllocationFuture.whenComplete(
+					(PhysicalSlot allocatedSlot, Throwable throwable) -> {
+						final SlotSharingManager.TaskSlot taskSlot = slotSharingManager.getTaskSlot(multiTaskSlotRequestId);
+
+						if (taskSlot != null) {
+							// still valid
+							if (!(taskSlot instanceof SlotSharingManager.MultiTaskSlot) || throwable != null) {
+								taskSlot.release(throwable);
+							} else {
+								if (!allocatedSlot.tryAssignPayload(((SlotSharingManager.MultiTaskSlot) taskSlot))) {
+									taskSlot.release(new FlinkException("Could not assign payload to allocated slot " +
+										allocatedSlot.getAllocationId() + '.'));
+								}
+							}
+						} else {
+							slotPool.releaseSlot(
+								allocatedSlotRequestId,
+								new FlinkException("Could not find task slot with " + multiTaskSlotRequestId + '.'));
+						}
+					});
+			}
+
+			return SlotSharingManager.MultiTaskSlotLocality.of(multiTaskSlot, Locality.UNKNOWN);
+		}
+
+		throw new NoResourceAvailableException("Could not allocate a shared slot for " + groupId + '.');
+	}
+
+	private void releaseSharedSlot(
+		@Nonnull SlotRequestId slotRequestId,
+		@Nonnull SlotSharingGroupId slotSharingGroupId,
+		Throwable cause) {
+
+		final SlotSharingManager multiTaskSlotManager = slotSharingManagers.get(slotSharingGroupId);
+
+		if (multiTaskSlotManager != null) {
+			final SlotSharingManager.TaskSlot taskSlot = multiTaskSlotManager.getTaskSlot(slotRequestId);
+
+			if (taskSlot != null) {
+				taskSlot.release(cause);
+			} else {
+				log.debug("Could not find slot [{}] in slot sharing group {}. Ignoring release slot request.", slotRequestId, slotSharingGroupId);
+			}
+		} else {
+			log.debug("Could not find slot sharing group {}. Ignoring release slot request.", slotSharingGroupId);
+		}
+	}
+
+	@Override
+	public boolean requiresPreviousExecutionGraphAllocations() {
+		return slotSelectionStrategy instanceof PreviousAllocationSlotSelectionStrategy;
+	}
+}
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SchedulingStrategy.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SchedulingStrategy.java
deleted file mode 100644
index 89b2d05..0000000
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SchedulingStrategy.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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.jobmaster.slotpool;
-
-import org.apache.flink.runtime.clusterframework.types.SlotProfile;
-import org.apache.flink.runtime.jobmanager.scheduler.Locality;
-import org.apache.flink.runtime.jobmaster.SlotContext;
-import org.apache.flink.runtime.jobmaster.SlotInfo;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import java.util.function.BiFunction;
-import java.util.function.Function;
-import java.util.function.Predicate;
-import java.util.function.Supplier;
-import java.util.stream.Stream;
-
-/**
- * Classes that implement this interface provide a method to match objects to somehow represent slot candidates
- * against the {@link SlotProfile} that produced the matcher object. A matching candidate is transformed into a
- * desired result. If the matcher does not find a matching candidate, it returns null.
- */
-public interface SchedulingStrategy {
-
-	/**
-	 * This method takes the candidate slots, extracts slot contexts from them, filters them by the profile
-	 * requirements and potentially by additional requirements, and produces a result from a match.
-	 *
-	 * @param slotProfile slotProfile for which to find a matching slot
-	 * @param candidates stream of candidates to match against.
-	 * @param contextExtractor function to extract the {@link SlotContext} from the candidates.
-	 * @param additionalRequirementsFilter predicate to specify additional requirements for each candidate.
-	 * @param resultProducer function to produce a result from a matching candidate input.
-	 * @param <IN> type of the objects against we match the profile.
-	 * @param <OUT> type of the produced output from a matching object.
-	 * @return the result produced by resultProducer if a matching candidate was found or null otherwise.
-	 */
-	@Nullable
-	<IN, OUT> OUT findMatchWithLocality(
-		@Nonnull SlotProfile slotProfile,
-		@Nonnull Supplier<Stream<IN>> candidates,
-		@Nonnull Function<IN, SlotInfo> contextExtractor,
-		@Nonnull Predicate<IN> additionalRequirementsFilter,
-		@Nonnull BiFunction<IN, Locality, OUT> resultProducer);
-}
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SingleLogicalSlot.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SingleLogicalSlot.java
index 74c841f..707bba9 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SingleLogicalSlot.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SingleLogicalSlot.java
@@ -33,12 +33,11 @@ import javax.annotation.Nullable;
 
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
-import java.util.function.Function;
 
 /**
- * Implementation of the {@link LogicalSlot} which is used by the {@link SlotPool}.
+ * Implementation of the {@link LogicalSlot} which is used by the {@link SlotPoolImpl}.
  */
-public class SingleLogicalSlot implements LogicalSlot, AllocatedSlot.Payload {
+public class SingleLogicalSlot implements LogicalSlot, PhysicalSlot.Payload {
 
 	private static final AtomicReferenceFieldUpdater<SingleLogicalSlot, Payload> PAYLOAD_UPDATER = AtomicReferenceFieldUpdater.newUpdater(
 		SingleLogicalSlot.class,
@@ -171,29 +170,25 @@ public class SingleLogicalSlot implements LogicalSlot, AllocatedSlot.Payload {
 
 	private void signalPayloadRelease(Throwable cause) {
 		tryAssignPayload(TERMINATED_PAYLOAD);
-		payload.failAsync(cause); //TODO this goes from the pool against the execution, has to by sync'ed back into the jm main thread
+		payload.fail(cause);
 	}
 
 	private void returnSlotToOwner(CompletableFuture<?> terminalStateFuture) {
 		terminalStateFuture
-			.handle((Object ignored, Throwable throwable) -> {
+			.whenComplete((Object ignored, Throwable throwable) -> {
+
 				if (state == State.RELEASING) {
-					return slotOwner.returnAllocatedSlot(this);
+					slotOwner.returnLogicalSlot(this);
+				}
+
+				markReleased();
+
+				if (throwable != null) {
+					releaseFuture.completeExceptionally(throwable);
 				} else {
-					return CompletableFuture.completedFuture(true);
+					releaseFuture.complete(null);
 				}
-			})
-			.thenCompose(Function.identity())
-			.whenComplete( //TODO this could be inside the job master main thread, should be inside slot pool main thread
-				(Object ignored, Throwable throwable) -> {
-					markReleased();
-
-					if (throwable != null) {
-						releaseFuture.completeExceptionally(throwable);
-					} else {
-						releaseFuture.complete(null);
-					}
-				});
+			});
 	}
 
 	private void markReleased() {
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SlotAndLocality.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SlotAndLocality.java
index 4befb51..0951f35 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SlotAndLocality.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SlotAndLocality.java
@@ -28,12 +28,12 @@ import javax.annotation.Nonnull;
 public class SlotAndLocality {
 
 	@Nonnull
-	private final AllocatedSlot slot;
+	private final PhysicalSlot slot;
 
 	@Nonnull
 	private final Locality locality;
 
-	public SlotAndLocality(@Nonnull AllocatedSlot slot, @Nonnull Locality locality) {
+	public SlotAndLocality(@Nonnull PhysicalSlot slot, @Nonnull Locality locality) {
 		this.slot = slot;
 		this.locality = locality;
 	}
@@ -41,7 +41,7 @@ public class SlotAndLocality {
 	// ------------------------------------------------------------------------
 
 	@Nonnull
-	public AllocatedSlot getSlot() {
+	public PhysicalSlot getSlot() {
 		return slot;
 	}
 
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPool.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPool.java
index f69c1a4..2191cea 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPool.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPool.java
@@ -18,1725 +18,149 @@
 
 package org.apache.flink.runtime.jobmaster.slotpool;
 
-import org.apache.flink.annotation.VisibleForTesting;
-import org.apache.flink.api.common.JobID;
 import org.apache.flink.api.common.time.Time;
-import org.apache.flink.configuration.JobManagerOptions;
-import org.apache.flink.runtime.akka.AkkaUtils;
 import org.apache.flink.runtime.clusterframework.types.AllocationID;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
 import org.apache.flink.runtime.clusterframework.types.ResourceProfile;
-import org.apache.flink.runtime.clusterframework.types.SlotID;
-import org.apache.flink.runtime.clusterframework.types.SlotProfile;
-import org.apache.flink.runtime.concurrent.FutureUtils;
-import org.apache.flink.runtime.executiongraph.ExecutionGraph;
-import org.apache.flink.runtime.instance.SlotSharingGroupId;
-import org.apache.flink.runtime.jobmanager.scheduler.CoLocationConstraint;
-import org.apache.flink.runtime.jobmanager.scheduler.Locality;
-import org.apache.flink.runtime.jobmanager.scheduler.NoResourceAvailableException;
-import org.apache.flink.runtime.jobmanager.scheduler.ScheduledUnit;
+import org.apache.flink.runtime.concurrent.ComponentMainThreadExecutor;
 import org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway;
 import org.apache.flink.runtime.jobmaster.JobMasterId;
-import org.apache.flink.runtime.jobmaster.LogicalSlot;
-import org.apache.flink.runtime.jobmaster.SlotContext;
-import org.apache.flink.runtime.jobmaster.SlotOwner;
+import org.apache.flink.runtime.jobmaster.SlotInfo;
 import org.apache.flink.runtime.jobmaster.SlotRequestId;
-import org.apache.flink.runtime.messages.Acknowledge;
 import org.apache.flink.runtime.resourcemanager.ResourceManagerGateway;
-import org.apache.flink.runtime.resourcemanager.SlotRequest;
-import org.apache.flink.runtime.rpc.RpcEndpoint;
-import org.apache.flink.runtime.rpc.RpcService;
+import org.apache.flink.runtime.rpc.RpcTimeout;
 import org.apache.flink.runtime.taskexecutor.slot.SlotOffer;
 import org.apache.flink.runtime.taskmanager.TaskManagerLocation;
-import org.apache.flink.runtime.util.clock.Clock;
-import org.apache.flink.runtime.util.clock.SystemClock;
-import org.apache.flink.types.SerializableOptional;
-import org.apache.flink.util.AbstractID;
-import org.apache.flink.util.FlinkException;
-import org.apache.flink.util.Preconditions;
 
 import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
 
-import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Objects;
 import java.util.Optional;
-import java.util.Set;
 import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.CompletionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import static org.apache.flink.util.Preconditions.checkNotNull;
 
 /**
- * The slot pool serves slot request issued by {@link ExecutionGraph}. It will attempt to acquire new slots
- * from the ResourceManager when it cannot serve a slot request. If no ResourceManager is currently available,
- * or it gets a decline from the ResourceManager, or a request times out, it fails the slot request. The slot pool also
- * holds all the slots that were offered to it and accepted, and can thus provides registered free slots even if the
- * ResourceManager is down. The slots will only be released when they are useless, e.g. when the job is fully running
- * but we still have some free slots.
- *
- * <p>All the allocation or the slot offering will be identified by self generated AllocationID, we will use it to
- * eliminate ambiguities.
- *
- * <p>TODO : Make pending requests location preference aware
- * TODO : Make pass location preferences to ResourceManager when sending a slot request
+ * The Interface of a slot pool that manages slots.
  */
-public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedSlotActions {
-
-	/** The interval (in milliseconds) in which the SlotPool writes its slot distribution on debug level. */
-	private static final int STATUS_LOG_INTERVAL_MS = 60_000;
-
-	private final JobID jobId;
-
-	private final SchedulingStrategy schedulingStrategy;
-
-	private final ProviderAndOwner providerAndOwner;
-
-	/** All registered TaskManagers, slots will be accepted and used only if the resource is registered. */
-	private final HashSet<ResourceID> registeredTaskManagers;
-
-	/** The book-keeping of all allocated slots. */
-	private final AllocatedSlots allocatedSlots;
-
-	/** The book-keeping of all available slots. */
-	private final AvailableSlots availableSlots;
-
-	/** All pending requests waiting for slots. */
-	private final DualKeyMap<SlotRequestId, AllocationID, PendingRequest> pendingRequests;
-
-	/** The requests that are waiting for the resource manager to be connected. */
-	private final HashMap<SlotRequestId, PendingRequest> waitingForResourceManager;
-
-	/** Timeout for external request calls (e.g. to the ResourceManager or the TaskExecutor). */
-	private final Time rpcTimeout;
-
-	/** Timeout for releasing idle slots. */
-	private final Time idleSlotTimeout;
-
-	private final Clock clock;
-
-	/** Managers for the different slot sharing groups. */
-	protected final Map<SlotSharingGroupId, SlotSharingManager> slotSharingManagers;
-
-	/** the fencing token of the job manager. */
-	private JobMasterId jobMasterId;
-
-	/** The gateway to communicate with resource manager. */
-	private ResourceManagerGateway resourceManagerGateway;
-
-	private String jobManagerAddress;
+public interface SlotPool extends AllocatedSlotActions, AutoCloseable {
 
 	// ------------------------------------------------------------------------
-
-	@VisibleForTesting
-	protected SlotPool(RpcService rpcService, JobID jobId, SchedulingStrategy schedulingStrategy) {
-		this(
-			rpcService,
-			jobId,
-			schedulingStrategy,
-			SystemClock.getInstance(),
-			AkkaUtils.getDefaultTimeout(),
-			Time.milliseconds(JobManagerOptions.SLOT_IDLE_TIMEOUT.defaultValue()));
-	}
-
-	public SlotPool(
-			RpcService rpcService,
-			JobID jobId,
-			SchedulingStrategy schedulingStrategy,
-			Clock clock,
-			Time rpcTimeout,
-			Time idleSlotTimeout) {
-
-		super(rpcService);
-
-		this.jobId = checkNotNull(jobId);
-		this.schedulingStrategy = checkNotNull(schedulingStrategy);
-		this.clock = checkNotNull(clock);
-		this.rpcTimeout = checkNotNull(rpcTimeout);
-		this.idleSlotTimeout = checkNotNull(idleSlotTimeout);
-
-		this.registeredTaskManagers = new HashSet<>(16);
-		this.allocatedSlots = new AllocatedSlots();
-		this.availableSlots = new AvailableSlots();
-		this.pendingRequests = new DualKeyMap<>(16);
-		this.waitingForResourceManager = new HashMap<>(16);
-
-		this.providerAndOwner = new ProviderAndOwner(
-			getSelfGateway(SlotPoolGateway.class),
-			schedulingStrategy instanceof PreviousAllocationSchedulingStrategy);
-
-		this.slotSharingManagers = new HashMap<>(4);
-
-		this.jobMasterId = null;
-		this.resourceManagerGateway = null;
-		this.jobManagerAddress = null;
-	}
-
+	//  lifecycle
 	// ------------------------------------------------------------------------
-	//  Starting and Stopping
-	// ------------------------------------------------------------------------
-
-	@Override
-	public void start() {
-		throw new UnsupportedOperationException("Should never call start() without leader ID");
-	}
-
-	/**
-	 * Start the slot pool to accept RPC calls.
-	 *
-	 * @param jobMasterId The necessary leader id for running the job.
-	 * @param newJobManagerAddress for the slot requests which are sent to the resource manager
-	 */
-	public void start(JobMasterId jobMasterId, String newJobManagerAddress) throws Exception {
-		this.jobMasterId = checkNotNull(jobMasterId);
-		this.jobManagerAddress = checkNotNull(newJobManagerAddress);
-
-		// TODO - start should not throw an exception
-		try {
-			super.start();
-		} catch (Exception e) {
-			throw new RuntimeException("This should never happen", e);
-		}
-
-		scheduleRunAsync(this::checkIdleSlot, idleSlotTimeout);
-
-		if (log.isDebugEnabled()) {
-			scheduleRunAsync(this::scheduledLogStatus, STATUS_LOG_INTERVAL_MS, TimeUnit.MILLISECONDS);
-		}
-	}
-
-	@Override
-	public CompletableFuture<Void> onStop() {
-		log.info("Stopping SlotPool.");
-		// cancel all pending allocations
-		Set<AllocationID> allocationIds = pendingRequests.keySetB();
-
-		for (AllocationID allocationId : allocationIds) {
-			resourceManagerGateway.cancelSlotRequest(allocationId);
-		}
-
-		// release all registered slots by releasing the corresponding TaskExecutors
-		for (ResourceID taskManagerResourceId : registeredTaskManagers) {
-			final FlinkException cause = new FlinkException(
-				"Releasing TaskManager " + taskManagerResourceId + ", because of stopping of SlotPool");
-			releaseTaskManagerInternal(taskManagerResourceId, cause);
-		}
-
-		clear();
-
-		return CompletableFuture.completedFuture(null);
-	}
-
-	/**
-	 * Suspends this pool, meaning it has lost its authority to accept and distribute slots.
-	 */
-	@Override
-	public CompletableFuture<Acknowledge> suspend() {
-		log.info("Suspending SlotPool.");
-
-		validateRunsInMainThread();
-
-		// cancel all pending allocations --> we can request these slots
-		// again after we regained the leadership
-		Set<AllocationID> allocationIds = pendingRequests.keySetB();
-
-		for (AllocationID allocationId : allocationIds) {
-			resourceManagerGateway.cancelSlotRequest(allocationId);
-		}
-
-		// suspend this RPC endpoint
-		stop();
 
-		// do not accept any requests
-		jobMasterId = null;
-		resourceManagerGateway = null;
+	void start(
+		JobMasterId jobMasterId,
+		String newJobManagerAddress,
+		ComponentMainThreadExecutor jmMainThreadScheduledExecutor) throws Exception;
 
-		// Clear (but not release!) the available slots. The TaskManagers should re-register them
-		// at the new leader JobManager/SlotPool
-		clear();
+	void suspend();
 
-		return CompletableFuture.completedFuture(Acknowledge.get());
-	}
+	void close();
 
 	// ------------------------------------------------------------------------
-	//  Getting PoolOwner and PoolProvider
+	//  resource manager connection
 	// ------------------------------------------------------------------------
 
 	/**
-	 * Gets the slot owner implementation for this pool.
+	 * Connects the SlotPool to the given ResourceManager. After this method is called, the
+	 * SlotPool will be able to request resources from the given ResourceManager.
 	 *
-	 * <p>This method does not mutate state and can be called directly (no RPC indirection)
-	 *
-	 * @return The slot owner implementation for this pool.
+	 * @param resourceManagerGateway  The RPC gateway for the resource manager.
 	 */
-	public SlotOwner getSlotOwner() {
-		return providerAndOwner;
-	}
+	void connectToResourceManager(ResourceManagerGateway resourceManagerGateway);
 
 	/**
-	 * Gets the slot provider implementation for this pool.
-	 *
-	 * <p>This method does not mutate state and can be called directly (no RPC indirection)
+	 * Disconnects the slot pool from its current Resource Manager. After this call, the pool will not
+	 * be able to request further slots from the Resource Manager, and all currently pending requests
+	 * to the resource manager will be canceled.
 	 *
-	 * @return The slot provider implementation for this pool.
+	 * <p>The slot pool will still be able to serve slots from its internal pool.
 	 */
-	public SlotProvider getSlotProvider() {
-		return providerAndOwner;
-	}
-
-	// ------------------------------------------------------------------------
-	//  Resource Manager Connection
-	// ------------------------------------------------------------------------
-
-	@Override
-	public void connectToResourceManager(ResourceManagerGateway resourceManagerGateway) {
-		this.resourceManagerGateway = checkNotNull(resourceManagerGateway);
-
-		// work on all slots waiting for this connection
-		for (PendingRequest pendingRequest : waitingForResourceManager.values()) {
-			requestSlotFromResourceManager(resourceManagerGateway, pendingRequest);
-		}
-
-		// all sent off
-		waitingForResourceManager.clear();
-	}
-
-	@Override
-	public void disconnectResourceManager() {
-		this.resourceManagerGateway = null;
-	}
+	void disconnectResourceManager();
 
 	// ------------------------------------------------------------------------
-	//  Slot Allocation
+	//  registering / un-registering TaskManagers and slots
 	// ------------------------------------------------------------------------
 
-	@Override
-	public CompletableFuture<LogicalSlot> allocateSlot(
-			SlotRequestId slotRequestId,
-			ScheduledUnit task,
-			SlotProfile slotProfile,
-			boolean allowQueuedScheduling,
-			Time allocationTimeout) {
-
-		log.debug("Received slot request [{}] for task: {}", slotRequestId, task.getTaskToExecute());
-
-		if (task.getSlotSharingGroupId() == null) {
-			return allocateSingleSlot(slotRequestId, slotProfile, allowQueuedScheduling, allocationTimeout);
-		} else {
-			return allocateSharedSlot(slotRequestId, task, slotProfile, allowQueuedScheduling, allocationTimeout);
-		}
-	}
-
-	private CompletableFuture<LogicalSlot> allocateSingleSlot(
-		SlotRequestId slotRequestId,
-		SlotProfile slotProfile,
-		boolean allowQueuedScheduling,
-		Time allocationTimeout) {
-		// request an allocated slot to assign a single logical slot to
-		CompletableFuture<SlotAndLocality> slotAndLocalityFuture = requestAllocatedSlot(
-			slotRequestId,
-			slotProfile,
-			allowQueuedScheduling,
-			allocationTimeout);
-
-		return slotAndLocalityFuture.thenApply(
-			(SlotAndLocality slotAndLocality) -> {
-				final AllocatedSlot allocatedSlot = slotAndLocality.getSlot();
-
-				final SingleLogicalSlot singleTaskSlot = new SingleLogicalSlot(
-					slotRequestId,
-					allocatedSlot,
-					null,
-					slotAndLocality.getLocality(),
-					providerAndOwner);
-
-				if (allocatedSlot.tryAssignPayload(singleTaskSlot)) {
-					return singleTaskSlot;
-				} else {
-					final FlinkException flinkException =
-						new FlinkException("Could not assign payload to allocated slot " + allocatedSlot.getAllocationId() + '.');
-					releaseSingleSlot(slotRequestId, flinkException);
-					throw new CompletionException(flinkException);
-				}
-			});
-	}
-
-	private CompletableFuture<LogicalSlot> allocateSharedSlot(
-		SlotRequestId slotRequestId,
-		ScheduledUnit task,
-		SlotProfile slotProfile,
-		boolean allowQueuedScheduling,
-		Time allocationTimeout) {
-
-		// allocate slot with slot sharing
-		final SlotSharingManager multiTaskSlotManager = slotSharingManagers.computeIfAbsent(
-			task.getSlotSharingGroupId(),
-			id -> new SlotSharingManager(
-				id,
-				this,
-				providerAndOwner));
-
-		final SlotSharingManager.MultiTaskSlotLocality multiTaskSlotLocality;
-
-		try {
-			if (task.getCoLocationConstraint() != null) {
-				multiTaskSlotLocality = allocateCoLocatedMultiTaskSlot(
-					task.getCoLocationConstraint(),
-					multiTaskSlotManager,
-					slotProfile,
-					allowQueuedScheduling,
-					allocationTimeout);
-			} else {
-				multiTaskSlotLocality = allocateMultiTaskSlot(
-					task.getJobVertexId(),
-					multiTaskSlotManager,
-					slotProfile,
-					allowQueuedScheduling,
-					allocationTimeout);
-			}
-		} catch (NoResourceAvailableException noResourceException) {
-			return FutureUtils.completedExceptionally(noResourceException);
-		}
-
-		// sanity check
-		Preconditions.checkState(!multiTaskSlotLocality.getMultiTaskSlot().contains(task.getJobVertexId()));
-
-		final SlotSharingManager.SingleTaskSlot leaf = multiTaskSlotLocality.getMultiTaskSlot().allocateSingleTaskSlot(
-			slotRequestId,
-			task.getJobVertexId(),
-			multiTaskSlotLocality.getLocality());
-
-		return leaf.getLogicalSlotFuture();
-	}
-
 	/**
-	 * Allocates a co-located {@link SlotSharingManager.MultiTaskSlot} for the given {@link CoLocationConstraint}.
-	 *
-	 * <p>If allowQueuedScheduling is true, then the returned {@link SlotSharingManager.MultiTaskSlot} can be
-	 * uncompleted.
+	 * Registers a TaskExecutor with the given {@link ResourceID} at {@link SlotPool}.
 	 *
-	 * @param coLocationConstraint for which to allocate a {@link SlotSharingManager.MultiTaskSlot}
-	 * @param multiTaskSlotManager responsible for the slot sharing group for which to allocate the slot
-	 * @param slotProfile specifying the requirements for the requested slot
-	 * @param allowQueuedScheduling true if queued scheduling (the returned task slot must not be completed yet) is allowed, otherwise false
-	 * @param allocationTimeout timeout before the slot allocation times out
-	 * @return A {@link SlotSharingManager.MultiTaskSlotLocality} which contains the allocated{@link SlotSharingManager.MultiTaskSlot}
-	 * 		and its locality wrt the given location preferences
-	 * @throws NoResourceAvailableException if no task slot could be allocated
+	 * @param resourceID identifying the TaskExecutor to register
+	 * @return true iff a new resource id was registered
 	 */
-	private SlotSharingManager.MultiTaskSlotLocality allocateCoLocatedMultiTaskSlot(
-			CoLocationConstraint coLocationConstraint,
-			SlotSharingManager multiTaskSlotManager,
-			SlotProfile slotProfile,
-			boolean allowQueuedScheduling,
-			Time allocationTimeout) throws NoResourceAvailableException {
-		final SlotRequestId coLocationSlotRequestId = coLocationConstraint.getSlotRequestId();
-
-		if (coLocationSlotRequestId != null) {
-			// we have a slot assigned --> try to retrieve it
-			final SlotSharingManager.TaskSlot taskSlot = multiTaskSlotManager.getTaskSlot(coLocationSlotRequestId);
-
-			if (taskSlot != null) {
-				Preconditions.checkState(taskSlot instanceof SlotSharingManager.MultiTaskSlot);
-				return SlotSharingManager.MultiTaskSlotLocality.of(((SlotSharingManager.MultiTaskSlot) taskSlot), Locality.LOCAL);
-			} else {
-				// the slot may have been cancelled in the mean time
-				coLocationConstraint.setSlotRequestId(null);
-			}
-		}
-
-		if (coLocationConstraint.isAssigned()) {
-			// refine the preferred locations of the slot profile
-			slotProfile = new SlotProfile(
-				slotProfile.getResourceProfile(),
-				Collections.singleton(coLocationConstraint.getLocation()),
-				slotProfile.getPreferredAllocations());
-		}
-
-		// get a new multi task slot
-		final SlotSharingManager.MultiTaskSlotLocality multiTaskSlotLocality = allocateMultiTaskSlot(
-			coLocationConstraint.getGroupId(),
-			multiTaskSlotManager,
-			slotProfile,
-			allowQueuedScheduling,
-			allocationTimeout);
-
-		// check whether we fulfill the co-location constraint
-		if (coLocationConstraint.isAssigned() && multiTaskSlotLocality.getLocality() != Locality.LOCAL) {
-			multiTaskSlotLocality.getMultiTaskSlot().release(
-				new FlinkException("Multi task slot is not local and, thus, does not fulfill the co-location constraint."));
-
-			throw new NoResourceAvailableException("Could not allocate a local multi task slot for the " +
-				"co location constraint " + coLocationConstraint + '.');
-		}
-
-		final SlotRequestId slotRequestId = new SlotRequestId();
-		final SlotSharingManager.MultiTaskSlot coLocationSlot = multiTaskSlotLocality.getMultiTaskSlot().allocateMultiTaskSlot(
-			slotRequestId,
-			coLocationConstraint.getGroupId());
-
-		// mark the requested slot as co-located slot for other co-located tasks
-		coLocationConstraint.setSlotRequestId(slotRequestId);
-
-		// lock the co-location constraint once we have obtained the allocated slot
-		coLocationSlot.getSlotContextFuture().whenComplete(
-			(SlotContext slotContext, Throwable throwable) -> {
-				if (throwable == null) {
-					// check whether we are still assigned to the co-location constraint
-					if (Objects.equals(coLocationConstraint.getSlotRequestId(), slotRequestId)) {
-						coLocationConstraint.lockLocation(slotContext.getTaskManagerLocation());
-					} else {
-						log.debug("Failed to lock colocation constraint {} because assigned slot " +
-							"request {} differs from fulfilled slot request {}.",
-							coLocationConstraint.getGroupId(),
-							coLocationConstraint.getSlotRequestId(),
-							slotRequestId);
-					}
-				} else {
-					log.debug("Failed to lock colocation constraint {} because the slot " +
-						"allocation for slot request {} failed.",
-						coLocationConstraint.getGroupId(),
-						coLocationConstraint.getSlotRequestId(),
-						throwable);
-				}
-			});
-
-		return SlotSharingManager.MultiTaskSlotLocality.of(coLocationSlot, multiTaskSlotLocality.getLocality());
-	}
+	boolean registerTaskManager(ResourceID resourceID);
 
 	/**
-	 * Allocates a {@link SlotSharingManager.MultiTaskSlot} for the given groupId which is in the
-	 * slot sharing group for which the given {@link SlotSharingManager} is responsible.
-	 *
-	 * <p>If allowQueuedScheduling is true, then the method can return an uncompleted {@link SlotSharingManager.MultiTaskSlot}.
+	 * Releases a TaskExecutor with the given {@link ResourceID} from the {@link SlotPool}.
 	 *
-	 * @param groupId for which to allocate a new {@link SlotSharingManager.MultiTaskSlot}
-	 * @param slotSharingManager responsible for the slot sharing group for which to allocate the slot
-	 * @param slotProfile slot profile that specifies the requirements for the slot
-	 * @param allowQueuedScheduling true if queued scheduling (the returned task slot must not be completed yet) is allowed, otherwise false
-	 * @param allocationTimeout timeout before the slot allocation times out
-	 * @return A {@link SlotSharingManager.MultiTaskSlotLocality} which contains the allocated {@link SlotSharingManager.MultiTaskSlot}
-	 * 		and its locality wrt the given location preferences
-	 * @throws NoResourceAvailableException if no task slot could be allocated
+	 * @param resourceId identifying the TaskExecutor which shall be released from the SlotPool
+	 * @param cause for the releasing of the TaskManager
+	 * @return true iff a given registered resource id was removed
 	 */
-	private SlotSharingManager.MultiTaskSlotLocality allocateMultiTaskSlot(
-			AbstractID groupId,
-			SlotSharingManager slotSharingManager,
-			SlotProfile slotProfile,
-			boolean allowQueuedScheduling,
-			Time allocationTimeout) throws NoResourceAvailableException {
-
-		// check first whether we have a resolved root slot which we can use
-		SlotSharingManager.MultiTaskSlotLocality multiTaskSlotLocality = slotSharingManager.getResolvedRootSlot(
-			groupId,
-			schedulingStrategy,
-			slotProfile);
-
-		if (multiTaskSlotLocality != null && multiTaskSlotLocality.getLocality() == Locality.LOCAL) {
-			return multiTaskSlotLocality;
-		}
-
-		final SlotRequestId allocatedSlotRequestId = new SlotRequestId();
-		final SlotRequestId multiTaskSlotRequestId = new SlotRequestId();
-
-		// check whether we have an allocated slot available which we can use to create a new multi task slot in
-		final SlotAndLocality polledSlotAndLocality = pollAndAllocateSlot(allocatedSlotRequestId, slotProfile);
-
-		if (polledSlotAndLocality != null && (polledSlotAndLocality.getLocality() == Locality.LOCAL || multiTaskSlotLocality == null)) {
-
-			final AllocatedSlot allocatedSlot = polledSlotAndLocality.getSlot();
-			final SlotSharingManager.MultiTaskSlot multiTaskSlot = slotSharingManager.createRootSlot(
-				multiTaskSlotRequestId,
-				CompletableFuture.completedFuture(polledSlotAndLocality.getSlot()),
-				allocatedSlotRequestId);
-
-			if (allocatedSlot.tryAssignPayload(multiTaskSlot)) {
-				return SlotSharingManager.MultiTaskSlotLocality.of(multiTaskSlot, polledSlotAndLocality.getLocality());
-			} else {
-				multiTaskSlot.release(new FlinkException("Could not assign payload to allocated slot " +
-					allocatedSlot.getAllocationId() + '.'));
-			}
-		}
-
-		if (multiTaskSlotLocality != null) {
-			// prefer slot sharing group slots over unused slots
-			if (polledSlotAndLocality != null) {
-				releaseSingleSlot(
-					allocatedSlotRequestId,
-					new FlinkException("Locality constraint is not better fulfilled by allocated slot."));
-			}
-			return multiTaskSlotLocality;
-		}
-
-		if (allowQueuedScheduling) {
-			// there is no slot immediately available --> check first for uncompleted slots at the slot sharing group
-			SlotSharingManager.MultiTaskSlot multiTaskSlotFuture = slotSharingManager.getUnresolvedRootSlot(groupId);
-
-			if (multiTaskSlotFuture == null) {
-				// it seems as if we have to request a new slot from the resource manager, this is always the last resort!!!
-				final CompletableFuture<AllocatedSlot> futureSlot = requestNewAllocatedSlot(
-					allocatedSlotRequestId,
-					slotProfile.getResourceProfile(),
-					allocationTimeout);
-
-				multiTaskSlotFuture = slotSharingManager.createRootSlot(
-					multiTaskSlotRequestId,
-					futureSlot,
-					allocatedSlotRequestId);
-
-				futureSlot.whenComplete(
-					(AllocatedSlot allocatedSlot, Throwable throwable) -> {
-						final SlotSharingManager.TaskSlot taskSlot = slotSharingManager.getTaskSlot(multiTaskSlotRequestId);
-
-						if (taskSlot != null) {
-							// still valid
-							if (!(taskSlot instanceof SlotSharingManager.MultiTaskSlot) || throwable != null) {
-								taskSlot.release(throwable);
-							} else {
-								if (!allocatedSlot.tryAssignPayload(((SlotSharingManager.MultiTaskSlot) taskSlot))) {
-									taskSlot.release(new FlinkException("Could not assign payload to allocated slot " +
-										allocatedSlot.getAllocationId() + '.'));
-								}
-							}
-						} else {
-							releaseSingleSlot(
-								allocatedSlotRequestId,
-								new FlinkException("Could not find task slot with " + multiTaskSlotRequestId + '.'));
-						}
-					});
-			}
-
-			return SlotSharingManager.MultiTaskSlotLocality.of(multiTaskSlotFuture, Locality.UNKNOWN);
-
-		} else {
-			throw new NoResourceAvailableException("Could not allocate a shared slot for " + groupId + '.');
-		}
-	}
+	boolean releaseTaskManager(final ResourceID resourceId, final Exception cause);
 
 	/**
-	 * Allocates an allocated slot first by polling from the available slots and then requesting a new
-	 * slot from the ResourceManager if no fitting slot could be found.
+	 * Offers multiple slots to the {@link SlotPool}. The slot offerings can be
+	 * individually accepted or rejected by returning the collection of accepted
+	 * slot offers.
 	 *
-	 * @param slotProfile slot profile that specifies the requirements for the slot
-	 * @param allowQueuedScheduling true if the slot allocation can be completed in the future
-	 * @param allocationTimeout timeout before the slot allocation times out
-	 * @return Future containing the allocated simple slot
+	 * @param taskManagerLocation from which the slot offers originate
+	 * @param taskManagerGateway to talk to the slot offerer
+	 * @param offers slot offers which are offered to the {@link SlotPool}
+	 * @return A collection of accepted slot offers. The remaining slot offers are
+	 * 			implicitly rejected.
 	 */
-	private CompletableFuture<SlotAndLocality> requestAllocatedSlot(
-			SlotRequestId slotRequestId,
-			SlotProfile slotProfile,
-			boolean allowQueuedScheduling,
-			Time allocationTimeout) {
-
-		final CompletableFuture<SlotAndLocality> allocatedSlotLocalityFuture;
-
-		// (1) do we have a slot available already?
-		SlotAndLocality slotFromPool = pollAndAllocateSlot(slotRequestId, slotProfile);
-
-		if (slotFromPool != null) {
-			allocatedSlotLocalityFuture = CompletableFuture.completedFuture(slotFromPool);
-		} else if (allowQueuedScheduling) {
-			// we have to request a new allocated slot
-			CompletableFuture<AllocatedSlot> allocatedSlotFuture = requestNewAllocatedSlot(
-				slotRequestId,
-				slotProfile.getResourceProfile(),
-				allocationTimeout);
-
-			allocatedSlotLocalityFuture = allocatedSlotFuture.thenApply((AllocatedSlot allocatedSlot) -> new SlotAndLocality(allocatedSlot, Locality.UNKNOWN));
-		} else {
-			allocatedSlotLocalityFuture = FutureUtils.completedExceptionally(new NoResourceAvailableException("Could not allocate a simple slot for " +
-				slotRequestId + '.'));
-		}
-
-		return allocatedSlotLocalityFuture;
-	}
+	Collection<SlotOffer> offerSlots(
+		TaskManagerLocation taskManagerLocation,
+		TaskManagerGateway taskManagerGateway,
+		Collection<SlotOffer> offers);
 
 	/**
-	 * Requests a new slot with the given {@link ResourceProfile} from the ResourceManager. If there is
-	 * currently not ResourceManager connected, then the request is stashed and send once a new
-	 * ResourceManager is connected.
+	 * Fails the slot with the given allocation id.
 	 *
-	 * @param slotRequestId identifying the requested slot
-	 * @param resourceProfile which the requested slot should fulfill
-	 * @param allocationTimeout timeout before the slot allocation times out
-	 * @return An {@link AllocatedSlot} future which is completed once the slot is offered to the {@link SlotPool}
+	 * @param allocationID identifying the slot which is being failed
+	 * @param cause of the failure
+	 * @return An optional task executor id if this task executor has no more slots registered
 	 */
-	private CompletableFuture<AllocatedSlot> requestNewAllocatedSlot(
-			SlotRequestId slotRequestId,
-			ResourceProfile resourceProfile,
-			Time allocationTimeout) {
-
-		final PendingRequest pendingRequest = new PendingRequest(
-			slotRequestId,
-			resourceProfile);
-
-		// register request timeout
-		FutureUtils
-			.orTimeout(pendingRequest.getAllocatedSlotFuture(), allocationTimeout.toMilliseconds(), TimeUnit.MILLISECONDS)
-			.whenCompleteAsync(
-				(AllocatedSlot ignored, Throwable throwable) -> {
-					if (throwable instanceof TimeoutException) {
-						timeoutPendingSlotRequest(slotRequestId);
-					}
-				},
-				getMainThreadExecutor());
-
-		if (resourceManagerGateway == null) {
-			stashRequestWaitingForResourceManager(pendingRequest);
-		} else {
-			requestSlotFromResourceManager(resourceManagerGateway, pendingRequest);
-		}
-
-		return pendingRequest.getAllocatedSlotFuture();
-	}
-
-	private void requestSlotFromResourceManager(
-			final ResourceManagerGateway resourceManagerGateway,
-			final PendingRequest pendingRequest) {
-
-		checkNotNull(resourceManagerGateway);
-		checkNotNull(pendingRequest);
-
-		log.info("Requesting new slot [{}] and profile {} from resource manager.", pendingRequest.getSlotRequestId(), pendingRequest.getResourceProfile());
-
-		final AllocationID allocationId = new AllocationID();
-
-		pendingRequests.put(pendingRequest.getSlotRequestId(), allocationId, pendingRequest);
-
-		pendingRequest.getAllocatedSlotFuture().whenComplete(
-			(AllocatedSlot allocatedSlot, Throwable throwable) -> {
-				if (throwable != null || !allocationId.equals(allocatedSlot.getAllocationId())) {
-					// cancel the slot request if there is a failure or if the pending request has
-					// been completed with another allocated slot
-					resourceManagerGateway.cancelSlotRequest(allocationId);
-				}
-			});
-
-		CompletableFuture<Acknowledge> rmResponse = resourceManagerGateway.requestSlot(
-			jobMasterId,
-			new SlotRequest(jobId, allocationId, pendingRequest.getResourceProfile(), jobManagerAddress),
-			rpcTimeout);
-
-		// on failure, fail the request future
-		rmResponse.whenCompleteAsync(
-			(Acknowledge ignored, Throwable failure) -> {
-				if (failure != null) {
-					slotRequestToResourceManagerFailed(pendingRequest.getSlotRequestId(), failure);
-				}
-			},
-			getMainThreadExecutor());
-	}
-
-	private void slotRequestToResourceManagerFailed(SlotRequestId slotRequestID, Throwable failure) {
-		PendingRequest request = pendingRequests.removeKeyA(slotRequestID);
-		if (request != null) {
-			request.getAllocatedSlotFuture().completeExceptionally(new NoResourceAvailableException(
-					"No pooled slot available and request to ResourceManager for new slot failed", failure));
-		} else {
-			if (log.isDebugEnabled()) {
-				log.debug("Unregistered slot request [{}] failed.", slotRequestID, failure);
-			}
-		}
-	}
-
-	private void stashRequestWaitingForResourceManager(final PendingRequest pendingRequest) {
-
-		log.info("Cannot serve slot request, no ResourceManager connected. " +
-				"Adding as pending request [{}]",  pendingRequest.getSlotRequestId());
-
-		waitingForResourceManager.put(pendingRequest.getSlotRequestId(), pendingRequest);
-	}
+	Optional<ResourceID> failAllocation(AllocationID allocationID, Exception cause);
 
 	// ------------------------------------------------------------------------
-	//  Slot releasing & offering
+	//  allocating and disposing slots
 	// ------------------------------------------------------------------------
 
-	@Override
-	public CompletableFuture<Acknowledge> releaseSlot(
-		SlotRequestId slotRequestId,
-		@Nullable SlotSharingGroupId slotSharingGroupId,
-		Throwable cause) {
-
-		log.debug("Releasing slot [{}] because: {}", slotRequestId, cause != null ? cause.getMessage() : "null");
-
-		if (slotSharingGroupId != null) {
-			releaseSharedSlot(slotRequestId, slotSharingGroupId, cause);
-		} else {
-			releaseSingleSlot(slotRequestId, cause);
-		}
-
-		return CompletableFuture.completedFuture(Acknowledge.get());
-	}
-
-	private void releaseSharedSlot(
-		SlotRequestId slotRequestId,
-		@Nonnull SlotSharingGroupId slotSharingGroupId, Throwable cause) {
-
-		final SlotSharingManager multiTaskSlotManager = slotSharingManagers.get(slotSharingGroupId);
-
-		if (multiTaskSlotManager != null) {
-			final SlotSharingManager.TaskSlot taskSlot = multiTaskSlotManager.getTaskSlot(slotRequestId);
-
-			if (taskSlot != null) {
-				taskSlot.release(cause);
-			} else {
-				log.debug("Could not find slot [{}] in slot sharing group {}. Ignoring release slot request.", slotRequestId, slotSharingGroupId);
-			}
-		} else {
-			log.debug("Could not find slot sharing group {}. Ignoring release slot request.", slotSharingGroupId);
-		}
-	}
-
-	private void releaseSingleSlot(SlotRequestId slotRequestId, Throwable cause) {
-		final PendingRequest pendingRequest = removePendingRequest(slotRequestId);
-
-		if (pendingRequest != null) {
-			failPendingRequest(pendingRequest, new FlinkException("Pending slot request with " + slotRequestId + " has been released."));
-		} else {
-			final AllocatedSlot allocatedSlot = allocatedSlots.remove(slotRequestId);
-
-			if (allocatedSlot != null) {
-				allocatedSlot.releasePayload(cause);
-				tryFulfillSlotRequestOrMakeAvailable(allocatedSlot);
-			} else {
-				log.debug("There is no allocated slot [{}]. Ignoring the release slot request.", slotRequestId);
-			}
-		}
-	}
-
 	/**
-	 * Checks whether there exists a pending request with the given slot request id and removes it
-	 * from the internal data structures.
+	 * Returns a list of {@link SlotInfo} objects about all slots that are currently available in the slot
+	 * pool.
 	 *
-	 * @param requestId identifying the pending request
-	 * @return pending request if there is one, otherwise null
+	 * @return a list of {@link SlotInfo} objects about all slots that are currently available in the slot pool.
 	 */
-	@Nullable
-	private PendingRequest removePendingRequest(SlotRequestId requestId) {
-		PendingRequest result = waitingForResourceManager.remove(requestId);
-
-		if (result != null) {
-			// sanity check
-			assert !pendingRequests.containsKeyA(requestId) : "A pending requests should only be part of either " +
-				"the pendingRequests or waitingForResourceManager but not both.";
-
-			return result;
-		} else {
-			return pendingRequests.removeKeyA(requestId);
-		}
-	}
-
-	private void failPendingRequest(PendingRequest pendingRequest, Exception e) {
-		checkNotNull(pendingRequest);
-		checkNotNull(e);
-
-		if (!pendingRequest.getAllocatedSlotFuture().isDone()) {
-			log.info("Failing pending slot request [{}]: {}", pendingRequest.getSlotRequestId(), e.getMessage());
-			pendingRequest.getAllocatedSlotFuture().completeExceptionally(e);
-		}
-	}
-
-	@Nullable
-	private SlotAndLocality pollAndAllocateSlot(SlotRequestId slotRequestId, SlotProfile slotProfile) {
-		SlotAndLocality slotFromPool = availableSlots.poll(schedulingStrategy, slotProfile);
-
-		if (slotFromPool != null) {
-			allocatedSlots.add(slotRequestId, slotFromPool.getSlot());
-		}
-
-		return slotFromPool;
-	}
-
-	/**
-	 * Tries to fulfill with the given allocated slot a pending slot request or add the
-	 * allocated slot to the set of available slots if no matching request is available.
-	 *
-	 * @param allocatedSlot which shall be returned
-	 */
-	private void tryFulfillSlotRequestOrMakeAvailable(AllocatedSlot allocatedSlot) {
-		Preconditions.checkState(!allocatedSlot.isUsed(), "Provided slot is still in use.");
-
-		final PendingRequest pendingRequest = pollMatchingPendingRequest(allocatedSlot);
-
-		if (pendingRequest != null) {
-			log.debug("Fulfilling pending slot request [{}] early with returned slot [{}]",
-				pendingRequest.getSlotRequestId(), allocatedSlot.getAllocationId());
-
-			allocatedSlots.add(pendingRequest.getSlotRequestId(), allocatedSlot);
-			pendingRequest.getAllocatedSlotFuture().complete(allocatedSlot);
-		} else {
-			log.debug("Adding returned slot [{}] to available slots", allocatedSlot.getAllocationId());
-			availableSlots.add(allocatedSlot, clock.relativeTimeMillis());
-		}
-	}
-
-	private PendingRequest pollMatchingPendingRequest(final AllocatedSlot slot) {
-		final ResourceProfile slotResources = slot.getResourceProfile();
-
-		// try the requests sent to the resource manager first
-		for (PendingRequest request : pendingRequests.values()) {
-			if (slotResources.isMatching(request.getResourceProfile())) {
-				pendingRequests.removeKeyA(request.getSlotRequestId());
-				return request;
-			}
-		}
-
-		// try the requests waiting for a resource manager connection next
-		for (PendingRequest request : waitingForResourceManager.values()) {
-			if (slotResources.isMatching(request.getResourceProfile())) {
-				waitingForResourceManager.remove(request.getSlotRequestId());
-				return request;
-			}
-		}
-
-		// no request pending, or no request matches
-		return null;
-	}
-
-	@Override
-	public CompletableFuture<Collection<SlotOffer>> offerSlots(
-			TaskManagerLocation taskManagerLocation,
-			TaskManagerGateway taskManagerGateway,
-			Collection<SlotOffer> offers) {
-		validateRunsInMainThread();
-
-		List<CompletableFuture<Optional<SlotOffer>>> acceptedSlotOffers = offers.stream().map(
-			offer -> offerSlot(
-					taskManagerLocation,
-					taskManagerGateway,
-					offer)
-				.<Optional<SlotOffer>>thenApply(
-					(acceptedSlot) -> acceptedSlot ? Optional.of(offer) : Optional.empty()
-				)
-		).collect(Collectors.toList());
-
-		CompletableFuture<Collection<Optional<SlotOffer>>> optionalSlotOffers = FutureUtils.combineAll(acceptedSlotOffers);
-
-		return optionalSlotOffers.thenApply(collection -> collection.stream()
-				.flatMap(opt -> opt.map(Stream::of).orElseGet(Stream::empty))
-				.collect(Collectors.toList()));
-	}
+	@Nonnull
+	Collection<SlotInfo> getAvailableSlotsInformation();
 
 	/**
-	 * Slot offering by TaskExecutor with AllocationID. The AllocationID is originally generated by this pool and
-	 * transfer through the ResourceManager to TaskManager. We use it to distinguish the different allocation
-	 * we issued. Slot offering may be rejected if we find something mismatching or there is actually no pending
-	 * request waiting for this slot (maybe fulfilled by some other returned slot).
+	 * Allocates the available slot with the given allocation id under the given request id. This method returns
+	 * {@code null} if no slot with the given allocation id is available.
 	 *
-	 * @param taskManagerLocation location from where the offer comes from
-	 * @param taskManagerGateway TaskManager gateway
-	 * @param slotOffer the offered slot
-	 * @return True if we accept the offering
-	 */
-	@Override
-	public CompletableFuture<Boolean> offerSlot(
-			final TaskManagerLocation taskManagerLocation,
-			final TaskManagerGateway taskManagerGateway,
-			final SlotOffer slotOffer) {
-
-		validateRunsInMainThread();
-
-		// check if this TaskManager is valid
-		final ResourceID resourceID = taskManagerLocation.getResourceID();
-		final AllocationID allocationID = slotOffer.getAllocationId();
-
-		if (!registeredTaskManagers.contains(resourceID)) {
-			log.debug("Received outdated slot offering [{}] from unregistered TaskManager: {}",
-					slotOffer.getAllocationId(), taskManagerLocation);
-			return CompletableFuture.completedFuture(false);
-		}
-
-		// check whether we have already using this slot
-		AllocatedSlot existingSlot;
-		if ((existingSlot = allocatedSlots.get(allocationID)) != null ||
-			(existingSlot = availableSlots.get(allocationID)) != null) {
-
-			// we need to figure out if this is a repeated offer for the exact same slot,
-			// or another offer that comes from a different TaskManager after the ResourceManager
-			// re-tried the request
-
-			// we write this in terms of comparing slot IDs, because the Slot IDs are the identifiers of
-			// the actual slots on the TaskManagers
-			// Note: The slotOffer should have the SlotID
-			final SlotID existingSlotId = existingSlot.getSlotId();
-			final SlotID newSlotId = new SlotID(taskManagerLocation.getResourceID(), slotOffer.getSlotIndex());
-
-			if (existingSlotId.equals(newSlotId)) {
-				log.info("Received repeated offer for slot [{}]. Ignoring.", allocationID);
-
-				// return true here so that the sender will get a positive acknowledgement to the retry
-				// and mark the offering as a success
-				return CompletableFuture.completedFuture(true);
-			} else {
-				// the allocation has been fulfilled by another slot, reject the offer so the task executor
-				// will offer the slot to the resource manager
-				return CompletableFuture.completedFuture(false);
-			}
-		}
-
-		final AllocatedSlot allocatedSlot = new AllocatedSlot(
-			allocationID,
-			taskManagerLocation,
-			slotOffer.getSlotIndex(),
-			slotOffer.getResourceProfile(),
-			taskManagerGateway);
-
-		// check whether we have request waiting for this slot
-		PendingRequest pendingRequest = pendingRequests.removeKeyB(allocationID);
-		if (pendingRequest != null) {
-			// we were waiting for this!
-			allocatedSlots.add(pendingRequest.getSlotRequestId(), allocatedSlot);
-
-			if (!pendingRequest.getAllocatedSlotFuture().complete(allocatedSlot)) {
-				// we could not complete the pending slot future --> try to fulfill another pending request
-				allocatedSlots.remove(pendingRequest.getSlotRequestId());
-				tryFulfillSlotRequestOrMakeAvailable(allocatedSlot);
-			} else {
-				log.debug("Fulfilled slot request [{}] with allocated slot [{}].", pendingRequest.getSlotRequestId(), allocationID);
-			}
-		}
-		else {
-			// we were actually not waiting for this:
-			//   - could be that this request had been fulfilled
-			//   - we are receiving the slots from TaskManagers after becoming leaders
-			tryFulfillSlotRequestOrMakeAvailable(allocatedSlot);
-		}
-
-		// we accepted the request in any case. slot will be released after it idled for
-		// too long and timed out
-		return CompletableFuture.completedFuture(true);
-	}
-
-
-	// TODO - periodic (every minute or so) catch slots that were lost (check all slots, if they have any task active)
-
-	// TODO - release slots that were not used to the resource manager
-
-	// ------------------------------------------------------------------------
-	//  Error Handling
-	// ------------------------------------------------------------------------
-
-	/**
-	 * Fail the specified allocation and release the corresponding slot if we have one.
-	 * This may triggered by JobManager when some slot allocation failed with rpcTimeout.
-	 * Or this could be triggered by TaskManager, when it finds out something went wrong with the slot,
-	 * and decided to take it back.
-	 *
-	 * @param allocationID Represents the allocation which should be failed
-	 * @param cause The cause of the failure
-	 * @return Optional task executor if it has no more slots registered
+	 * @param slotRequestId identifying the requested slot
+	 * @param allocationID the allocation id of the requested available slot
+	 * @return the previously available slot with the given allocation id or {@code null} if no such slot existed.
 	 */
-	@Override
-	public CompletableFuture<SerializableOptional<ResourceID>> failAllocation(final AllocationID allocationID, final Exception cause) {
-		final PendingRequest pendingRequest = pendingRequests.removeKeyB(allocationID);
-		if (pendingRequest != null) {
-			// request was still pending
-			failPendingRequest(pendingRequest, cause);
-			return CompletableFuture.completedFuture(SerializableOptional.empty());
-		}
-		else {
-			return tryFailingAllocatedSlot(allocationID, cause);
-		}
-
-		// TODO: add some unit tests when the previous two are ready, the allocation may failed at any phase
-	}
-
-	private CompletableFuture<SerializableOptional<ResourceID>> tryFailingAllocatedSlot(AllocationID allocationID, Exception cause) {
-		AllocatedSlot allocatedSlot = availableSlots.tryRemove(allocationID);
-
-		if (allocatedSlot == null) {
-			allocatedSlot = allocatedSlots.remove(allocationID);
-		}
-
-		if (allocatedSlot != null) {
-			log.debug("Failed allocated slot [{}]: {}", allocationID, cause.getMessage());
-
-			// notify TaskExecutor about the failure
-			allocatedSlot.getTaskManagerGateway().freeSlot(allocationID, cause, rpcTimeout);
-			// release the slot.
-			// since it is not in 'allocatedSlots' any more, it will be dropped o return'
-			allocatedSlot.releasePayload(cause);
-
-			final ResourceID taskManagerId = allocatedSlot.getTaskManagerId();
-
-			if (!availableSlots.containsTaskManager(taskManagerId) && !allocatedSlots.containResource(taskManagerId)) {
-				return CompletableFuture.completedFuture(SerializableOptional.of(taskManagerId));
-			}
-		}
-
-		return CompletableFuture.completedFuture(SerializableOptional.empty());
-	}
-
-	// ------------------------------------------------------------------------
-	//  Resource
-	// ------------------------------------------------------------------------
+	Optional<PhysicalSlot> allocateAvailableSlot(
+		@Nonnull SlotRequestId slotRequestId,
+		@Nonnull AllocationID allocationID);
 
 	/**
-	 * Register TaskManager to this pool, only those slots come from registered TaskManager will be considered valid.
-	 * Also it provides a way for us to keep "dead" or "abnormal" TaskManagers out of this pool.
+	 * Request the allocation of a new slot from the resource manager. This method will not return a slot from the
+	 * already available slots from the pool, but instead will add a new slot to that pool that is immediately allocated
+	 * and returned.
 	 *
-	 * @param resourceID The id of the TaskManager
-	 * @return Future acknowledge if th operation was successful
-	 */
-	@Override
-	public CompletableFuture<Acknowledge> registerTaskManager(final ResourceID resourceID) {
-		log.debug("Register new TaskExecutor {}.", resourceID);
-		registeredTaskManagers.add(resourceID);
-
-		return CompletableFuture.completedFuture(Acknowledge.get());
-	}
-
-	/**
-	 * Unregister TaskManager from this pool, all the related slots will be released and tasks be canceled. Called
-	 * when we find some TaskManager becomes "dead" or "abnormal", and we decide to not using slots from it anymore.
-	 *
-	 * @param resourceId The id of the TaskManager
-	 * @param cause for the releasing of the TaskManager
-	 */
-	@Override
-	public CompletableFuture<Acknowledge> releaseTaskManager(final ResourceID resourceId, final Exception cause) {
-		if (registeredTaskManagers.remove(resourceId)) {
-			releaseTaskManagerInternal(resourceId, cause);
-		}
-
-		return CompletableFuture.completedFuture(Acknowledge.get());
-	}
-
-	// ------------------------------------------------------------------------
-	//  Internal methods
-	// ------------------------------------------------------------------------
-
-	@VisibleForTesting
-	protected void timeoutPendingSlotRequest(SlotRequestId slotRequestId) {
-		log.info("Pending slot request [{}] timed out.", slotRequestId);
-		removePendingRequest(slotRequestId);
-	}
-
-	private void releaseTaskManagerInternal(final ResourceID resourceId, final Exception cause) {
-		final Set<AllocatedSlot> removedSlots = new HashSet<>(allocatedSlots.removeSlotsForTaskManager(resourceId));
-
-		for (AllocatedSlot allocatedSlot : removedSlots) {
-			allocatedSlot.releasePayload(cause);
-		}
-
-		removedSlots.addAll(availableSlots.removeAllForTaskManager(resourceId));
-
-		for (AllocatedSlot removedSlot : removedSlots) {
-			TaskManagerGateway taskManagerGateway = removedSlot.getTaskManagerGateway();
-			taskManagerGateway.freeSlot(removedSlot.getAllocationId(), cause, rpcTimeout);
-		}
-	}
-
-	/**
-	 * Check the available slots, release the slot that is idle for a long time.
-	 */
-	private void checkIdleSlot() {
-
-		// The timestamp in SlotAndTimestamp is relative
-		final long currentRelativeTimeMillis = clock.relativeTimeMillis();
-
-		final List<AllocatedSlot> expiredSlots = new ArrayList<>(availableSlots.size());
-
-		for (SlotAndTimestamp slotAndTimestamp : availableSlots.availableSlots.values()) {
-			if (currentRelativeTimeMillis - slotAndTimestamp.timestamp > idleSlotTimeout.toMilliseconds()) {
-				expiredSlots.add(slotAndTimestamp.slot);
-			}
-		}
-
-		final FlinkException cause = new FlinkException("Releasing idle slot.");
-
-		for (AllocatedSlot expiredSlot : expiredSlots) {
-			final AllocationID allocationID = expiredSlot.getAllocationId();
-			if (availableSlots.tryRemove(allocationID) != null) {
-
-				log.info("Releasing idle slot [{}].", allocationID);
-				final CompletableFuture<Acknowledge> freeSlotFuture = expiredSlot.getTaskManagerGateway().freeSlot(
-					allocationID,
-					cause,
-					rpcTimeout);
-
-				freeSlotFuture.whenCompleteAsync(
-					(Acknowledge ignored, Throwable throwable) -> {
-						if (throwable != null) {
-							if (registeredTaskManagers.contains(expiredSlot.getTaskManagerId())) {
-								log.debug("Releasing slot [{}] of registered TaskExecutor {} failed. " +
-									"Trying to fulfill a different slot request.", allocationID, expiredSlot.getTaskManagerId(),
-									throwable);
-								tryFulfillSlotRequestOrMakeAvailable(expiredSlot);
-							} else {
-								log.debug("Releasing slot [{}] failed and owning TaskExecutor {} is no " +
-									"longer registered. Discarding slot.", allocationID, expiredSlot.getTaskManagerId());
-							}
-						}
-					},
-					getMainThreadExecutor());
-			}
-		}
-
-		scheduleRunAsync(this::checkIdleSlot, idleSlotTimeout);
-	}
-
-	/**
-	 * Clear the internal state of the SlotPool.
-	 */
-	private void clear() {
-		availableSlots.clear();
-		allocatedSlots.clear();
-		pendingRequests.clear();
-		waitingForResourceManager.clear();
-		registeredTaskManagers.clear();
-		slotSharingManagers.clear();
-	}
-
-	// ------------------------------------------------------------------------
-	//  Methods for tests
-	// ------------------------------------------------------------------------
-
-	private void scheduledLogStatus() {
-		log.debug(printStatus());
-		scheduleRunAsync(this::scheduledLogStatus, STATUS_LOG_INTERVAL_MS, TimeUnit.MILLISECONDS);
-	}
-
-	private String printStatus() {
-		validateRunsInMainThread();
-
-		final StringBuilder builder = new StringBuilder(1024).append("Slot Pool Status:\n");
-
-		builder.append("\tstatus: ");
-		if (resourceManagerGateway != null) {
-			builder.append("connected to ").append(resourceManagerGateway.getAddress()).append('\n');
-		} else {
-			builder.append("unconnected and waiting for ResourceManager ")
-					.append(waitingForResourceManager)
-					.append('\n');
-		}
-
-		builder.append("\tregistered TaskManagers: ").append(registeredTaskManagers).append('\n');
-
-		builder.append("\tavailable slots: ").append(availableSlots.printAllSlots()).append('\n');
-		builder.append("\tallocated slots: ").append(allocatedSlots.printAllSlots()).append('\n');
-
-		builder.append("\tpending requests: ").append(pendingRequests.values()).append('\n');
-
-		builder.append("\tsharing groups: {\n");
-		for (Entry<SlotSharingGroupId, SlotSharingManager> manager : slotSharingManagers.entrySet()) {
-			builder.append("\t -------- ").append(manager.getKey()).append(" --------\n");
-			builder.append(manager.getValue());
-		}
-		builder.append("\t}\n");
-		return builder.toString();
-	}
-
-	@VisibleForTesting
-	protected AllocatedSlots getAllocatedSlots() {
-		return allocatedSlots;
-	}
-
-	@VisibleForTesting
-	protected AvailableSlots getAvailableSlots() {
-		return availableSlots;
-	}
-
-	@VisibleForTesting
-	DualKeyMap<SlotRequestId, AllocationID, PendingRequest> getPendingRequests() {
-		return pendingRequests;
-	}
-
-	@VisibleForTesting
-	Map<SlotRequestId, PendingRequest> getWaitingForResourceManager() {
-		return waitingForResourceManager;
-	}
-
-	@VisibleForTesting
-	void triggerCheckIdleSlot() {
-		runAsync(this::checkIdleSlot);
-	}
-
-	// ------------------------------------------------------------------------
-	//  Helper classes
-	// ------------------------------------------------------------------------
-
-	/**
-	 * Organize allocated slots from different points of view.
-	 */
-	static class AllocatedSlots {
-
-		/** All allocated slots organized by TaskManager's id. */
-		private final Map<ResourceID, Set<AllocatedSlot>> allocatedSlotsByTaskManager;
-
-		/** All allocated slots organized by AllocationID. */
-		private final DualKeyMap<AllocationID, SlotRequestId, AllocatedSlot> allocatedSlotsById;
-
-		AllocatedSlots() {
-			this.allocatedSlotsByTaskManager = new HashMap<>(16);
-			this.allocatedSlotsById = new DualKeyMap<>(16);
-		}
-
-		/**
-		 * Adds a new slot to this collection.
-		 *
-		 * @param allocatedSlot The allocated slot
-		 */
-		void add(SlotRequestId slotRequestId, AllocatedSlot allocatedSlot) {
-			allocatedSlotsById.put(allocatedSlot.getAllocationId(), slotRequestId, allocatedSlot);
-
-			final ResourceID resourceID = allocatedSlot.getTaskManagerLocation().getResourceID();
-
-			Set<AllocatedSlot> slotsForTaskManager = allocatedSlotsByTaskManager.computeIfAbsent(
-				resourceID,
-				resourceId -> new HashSet<>(4));
-
-			slotsForTaskManager.add(allocatedSlot);
-		}
-
-		/**
-		 * Get allocated slot with allocation id.
-		 *
-		 * @param allocationID The allocation id
-		 * @return The allocated slot, null if we can't find a match
-		 */
-		AllocatedSlot get(final AllocationID allocationID) {
-			return allocatedSlotsById.getKeyA(allocationID);
-		}
-
-		AllocatedSlot get(final SlotRequestId slotRequestId) {
-			return allocatedSlotsById.getKeyB(slotRequestId);
-		}
-
-		/**
-		 * Check whether we have allocated this slot.
-		 *
-		 * @param slotAllocationId The allocation id of the slot to check
-		 * @return True if we contains this slot
-		 */
-		boolean contains(AllocationID slotAllocationId) {
-			return allocatedSlotsById.containsKeyA(slotAllocationId);
-		}
-
-		/**
-		 * Removes the allocated slot specified by the provided slot allocation id.
-		 *
-		 * @param allocationID identifying the allocated slot to remove
-		 * @return The removed allocated slot or null.
-		 */
-		@Nullable
-		AllocatedSlot remove(final AllocationID allocationID) {
-			AllocatedSlot allocatedSlot = allocatedSlotsById.removeKeyA(allocationID);
-
-			if (allocatedSlot != null) {
-				removeAllocatedSlot(allocatedSlot);
-			}
-
-			return allocatedSlot;
-		}
-
-		/**
-		 * Removes the allocated slot specified by the provided slot request id.
-		 *
-		 * @param slotRequestId identifying the allocated slot to remove
-		 * @return The removed allocated slot or null.
-		 */
-		@Nullable
-		AllocatedSlot remove(final SlotRequestId slotRequestId) {
-			final AllocatedSlot allocatedSlot = allocatedSlotsById.removeKeyB(slotRequestId);
-
-			if (allocatedSlot != null) {
-				removeAllocatedSlot(allocatedSlot);
-			}
-
-			return allocatedSlot;
-		}
-
-		private void removeAllocatedSlot(final AllocatedSlot allocatedSlot) {
-			Preconditions.checkNotNull(allocatedSlot);
-			final ResourceID taskManagerId = allocatedSlot.getTaskManagerLocation().getResourceID();
-			Set<AllocatedSlot> slotsForTM = allocatedSlotsByTaskManager.get(taskManagerId);
-
-			slotsForTM.remove(allocatedSlot);
-
-			if (slotsForTM.isEmpty()) {
-				allocatedSlotsByTaskManager.remove(taskManagerId);
-			}
-		}
-
-		/**
-		 * Get all allocated slot from same TaskManager.
-		 *
-		 * @param resourceID The id of the TaskManager
-		 * @return Set of slots which are allocated from the same TaskManager
-		 */
-		Set<AllocatedSlot> removeSlotsForTaskManager(final ResourceID resourceID) {
-			Set<AllocatedSlot> slotsForTaskManager = allocatedSlotsByTaskManager.remove(resourceID);
-			if (slotsForTaskManager != null) {
-				for (AllocatedSlot allocatedSlot : slotsForTaskManager) {
-					allocatedSlotsById.removeKeyA(allocatedSlot.getAllocationId());
-				}
-				return slotsForTaskManager;
-			}
-			else {
-				return Collections.emptySet();
-			}
-		}
-
-		void clear() {
-			allocatedSlotsById.clear();
-			allocatedSlotsByTaskManager.clear();
-		}
-
-		String printAllSlots() {
-			return allocatedSlotsByTaskManager.values().toString();
-		}
-
-		@VisibleForTesting
-		boolean containResource(final ResourceID resourceID) {
-			return allocatedSlotsByTaskManager.containsKey(resourceID);
-		}
-
-		@VisibleForTesting
-		int size() {
-			return allocatedSlotsById.size();
-		}
-
-		@VisibleForTesting
-		Set<AllocatedSlot> getSlotsForTaskManager(ResourceID resourceId) {
-			return allocatedSlotsByTaskManager.getOrDefault(resourceId, Collections.emptySet());
-		}
-	}
-
-	// ------------------------------------------------------------------------
-
-	/**
-	 * Organize all available slots from different points of view.
-	 */
-	protected static class AvailableSlots {
-
-		/** All available slots organized by TaskManager. */
-		private final HashMap<ResourceID, Set<AllocatedSlot>> availableSlotsByTaskManager;
-
-		/** All available slots organized by host. */
-		private final HashMap<String, Set<AllocatedSlot>> availableSlotsByHost;
-
-		/** The available slots, with the time when they were inserted. */
-		private final HashMap<AllocationID, SlotAndTimestamp> availableSlots;
-
-		AvailableSlots() {
-			this.availableSlotsByTaskManager = new HashMap<>();
-			this.availableSlotsByHost = new HashMap<>();
-			this.availableSlots = new HashMap<>();
-		}
-
-		/**
-		 * Adds an available slot.
-		 *
-		 * @param slot The slot to add
-		 */
-		void add(final AllocatedSlot slot, final long timestamp) {
-			checkNotNull(slot);
-
-			SlotAndTimestamp previous = availableSlots.put(
-					slot.getAllocationId(), new SlotAndTimestamp(slot, timestamp));
-
-			if (previous == null) {
-				final ResourceID resourceID = slot.getTaskManagerLocation().getResourceID();
-				final String host = slot.getTaskManagerLocation().getFQDNHostname();
-
-				Set<AllocatedSlot> slotsForTaskManager =
-					availableSlotsByTaskManager.computeIfAbsent(resourceID, k -> new HashSet<>());
-				slotsForTaskManager.add(slot);
-
-				Set<AllocatedSlot> slotsForHost =
-					availableSlotsByHost.computeIfAbsent(host, k -> new HashSet<>());
-				slotsForHost.add(slot);
-			}
-			else {
-				throw new IllegalStateException("slot already contained");
-			}
-		}
-
-		/**
-		 * Check whether we have this slot.
-		 */
-		boolean contains(AllocationID slotId) {
-			return availableSlots.containsKey(slotId);
-		}
-
-		AllocatedSlot get(AllocationID allocationID) {
-			SlotAndTimestamp slotAndTimestamp = availableSlots.get(allocationID);
-			if (slotAndTimestamp != null) {
-				return slotAndTimestamp.slot();
-			} else {
-				return null;
-			}
-		}
-
-		/**
-		 * Poll a slot which matches the required resource profile. The polling tries to satisfy the
-		 * location preferences, by TaskManager and by host.
-		 *
-		 * @param slotProfile slot profile that specifies the requirements for the slot
-		 *
-		 * @return Slot which matches the resource profile, null if we can't find a match
-		 */
-		SlotAndLocality poll(SchedulingStrategy schedulingStrategy, SlotProfile slotProfile) {
-			// fast path if no slots are available
-			if (availableSlots.isEmpty()) {
-				return null;
-			}
-			Collection<SlotAndTimestamp> slotAndTimestamps = availableSlots.values();
-
-			SlotAndLocality matchingSlotAndLocality = schedulingStrategy.findMatchWithLocality(
-				slotProfile,
-				slotAndTimestamps::stream,
-				SlotAndTimestamp::slot,
-				(SlotAndTimestamp slot) -> slot.slot().getResourceProfile().isMatching(slotProfile.getResourceProfile()),
-				(SlotAndTimestamp slotAndTimestamp, Locality locality) -> {
-					AllocatedSlot slot = slotAndTimestamp.slot();
-					return new SlotAndLocality(slot, locality);
-				});
-
-			if (matchingSlotAndLocality != null) {
-				AllocatedSlot slot = matchingSlotAndLocality.getSlot();
-				remove(slot.getAllocationId());
-			}
-
-			return matchingSlotAndLocality;
-		}
-
-		/**
-		 * Remove all available slots come from specified TaskManager.
-		 *
-		 * @param taskManager The id of the TaskManager
-		 * @return The set of removed slots for the given TaskManager
-		 */
-		Set<AllocatedSlot> removeAllForTaskManager(final ResourceID taskManager) {
-			// remove from the by-TaskManager view
-			final Set<AllocatedSlot> slotsForTm = availableSlotsByTaskManager.remove(taskManager);
-
-			if (slotsForTm != null && slotsForTm.size() > 0) {
-				final String host = slotsForTm.iterator().next().getTaskManagerLocation().getFQDNHostname();
-				final Set<AllocatedSlot> slotsForHost = availableSlotsByHost.get(host);
-
-				// remove from the base set and the by-host view
-				for (AllocatedSlot slot : slotsForTm) {
-					availableSlots.remove(slot.getAllocationId());
-					slotsForHost.remove(slot);
-				}
-
-				if (slotsForHost.isEmpty()) {
-					availableSlotsByHost.remove(host);
-				}
-
-				return slotsForTm;
-			} else {
-				return Collections.emptySet();
-			}
-		}
-
-		AllocatedSlot tryRemove(AllocationID slotId) {
-			final SlotAndTimestamp sat = availableSlots.remove(slotId);
-			if (sat != null) {
-				final AllocatedSlot slot = sat.slot();
-				final ResourceID resourceID = slot.getTaskManagerLocation().getResourceID();
-				final String host = slot.getTaskManagerLocation().getFQDNHostname();
-
-				final Set<AllocatedSlot> slotsForTm = availableSlotsByTaskManager.get(resourceID);
-				final Set<AllocatedSlot> slotsForHost = availableSlotsByHost.get(host);
-
-				slotsForTm.remove(slot);
-				slotsForHost.remove(slot);
-
-				if (slotsForTm.isEmpty()) {
-					availableSlotsByTaskManager.remove(resourceID);
-				}
-				if (slotsForHost.isEmpty()) {
-					availableSlotsByHost.remove(host);
-				}
-
-				return slot;
-			}
-			else {
-				return null;
-			}
-		}
-
-		private void remove(AllocationID slotId) throws IllegalStateException {
-			if (tryRemove(slotId) == null) {
-				throw new IllegalStateException("slot not contained");
-			}
-		}
-
-		String printAllSlots() {
-			return availableSlots.values().toString();
-		}
-
-		@VisibleForTesting
-		boolean containsTaskManager(ResourceID resourceID) {
-			return availableSlotsByTaskManager.containsKey(resourceID);
-		}
-
-		@VisibleForTesting
-		public int size() {
-			return availableSlots.size();
-		}
-
-		@VisibleForTesting
-		void clear() {
-			availableSlots.clear();
-			availableSlotsByTaskManager.clear();
-			availableSlotsByHost.clear();
-		}
-	}
-
-	// ------------------------------------------------------------------------
-
-	/**
-	 * An implementation of the {@link SlotOwner} and {@link SlotProvider} interfaces
-	 * that delegates methods as RPC calls to the SlotPool's RPC gateway.
-	 */
-	public static class ProviderAndOwner implements SlotOwner, SlotProvider {
-
-		private final SlotPoolGateway gateway;
-		private final boolean requiresPreviousAllocationsForScheduling;
-
-		ProviderAndOwner(SlotPoolGateway gateway, boolean requiresPreviousAllocationsForScheduling) {
-			this.gateway = gateway;
-			this.requiresPreviousAllocationsForScheduling = requiresPreviousAllocationsForScheduling;
-		}
-
-		public boolean requiresPreviousAllocationsForScheduling() {
-			return requiresPreviousAllocationsForScheduling;
-		}
-
-		@Override
-		public CompletableFuture<Boolean> returnAllocatedSlot(LogicalSlot slot) {
-			return gateway
-				.releaseSlot(
-					slot.getSlotRequestId(),
-					slot.getSlotSharingGroupId(),
-					new FlinkException("Slot is being returned to the SlotPool."))
-				.thenApply(
-					(Acknowledge acknowledge) -> true);
-		}
-
-		@Override
-		public CompletableFuture<LogicalSlot> allocateSlot(
-				SlotRequestId slotRequestId,
-				ScheduledUnit task,
-				boolean allowQueued,
-				SlotProfile slotProfile,
-				Time timeout) {
-
-			CompletableFuture<LogicalSlot> slotFuture = gateway.allocateSlot(
-				slotRequestId,
-				task,
-				slotProfile,
-				allowQueued,
-				timeout);
-
-			slotFuture.whenComplete(
-				(LogicalSlot slot, Throwable failure) -> {
-					if (failure != null) {
-						gateway.releaseSlot(
-							slotRequestId,
-							task.getSlotSharingGroupId(),
-							failure);
-					}
-			});
-
-			return slotFuture;
-		}
-
-		@Override
-		public CompletableFuture<Acknowledge> cancelSlotRequest(
-				SlotRequestId slotRequestId,
-				@Nullable SlotSharingGroupId slotSharingGroupId,
-				Throwable cause) {
-			return gateway.releaseSlot(slotRequestId, slotSharingGroupId, cause);
-		}
-	}
-
-	// ------------------------------------------------------------------------
-
-	/**
-	 * A pending request for a slot.
-	 */
-	private static class PendingRequest {
-
-		private final SlotRequestId slotRequestId;
-
-		private final ResourceProfile resourceProfile;
-
-		private final CompletableFuture<AllocatedSlot> allocatedSlotFuture;
-
-		PendingRequest(
-				SlotRequestId slotRequestId,
-				ResourceProfile resourceProfile) {
-			this.slotRequestId = Preconditions.checkNotNull(slotRequestId);
-			this.resourceProfile = Preconditions.checkNotNull(resourceProfile);
-
-			allocatedSlotFuture = new CompletableFuture<>();
-		}
-
-		public SlotRequestId getSlotRequestId() {
-			return slotRequestId;
-		}
-
-		public CompletableFuture<AllocatedSlot> getAllocatedSlotFuture() {
-			return allocatedSlotFuture;
-		}
-
-		public ResourceProfile getResourceProfile() {
-			return resourceProfile;
-		}
-
-		@Override
-		public String toString() {
-			return "PendingRequest{" +
-					"slotRequestId=" + slotRequestId +
-					", resourceProfile=" + resourceProfile +
-					", allocatedSlotFuture=" + allocatedSlotFuture +
-					'}';
-		}
-	}
-
-	// ------------------------------------------------------------------------
-
-	/**
-	 * A slot, together with the timestamp when it was added.
-	 */
-	private static class SlotAndTimestamp {
-
-		private final AllocatedSlot slot;
-
-		private final long timestamp;
-
-		SlotAndTimestamp(AllocatedSlot slot, long timestamp) {
-			this.slot = slot;
-			this.timestamp = timestamp;
-		}
-
-		public AllocatedSlot slot() {
-			return slot;
-		}
-
-		public long timestamp() {
-			return timestamp;
-		}
-
-		@Override
-		public String toString() {
-			return slot + " @ " + timestamp;
-		}
-	}
+	 * @param slotRequestId identifying the requested slot
+	 * @param resourceProfile resource profile that specifies the resource requirements for the requested slot
+	 * @param timeout timeout for the allocation procedure
+	 * @return a newly allocated slot that was previously not available.
+	 */
+	@Nonnull
+	CompletableFuture<PhysicalSlot> requestNewAllocatedSlot(
+		@Nonnull SlotRequestId slotRequestId,
+		@Nonnull ResourceProfile resourceProfile,
+		@RpcTimeout Time timeout);
 }
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolGateway.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolGateway.java
deleted file mode 100644
index 4aa8614..0000000
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolGateway.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * 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.jobmaster.slotpool;
-
-import org.apache.flink.api.common.time.Time;
-import org.apache.flink.runtime.clusterframework.types.AllocationID;
-import org.apache.flink.runtime.clusterframework.types.ResourceID;
-import org.apache.flink.runtime.clusterframework.types.ResourceProfile;
-import org.apache.flink.runtime.clusterframework.types.SlotProfile;
-import org.apache.flink.runtime.instance.SlotSharingGroupId;
-import org.apache.flink.runtime.jobmanager.scheduler.ScheduledUnit;
-import org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway;
-import org.apache.flink.runtime.jobmaster.LogicalSlot;
-import org.apache.flink.runtime.jobmaster.SlotRequestId;
-import org.apache.flink.runtime.messages.Acknowledge;
-import org.apache.flink.runtime.resourcemanager.ResourceManagerGateway;
-import org.apache.flink.runtime.rpc.RpcGateway;
-import org.apache.flink.runtime.rpc.RpcTimeout;
-import org.apache.flink.runtime.taskexecutor.slot.SlotOffer;
-import org.apache.flink.runtime.taskmanager.TaskManagerLocation;
-import org.apache.flink.types.SerializableOptional;
-
-import java.util.Collection;
-import java.util.concurrent.CompletableFuture;
-
-/**
- * The gateway for calls on the {@link SlotPool}.
- */
-public interface SlotPoolGateway extends AllocatedSlotActions, RpcGateway {
-
-	// ------------------------------------------------------------------------
-	//  shutdown
-	// ------------------------------------------------------------------------
-
-	CompletableFuture<Acknowledge> suspend();
-
-	// ------------------------------------------------------------------------
-	//  resource manager connection
-	// ------------------------------------------------------------------------
-
-	/**
-	 * Connects the SlotPool to the given ResourceManager. After this method is called, the
-	 * SlotPool will be able to request resources from the given ResourceManager.
-	 *
-	 * @param resourceManagerGateway  The RPC gateway for the resource manager.
-	 */
-	void connectToResourceManager(ResourceManagerGateway resourceManagerGateway);
-
-	/**
-	 * Disconnects the slot pool from its current Resource Manager. After this call, the pool will not
-	 * be able to request further slots from the Resource Manager, and all currently pending requests
-	 * to the resource manager will be canceled.
-	 *
-	 * <p>The slot pool will still be able to serve slots from its internal pool.
-	 */
-	void disconnectResourceManager();
-
-	// ------------------------------------------------------------------------
-	//  registering / un-registering TaskManagers and slots
-	// ------------------------------------------------------------------------
-
-	/**
-	 * Registers a TaskExecutor with the given {@link ResourceID} at {@link SlotPool}.
-	 *
-	 * @param resourceID identifying the TaskExecutor to register
-	 * @return Future acknowledge which is completed after the TaskExecutor has been registered
-	 */
-	CompletableFuture<Acknowledge> registerTaskManager(ResourceID resourceID);
-
-	/**
-	 * Releases a TaskExecutor with the given {@link ResourceID} from the {@link SlotPool}.
-	 *
-	 * @param resourceId identifying the TaskExecutor which shall be released from the SlotPool
-	 * @param cause for the releasing of the TaskManager
-	 * @return Future acknowledge which is completed after the TaskExecutor has been released
-	 */
-	CompletableFuture<Acknowledge> releaseTaskManager(final ResourceID resourceId, final Exception cause);
-
-	/**
-	 * Offers a slot to the {@link SlotPool}. The slot offer can be accepted or
-	 * rejected.
-	 *
-	 * @param taskManagerLocation from which the slot offer originates
-	 * @param taskManagerGateway to talk to the slot offerer
-	 * @param slotOffer slot which is offered to the {@link SlotPool}
-	 * @return True (future) if the slot has been accepted, otherwise false (future)
-	 */
-	CompletableFuture<Boolean> offerSlot(
-		TaskManagerLocation taskManagerLocation,
-		TaskManagerGateway taskManagerGateway,
-		SlotOffer slotOffer);
-
-	/**
-	 * Offers multiple slots to the {@link SlotPool}. The slot offerings can be
-	 * individually accepted or rejected by returning the collection of accepted
-	 * slot offers.
-	 *
-	 * @param taskManagerLocation from which the slot offers originate
-	 * @param taskManagerGateway to talk to the slot offerer
-	 * @param offers slot offers which are offered to the {@link SlotPool}
-	 * @return A collection of accepted slot offers (future). The remaining slot offers are
-	 * 			implicitly rejected.
-	 */
-	CompletableFuture<Collection<SlotOffer>> offerSlots(
-		TaskManagerLocation taskManagerLocation,
-		TaskManagerGateway taskManagerGateway,
-		Collection<SlotOffer> offers);
-
-	/**
-	 * Fails the slot with the given allocation id.
-	 *
-	 * @param allocationID identifying the slot which is being failed
-	 * @param cause of the failure
-	 * @return An optional task executor id if this task executor has no more slots registered
-	 */
-	CompletableFuture<SerializableOptional<ResourceID>> failAllocation(AllocationID allocationID, Exception cause);
-
-	// ------------------------------------------------------------------------
-	//  allocating and disposing slots
-	// ------------------------------------------------------------------------
-
-	/**
-	 * Requests to allocate a slot for the given {@link ScheduledUnit}. The request
-	 * is uniquely identified by the provided {@link SlotRequestId} which can also
-	 * be used to release the slot via {@link #releaseSlot(SlotRequestId, SlotSharingGroupId, Throwable)}.
-	 * The allocated slot will fulfill the requested {@link ResourceProfile} and it
-	 * is tried to place it on one of the location preferences.
-	 *
-	 * <p>If the returned future must not be completed right away (a.k.a. the slot request
-	 * can be queued), allowQueuedScheduling must be set to true.
-	 *
-	 * @param slotRequestId identifying the requested slot
-	 * @param scheduledUnit for which to allocate slot
-	 * @param slotProfile profile that specifies the requirements for the requested slot
-	 * @param allowQueuedScheduling true if the slot request can be queued (e.g. the returned future must not be completed)
-	 * @param timeout for the operation
-	 * @return Future which is completed with the allocated {@link LogicalSlot}
-	 */
-	CompletableFuture<LogicalSlot> allocateSlot(
-			SlotRequestId slotRequestId,
-			ScheduledUnit scheduledUnit,
-			SlotProfile slotProfile,
-			boolean allowQueuedScheduling,
-			@RpcTimeout Time timeout);
-}
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPool.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolImpl.java
similarity index 60%
copy from flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPool.java
copy to flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolImpl.java
index f69c1a4..0671e4e 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPool.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolImpl.java
@@ -27,34 +27,27 @@ import org.apache.flink.runtime.clusterframework.types.AllocationID;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
 import org.apache.flink.runtime.clusterframework.types.ResourceProfile;
 import org.apache.flink.runtime.clusterframework.types.SlotID;
-import org.apache.flink.runtime.clusterframework.types.SlotProfile;
+import org.apache.flink.runtime.concurrent.ComponentMainThreadExecutor;
 import org.apache.flink.runtime.concurrent.FutureUtils;
 import org.apache.flink.runtime.executiongraph.ExecutionGraph;
-import org.apache.flink.runtime.instance.SlotSharingGroupId;
-import org.apache.flink.runtime.jobmanager.scheduler.CoLocationConstraint;
-import org.apache.flink.runtime.jobmanager.scheduler.Locality;
 import org.apache.flink.runtime.jobmanager.scheduler.NoResourceAvailableException;
-import org.apache.flink.runtime.jobmanager.scheduler.ScheduledUnit;
 import org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway;
 import org.apache.flink.runtime.jobmaster.JobMasterId;
-import org.apache.flink.runtime.jobmaster.LogicalSlot;
-import org.apache.flink.runtime.jobmaster.SlotContext;
-import org.apache.flink.runtime.jobmaster.SlotOwner;
+import org.apache.flink.runtime.jobmaster.SlotInfo;
 import org.apache.flink.runtime.jobmaster.SlotRequestId;
 import org.apache.flink.runtime.messages.Acknowledge;
 import org.apache.flink.runtime.resourcemanager.ResourceManagerGateway;
 import org.apache.flink.runtime.resourcemanager.SlotRequest;
-import org.apache.flink.runtime.rpc.RpcEndpoint;
-import org.apache.flink.runtime.rpc.RpcService;
 import org.apache.flink.runtime.taskexecutor.slot.SlotOffer;
 import org.apache.flink.runtime.taskmanager.TaskManagerLocation;
 import org.apache.flink.runtime.util.clock.Clock;
 import org.apache.flink.runtime.util.clock.SystemClock;
-import org.apache.flink.types.SerializableOptional;
-import org.apache.flink.util.AbstractID;
 import org.apache.flink.util.FlinkException;
 import org.apache.flink.util.Preconditions;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
@@ -65,16 +58,13 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Objects;
 import java.util.Optional;
 import java.util.Set;
 import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.CompletionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
+import java.util.function.Function;
 import java.util.stream.Collectors;
-import java.util.stream.Stream;
 
 import static org.apache.flink.util.Preconditions.checkNotNull;
 
@@ -92,17 +82,15 @@ import static org.apache.flink.util.Preconditions.checkNotNull;
  * <p>TODO : Make pending requests location preference aware
  * TODO : Make pass location preferences to ResourceManager when sending a slot request
  */
-public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedSlotActions {
+public class SlotPoolImpl implements SlotPool {
+
+	protected final Logger log = LoggerFactory.getLogger(getClass());
 
 	/** The interval (in milliseconds) in which the SlotPool writes its slot distribution on debug level. */
-	private static final int STATUS_LOG_INTERVAL_MS = 60_000;
+	private static final long STATUS_LOG_INTERVAL_MS = 60_000;
 
 	private final JobID jobId;
 
-	private final SchedulingStrategy schedulingStrategy;
-
-	private final ProviderAndOwner providerAndOwner;
-
 	/** All registered TaskManagers, slots will be accepted and used only if the resource is registered. */
 	private final HashSet<ResourceID> registeredTaskManagers;
 
@@ -126,9 +114,6 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 
 	private final Clock clock;
 
-	/** Managers for the different slot sharing groups. */
-	protected final Map<SlotSharingGroupId, SlotSharingManager> slotSharingManagers;
-
 	/** the fencing token of the job manager. */
 	private JobMasterId jobMasterId;
 
@@ -137,31 +122,26 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 
 	private String jobManagerAddress;
 
+	private ComponentMainThreadExecutor componentMainThreadExecutor;
+
 	// ------------------------------------------------------------------------
 
 	@VisibleForTesting
-	protected SlotPool(RpcService rpcService, JobID jobId, SchedulingStrategy schedulingStrategy) {
+	public SlotPoolImpl(JobID jobId) {
 		this(
-			rpcService,
 			jobId,
-			schedulingStrategy,
 			SystemClock.getInstance(),
 			AkkaUtils.getDefaultTimeout(),
 			Time.milliseconds(JobManagerOptions.SLOT_IDLE_TIMEOUT.defaultValue()));
 	}
 
-	public SlotPool(
-			RpcService rpcService,
+	public SlotPoolImpl(
 			JobID jobId,
-			SchedulingStrategy schedulingStrategy,
 			Clock clock,
 			Time rpcTimeout,
 			Time idleSlotTimeout) {
 
-		super(rpcService);
-
 		this.jobId = checkNotNull(jobId);
-		this.schedulingStrategy = checkNotNull(schedulingStrategy);
 		this.clock = checkNotNull(clock);
 		this.rpcTimeout = checkNotNull(rpcTimeout);
 		this.idleSlotTimeout = checkNotNull(idleSlotTimeout);
@@ -172,42 +152,32 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 		this.pendingRequests = new DualKeyMap<>(16);
 		this.waitingForResourceManager = new HashMap<>(16);
 
-		this.providerAndOwner = new ProviderAndOwner(
-			getSelfGateway(SlotPoolGateway.class),
-			schedulingStrategy instanceof PreviousAllocationSchedulingStrategy);
-
-		this.slotSharingManagers = new HashMap<>(4);
-
 		this.jobMasterId = null;
 		this.resourceManagerGateway = null;
 		this.jobManagerAddress = null;
+
+		this.componentMainThreadExecutor = null;
 	}
 
 	// ------------------------------------------------------------------------
 	//  Starting and Stopping
 	// ------------------------------------------------------------------------
 
-	@Override
-	public void start() {
-		throw new UnsupportedOperationException("Should never call start() without leader ID");
-	}
-
 	/**
 	 * Start the slot pool to accept RPC calls.
 	 *
 	 * @param jobMasterId The necessary leader id for running the job.
 	 * @param newJobManagerAddress for the slot requests which are sent to the resource manager
+	 * @param componentMainThreadExecutor The main thread executor for the job master's main thread.
 	 */
-	public void start(JobMasterId jobMasterId, String newJobManagerAddress) throws Exception {
-		this.jobMasterId = checkNotNull(jobMasterId);
-		this.jobManagerAddress = checkNotNull(newJobManagerAddress);
+	public void start(
+		@Nonnull JobMasterId jobMasterId,
+		@Nonnull String newJobManagerAddress,
+		@Nonnull ComponentMainThreadExecutor componentMainThreadExecutor) throws Exception {
 
-		// TODO - start should not throw an exception
-		try {
-			super.start();
-		} catch (Exception e) {
-			throw new RuntimeException("This should never happen", e);
-		}
+		this.jobMasterId = jobMasterId;
+		this.jobManagerAddress = newJobManagerAddress;
+		this.componentMainThreadExecutor = componentMainThreadExecutor;
 
 		scheduleRunAsync(this::checkIdleSlot, idleSlotTimeout);
 
@@ -216,36 +186,15 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 		}
 	}
 
-	@Override
-	public CompletableFuture<Void> onStop() {
-		log.info("Stopping SlotPool.");
-		// cancel all pending allocations
-		Set<AllocationID> allocationIds = pendingRequests.keySetB();
-
-		for (AllocationID allocationId : allocationIds) {
-			resourceManagerGateway.cancelSlotRequest(allocationId);
-		}
-
-		// release all registered slots by releasing the corresponding TaskExecutors
-		for (ResourceID taskManagerResourceId : registeredTaskManagers) {
-			final FlinkException cause = new FlinkException(
-				"Releasing TaskManager " + taskManagerResourceId + ", because of stopping of SlotPool");
-			releaseTaskManagerInternal(taskManagerResourceId, cause);
-		}
-
-		clear();
-
-		return CompletableFuture.completedFuture(null);
-	}
-
 	/**
 	 * Suspends this pool, meaning it has lost its authority to accept and distribute slots.
 	 */
 	@Override
-	public CompletableFuture<Acknowledge> suspend() {
-		log.info("Suspending SlotPool.");
+	public void suspend() {
 
-		validateRunsInMainThread();
+		componentMainThreadExecutor.assertRunningInMainThread();
+
+		log.info("Suspending SlotPool.");
 
 		// cancel all pending allocations --> we can request these slots
 		// again after we regained the leadership
@@ -255,9 +204,6 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 			resourceManagerGateway.cancelSlotRequest(allocationId);
 		}
 
-		// suspend this RPC endpoint
-		stop();
-
 		// do not accept any requests
 		jobMasterId = null;
 		resourceManagerGateway = null;
@@ -265,34 +211,26 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 		// Clear (but not release!) the available slots. The TaskManagers should re-register them
 		// at the new leader JobManager/SlotPool
 		clear();
-
-		return CompletableFuture.completedFuture(Acknowledge.get());
 	}
 
-	// ------------------------------------------------------------------------
-	//  Getting PoolOwner and PoolProvider
-	// ------------------------------------------------------------------------
+	@Override
+	public void close() {
+		log.info("Stopping SlotPool.");
+		// cancel all pending allocations
+		Set<AllocationID> allocationIds = pendingRequests.keySetB();
 
-	/**
-	 * Gets the slot owner implementation for this pool.
-	 *
-	 * <p>This method does not mutate state and can be called directly (no RPC indirection)
-	 *
-	 * @return The slot owner implementation for this pool.
-	 */
-	public SlotOwner getSlotOwner() {
-		return providerAndOwner;
-	}
+		for (AllocationID allocationId : allocationIds) {
+			resourceManagerGateway.cancelSlotRequest(allocationId);
+		}
 
-	/**
-	 * Gets the slot provider implementation for this pool.
-	 *
-	 * <p>This method does not mutate state and can be called directly (no RPC indirection)
-	 *
-	 * @return The slot provider implementation for this pool.
-	 */
-	public SlotProvider getSlotProvider() {
-		return providerAndOwner;
+		// release all registered slots by releasing the corresponding TaskExecutors
+		for (ResourceID taskManagerResourceId : registeredTaskManagers) {
+			final FlinkException cause = new FlinkException(
+				"Releasing TaskManager " + taskManagerResourceId + ", because of stopping of SlotPool");
+			releaseTaskManagerInternal(taskManagerResourceId, cause);
+		}
+
+		clear();
 	}
 
 	// ------------------------------------------------------------------------
@@ -300,7 +238,7 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 	// ------------------------------------------------------------------------
 
 	@Override
-	public void connectToResourceManager(ResourceManagerGateway resourceManagerGateway) {
+	public void connectToResourceManager(@Nonnull ResourceManagerGateway resourceManagerGateway) {
 		this.resourceManagerGateway = checkNotNull(resourceManagerGateway);
 
 		// work on all slots waiting for this connection
@@ -321,347 +259,6 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 	//  Slot Allocation
 	// ------------------------------------------------------------------------
 
-	@Override
-	public CompletableFuture<LogicalSlot> allocateSlot(
-			SlotRequestId slotRequestId,
-			ScheduledUnit task,
-			SlotProfile slotProfile,
-			boolean allowQueuedScheduling,
-			Time allocationTimeout) {
-
-		log.debug("Received slot request [{}] for task: {}", slotRequestId, task.getTaskToExecute());
-
-		if (task.getSlotSharingGroupId() == null) {
-			return allocateSingleSlot(slotRequestId, slotProfile, allowQueuedScheduling, allocationTimeout);
-		} else {
-			return allocateSharedSlot(slotRequestId, task, slotProfile, allowQueuedScheduling, allocationTimeout);
-		}
-	}
-
-	private CompletableFuture<LogicalSlot> allocateSingleSlot(
-		SlotRequestId slotRequestId,
-		SlotProfile slotProfile,
-		boolean allowQueuedScheduling,
-		Time allocationTimeout) {
-		// request an allocated slot to assign a single logical slot to
-		CompletableFuture<SlotAndLocality> slotAndLocalityFuture = requestAllocatedSlot(
-			slotRequestId,
-			slotProfile,
-			allowQueuedScheduling,
-			allocationTimeout);
-
-		return slotAndLocalityFuture.thenApply(
-			(SlotAndLocality slotAndLocality) -> {
-				final AllocatedSlot allocatedSlot = slotAndLocality.getSlot();
-
-				final SingleLogicalSlot singleTaskSlot = new SingleLogicalSlot(
-					slotRequestId,
-					allocatedSlot,
-					null,
-					slotAndLocality.getLocality(),
-					providerAndOwner);
-
-				if (allocatedSlot.tryAssignPayload(singleTaskSlot)) {
-					return singleTaskSlot;
-				} else {
-					final FlinkException flinkException =
-						new FlinkException("Could not assign payload to allocated slot " + allocatedSlot.getAllocationId() + '.');
-					releaseSingleSlot(slotRequestId, flinkException);
-					throw new CompletionException(flinkException);
-				}
-			});
-	}
-
-	private CompletableFuture<LogicalSlot> allocateSharedSlot(
-		SlotRequestId slotRequestId,
-		ScheduledUnit task,
-		SlotProfile slotProfile,
-		boolean allowQueuedScheduling,
-		Time allocationTimeout) {
-
-		// allocate slot with slot sharing
-		final SlotSharingManager multiTaskSlotManager = slotSharingManagers.computeIfAbsent(
-			task.getSlotSharingGroupId(),
-			id -> new SlotSharingManager(
-				id,
-				this,
-				providerAndOwner));
-
-		final SlotSharingManager.MultiTaskSlotLocality multiTaskSlotLocality;
-
-		try {
-			if (task.getCoLocationConstraint() != null) {
-				multiTaskSlotLocality = allocateCoLocatedMultiTaskSlot(
-					task.getCoLocationConstraint(),
-					multiTaskSlotManager,
-					slotProfile,
-					allowQueuedScheduling,
-					allocationTimeout);
-			} else {
-				multiTaskSlotLocality = allocateMultiTaskSlot(
-					task.getJobVertexId(),
-					multiTaskSlotManager,
-					slotProfile,
-					allowQueuedScheduling,
-					allocationTimeout);
-			}
-		} catch (NoResourceAvailableException noResourceException) {
-			return FutureUtils.completedExceptionally(noResourceException);
-		}
-
-		// sanity check
-		Preconditions.checkState(!multiTaskSlotLocality.getMultiTaskSlot().contains(task.getJobVertexId()));
-
-		final SlotSharingManager.SingleTaskSlot leaf = multiTaskSlotLocality.getMultiTaskSlot().allocateSingleTaskSlot(
-			slotRequestId,
-			task.getJobVertexId(),
-			multiTaskSlotLocality.getLocality());
-
-		return leaf.getLogicalSlotFuture();
-	}
-
-	/**
-	 * Allocates a co-located {@link SlotSharingManager.MultiTaskSlot} for the given {@link CoLocationConstraint}.
-	 *
-	 * <p>If allowQueuedScheduling is true, then the returned {@link SlotSharingManager.MultiTaskSlot} can be
-	 * uncompleted.
-	 *
-	 * @param coLocationConstraint for which to allocate a {@link SlotSharingManager.MultiTaskSlot}
-	 * @param multiTaskSlotManager responsible for the slot sharing group for which to allocate the slot
-	 * @param slotProfile specifying the requirements for the requested slot
-	 * @param allowQueuedScheduling true if queued scheduling (the returned task slot must not be completed yet) is allowed, otherwise false
-	 * @param allocationTimeout timeout before the slot allocation times out
-	 * @return A {@link SlotSharingManager.MultiTaskSlotLocality} which contains the allocated{@link SlotSharingManager.MultiTaskSlot}
-	 * 		and its locality wrt the given location preferences
-	 * @throws NoResourceAvailableException if no task slot could be allocated
-	 */
-	private SlotSharingManager.MultiTaskSlotLocality allocateCoLocatedMultiTaskSlot(
-			CoLocationConstraint coLocationConstraint,
-			SlotSharingManager multiTaskSlotManager,
-			SlotProfile slotProfile,
-			boolean allowQueuedScheduling,
-			Time allocationTimeout) throws NoResourceAvailableException {
-		final SlotRequestId coLocationSlotRequestId = coLocationConstraint.getSlotRequestId();
-
-		if (coLocationSlotRequestId != null) {
-			// we have a slot assigned --> try to retrieve it
-			final SlotSharingManager.TaskSlot taskSlot = multiTaskSlotManager.getTaskSlot(coLocationSlotRequestId);
-
-			if (taskSlot != null) {
-				Preconditions.checkState(taskSlot instanceof SlotSharingManager.MultiTaskSlot);
-				return SlotSharingManager.MultiTaskSlotLocality.of(((SlotSharingManager.MultiTaskSlot) taskSlot), Locality.LOCAL);
-			} else {
-				// the slot may have been cancelled in the mean time
-				coLocationConstraint.setSlotRequestId(null);
-			}
-		}
-
-		if (coLocationConstraint.isAssigned()) {
-			// refine the preferred locations of the slot profile
-			slotProfile = new SlotProfile(
-				slotProfile.getResourceProfile(),
-				Collections.singleton(coLocationConstraint.getLocation()),
-				slotProfile.getPreferredAllocations());
-		}
-
-		// get a new multi task slot
-		final SlotSharingManager.MultiTaskSlotLocality multiTaskSlotLocality = allocateMultiTaskSlot(
-			coLocationConstraint.getGroupId(),
-			multiTaskSlotManager,
-			slotProfile,
-			allowQueuedScheduling,
-			allocationTimeout);
-
-		// check whether we fulfill the co-location constraint
-		if (coLocationConstraint.isAssigned() && multiTaskSlotLocality.getLocality() != Locality.LOCAL) {
-			multiTaskSlotLocality.getMultiTaskSlot().release(
-				new FlinkException("Multi task slot is not local and, thus, does not fulfill the co-location constraint."));
-
-			throw new NoResourceAvailableException("Could not allocate a local multi task slot for the " +
-				"co location constraint " + coLocationConstraint + '.');
-		}
-
-		final SlotRequestId slotRequestId = new SlotRequestId();
-		final SlotSharingManager.MultiTaskSlot coLocationSlot = multiTaskSlotLocality.getMultiTaskSlot().allocateMultiTaskSlot(
-			slotRequestId,
-			coLocationConstraint.getGroupId());
-
-		// mark the requested slot as co-located slot for other co-located tasks
-		coLocationConstraint.setSlotRequestId(slotRequestId);
-
-		// lock the co-location constraint once we have obtained the allocated slot
-		coLocationSlot.getSlotContextFuture().whenComplete(
-			(SlotContext slotContext, Throwable throwable) -> {
-				if (throwable == null) {
-					// check whether we are still assigned to the co-location constraint
-					if (Objects.equals(coLocationConstraint.getSlotRequestId(), slotRequestId)) {
-						coLocationConstraint.lockLocation(slotContext.getTaskManagerLocation());
-					} else {
-						log.debug("Failed to lock colocation constraint {} because assigned slot " +
-							"request {} differs from fulfilled slot request {}.",
-							coLocationConstraint.getGroupId(),
-							coLocationConstraint.getSlotRequestId(),
-							slotRequestId);
-					}
-				} else {
-					log.debug("Failed to lock colocation constraint {} because the slot " +
-						"allocation for slot request {} failed.",
-						coLocationConstraint.getGroupId(),
-						coLocationConstraint.getSlotRequestId(),
-						throwable);
-				}
-			});
-
-		return SlotSharingManager.MultiTaskSlotLocality.of(coLocationSlot, multiTaskSlotLocality.getLocality());
-	}
-
-	/**
-	 * Allocates a {@link SlotSharingManager.MultiTaskSlot} for the given groupId which is in the
-	 * slot sharing group for which the given {@link SlotSharingManager} is responsible.
-	 *
-	 * <p>If allowQueuedScheduling is true, then the method can return an uncompleted {@link SlotSharingManager.MultiTaskSlot}.
-	 *
-	 * @param groupId for which to allocate a new {@link SlotSharingManager.MultiTaskSlot}
-	 * @param slotSharingManager responsible for the slot sharing group for which to allocate the slot
-	 * @param slotProfile slot profile that specifies the requirements for the slot
-	 * @param allowQueuedScheduling true if queued scheduling (the returned task slot must not be completed yet) is allowed, otherwise false
-	 * @param allocationTimeout timeout before the slot allocation times out
-	 * @return A {@link SlotSharingManager.MultiTaskSlotLocality} which contains the allocated {@link SlotSharingManager.MultiTaskSlot}
-	 * 		and its locality wrt the given location preferences
-	 * @throws NoResourceAvailableException if no task slot could be allocated
-	 */
-	private SlotSharingManager.MultiTaskSlotLocality allocateMultiTaskSlot(
-			AbstractID groupId,
-			SlotSharingManager slotSharingManager,
-			SlotProfile slotProfile,
-			boolean allowQueuedScheduling,
-			Time allocationTimeout) throws NoResourceAvailableException {
-
-		// check first whether we have a resolved root slot which we can use
-		SlotSharingManager.MultiTaskSlotLocality multiTaskSlotLocality = slotSharingManager.getResolvedRootSlot(
-			groupId,
-			schedulingStrategy,
-			slotProfile);
-
-		if (multiTaskSlotLocality != null && multiTaskSlotLocality.getLocality() == Locality.LOCAL) {
-			return multiTaskSlotLocality;
-		}
-
-		final SlotRequestId allocatedSlotRequestId = new SlotRequestId();
-		final SlotRequestId multiTaskSlotRequestId = new SlotRequestId();
-
-		// check whether we have an allocated slot available which we can use to create a new multi task slot in
-		final SlotAndLocality polledSlotAndLocality = pollAndAllocateSlot(allocatedSlotRequestId, slotProfile);
-
-		if (polledSlotAndLocality != null && (polledSlotAndLocality.getLocality() == Locality.LOCAL || multiTaskSlotLocality == null)) {
-
-			final AllocatedSlot allocatedSlot = polledSlotAndLocality.getSlot();
-			final SlotSharingManager.MultiTaskSlot multiTaskSlot = slotSharingManager.createRootSlot(
-				multiTaskSlotRequestId,
-				CompletableFuture.completedFuture(polledSlotAndLocality.getSlot()),
-				allocatedSlotRequestId);
-
-			if (allocatedSlot.tryAssignPayload(multiTaskSlot)) {
-				return SlotSharingManager.MultiTaskSlotLocality.of(multiTaskSlot, polledSlotAndLocality.getLocality());
-			} else {
-				multiTaskSlot.release(new FlinkException("Could not assign payload to allocated slot " +
-					allocatedSlot.getAllocationId() + '.'));
-			}
-		}
-
-		if (multiTaskSlotLocality != null) {
-			// prefer slot sharing group slots over unused slots
-			if (polledSlotAndLocality != null) {
-				releaseSingleSlot(
-					allocatedSlotRequestId,
-					new FlinkException("Locality constraint is not better fulfilled by allocated slot."));
-			}
-			return multiTaskSlotLocality;
-		}
-
-		if (allowQueuedScheduling) {
-			// there is no slot immediately available --> check first for uncompleted slots at the slot sharing group
-			SlotSharingManager.MultiTaskSlot multiTaskSlotFuture = slotSharingManager.getUnresolvedRootSlot(groupId);
-
-			if (multiTaskSlotFuture == null) {
-				// it seems as if we have to request a new slot from the resource manager, this is always the last resort!!!
-				final CompletableFuture<AllocatedSlot> futureSlot = requestNewAllocatedSlot(
-					allocatedSlotRequestId,
-					slotProfile.getResourceProfile(),
-					allocationTimeout);
-
-				multiTaskSlotFuture = slotSharingManager.createRootSlot(
-					multiTaskSlotRequestId,
-					futureSlot,
-					allocatedSlotRequestId);
-
-				futureSlot.whenComplete(
-					(AllocatedSlot allocatedSlot, Throwable throwable) -> {
-						final SlotSharingManager.TaskSlot taskSlot = slotSharingManager.getTaskSlot(multiTaskSlotRequestId);
-
-						if (taskSlot != null) {
-							// still valid
-							if (!(taskSlot instanceof SlotSharingManager.MultiTaskSlot) || throwable != null) {
-								taskSlot.release(throwable);
-							} else {
-								if (!allocatedSlot.tryAssignPayload(((SlotSharingManager.MultiTaskSlot) taskSlot))) {
-									taskSlot.release(new FlinkException("Could not assign payload to allocated slot " +
-										allocatedSlot.getAllocationId() + '.'));
-								}
-							}
-						} else {
-							releaseSingleSlot(
-								allocatedSlotRequestId,
-								new FlinkException("Could not find task slot with " + multiTaskSlotRequestId + '.'));
-						}
-					});
-			}
-
-			return SlotSharingManager.MultiTaskSlotLocality.of(multiTaskSlotFuture, Locality.UNKNOWN);
-
-		} else {
-			throw new NoResourceAvailableException("Could not allocate a shared slot for " + groupId + '.');
-		}
-	}
-
-	/**
-	 * Allocates an allocated slot first by polling from the available slots and then requesting a new
-	 * slot from the ResourceManager if no fitting slot could be found.
-	 *
-	 * @param slotProfile slot profile that specifies the requirements for the slot
-	 * @param allowQueuedScheduling true if the slot allocation can be completed in the future
-	 * @param allocationTimeout timeout before the slot allocation times out
-	 * @return Future containing the allocated simple slot
-	 */
-	private CompletableFuture<SlotAndLocality> requestAllocatedSlot(
-			SlotRequestId slotRequestId,
-			SlotProfile slotProfile,
-			boolean allowQueuedScheduling,
-			Time allocationTimeout) {
-
-		final CompletableFuture<SlotAndLocality> allocatedSlotLocalityFuture;
-
-		// (1) do we have a slot available already?
-		SlotAndLocality slotFromPool = pollAndAllocateSlot(slotRequestId, slotProfile);
-
-		if (slotFromPool != null) {
-			allocatedSlotLocalityFuture = CompletableFuture.completedFuture(slotFromPool);
-		} else if (allowQueuedScheduling) {
-			// we have to request a new allocated slot
-			CompletableFuture<AllocatedSlot> allocatedSlotFuture = requestNewAllocatedSlot(
-				slotRequestId,
-				slotProfile.getResourceProfile(),
-				allocationTimeout);
-
-			allocatedSlotLocalityFuture = allocatedSlotFuture.thenApply((AllocatedSlot allocatedSlot) -> new SlotAndLocality(allocatedSlot, Locality.UNKNOWN));
-		} else {
-			allocatedSlotLocalityFuture = FutureUtils.completedExceptionally(new NoResourceAvailableException("Could not allocate a simple slot for " +
-				slotRequestId + '.'));
-		}
-
-		return allocatedSlotLocalityFuture;
-	}
-
 	/**
 	 * Requests a new slot with the given {@link ResourceProfile} from the ResourceManager. If there is
 	 * currently not ResourceManager connected, then the request is stashed and send once a new
@@ -669,13 +266,16 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 	 *
 	 * @param slotRequestId identifying the requested slot
 	 * @param resourceProfile which the requested slot should fulfill
-	 * @param allocationTimeout timeout before the slot allocation times out
+	 * @param timeout timeout before the slot allocation times out
 	 * @return An {@link AllocatedSlot} future which is completed once the slot is offered to the {@link SlotPool}
 	 */
-	private CompletableFuture<AllocatedSlot> requestNewAllocatedSlot(
-			SlotRequestId slotRequestId,
-			ResourceProfile resourceProfile,
-			Time allocationTimeout) {
+	@Nonnull
+	private CompletableFuture<AllocatedSlot> requestNewAllocatedSlotInternal(
+		@Nonnull SlotRequestId slotRequestId,
+		@Nonnull ResourceProfile resourceProfile,
+		@Nonnull Time timeout) {
+
+		componentMainThreadExecutor.assertRunningInMainThread();
 
 		final PendingRequest pendingRequest = new PendingRequest(
 			slotRequestId,
@@ -683,14 +283,17 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 
 		// register request timeout
 		FutureUtils
-			.orTimeout(pendingRequest.getAllocatedSlotFuture(), allocationTimeout.toMilliseconds(), TimeUnit.MILLISECONDS)
-			.whenCompleteAsync(
+			.orTimeout(
+				pendingRequest.getAllocatedSlotFuture(),
+				timeout.toMilliseconds(),
+				TimeUnit.MILLISECONDS,
+				componentMainThreadExecutor)
+			.whenComplete(
 				(AllocatedSlot ignored, Throwable throwable) -> {
 					if (throwable instanceof TimeoutException) {
 						timeoutPendingSlotRequest(slotRequestId);
 					}
-				},
-				getMainThreadExecutor());
+				});
 
 		if (resourceManagerGateway == null) {
 			stashRequestWaitingForResourceManager(pendingRequest);
@@ -728,14 +331,15 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 			new SlotRequest(jobId, allocationId, pendingRequest.getResourceProfile(), jobManagerAddress),
 			rpcTimeout);
 
-		// on failure, fail the request future
-		rmResponse.whenCompleteAsync(
+		FutureUtils.whenCompleteAsyncIfNotDone(
+			rmResponse,
+			componentMainThreadExecutor,
 			(Acknowledge ignored, Throwable failure) -> {
+				// on failure, fail the request future
 				if (failure != null) {
 					slotRequestToResourceManagerFailed(pendingRequest.getSlotRequestId(), failure);
 				}
-			},
-			getMainThreadExecutor());
+			});
 	}
 
 	private void slotRequestToResourceManagerFailed(SlotRequestId slotRequestID, Throwable failure) {
@@ -763,39 +367,45 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 	// ------------------------------------------------------------------------
 
 	@Override
-	public CompletableFuture<Acknowledge> releaseSlot(
-		SlotRequestId slotRequestId,
-		@Nullable SlotSharingGroupId slotSharingGroupId,
-		Throwable cause) {
+	public void releaseSlot(@Nonnull SlotRequestId slotRequestId, @Nullable Throwable cause) {
+
+		componentMainThreadExecutor.assertRunningInMainThread();
 
 		log.debug("Releasing slot [{}] because: {}", slotRequestId, cause != null ? cause.getMessage() : "null");
+		releaseSingleSlot(slotRequestId, cause);
+	}
 
-		if (slotSharingGroupId != null) {
-			releaseSharedSlot(slotRequestId, slotSharingGroupId, cause);
+	@Override
+	public Optional<PhysicalSlot> allocateAvailableSlot(
+		@Nonnull SlotRequestId slotRequestId,
+		@Nonnull AllocationID allocationID) {
+
+		componentMainThreadExecutor.assertRunningInMainThread();
+
+		AllocatedSlot allocatedSlot = availableSlots.tryRemove(allocationID);
+		if (allocatedSlot != null) {
+			allocatedSlots.add(slotRequestId, allocatedSlot);
+			return Optional.of(allocatedSlot);
 		} else {
-			releaseSingleSlot(slotRequestId, cause);
+			return Optional.empty();
 		}
-
-		return CompletableFuture.completedFuture(Acknowledge.get());
 	}
 
-	private void releaseSharedSlot(
-		SlotRequestId slotRequestId,
-		@Nonnull SlotSharingGroupId slotSharingGroupId, Throwable cause) {
-
-		final SlotSharingManager multiTaskSlotManager = slotSharingManagers.get(slotSharingGroupId);
+	@Nonnull
+	@Override
+	public CompletableFuture<PhysicalSlot> requestNewAllocatedSlot(
+		@Nonnull SlotRequestId slotRequestId,
+		@Nonnull ResourceProfile resourceProfile,
+		Time timeout) {
 
-		if (multiTaskSlotManager != null) {
-			final SlotSharingManager.TaskSlot taskSlot = multiTaskSlotManager.getTaskSlot(slotRequestId);
+		return requestNewAllocatedSlotInternal(slotRequestId, resourceProfile, timeout)
+			.thenApply((Function.identity()));
+	}
 
-			if (taskSlot != null) {
-				taskSlot.release(cause);
-			} else {
-				log.debug("Could not find slot [{}] in slot sharing group {}. Ignoring release slot request.", slotRequestId, slotSharingGroupId);
-			}
-		} else {
-			log.debug("Could not find slot sharing group {}. Ignoring release slot request.", slotSharingGroupId);
-		}
+	@Override
+	@Nonnull
+	public Collection<SlotInfo> getAvailableSlotsInformation() {
+		return availableSlots.listSlotInfo();
 	}
 
 	private void releaseSingleSlot(SlotRequestId slotRequestId, Throwable cause) {
@@ -847,17 +457,6 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 		}
 	}
 
-	@Nullable
-	private SlotAndLocality pollAndAllocateSlot(SlotRequestId slotRequestId, SlotProfile slotProfile) {
-		SlotAndLocality slotFromPool = availableSlots.poll(schedulingStrategy, slotProfile);
-
-		if (slotFromPool != null) {
-			allocatedSlots.add(slotRequestId, slotFromPool.getSlot());
-		}
-
-		return slotFromPool;
-	}
-
 	/**
 	 * Tries to fulfill with the given allocated slot a pending slot request or add the
 	 * allocated slot to the set of available slots if no matching request is available.
@@ -905,27 +504,24 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 	}
 
 	@Override
-	public CompletableFuture<Collection<SlotOffer>> offerSlots(
+	public Collection<SlotOffer> offerSlots(
 			TaskManagerLocation taskManagerLocation,
 			TaskManagerGateway taskManagerGateway,
 			Collection<SlotOffer> offers) {
-		validateRunsInMainThread();
-
-		List<CompletableFuture<Optional<SlotOffer>>> acceptedSlotOffers = offers.stream().map(
-			offer -> offerSlot(
-					taskManagerLocation,
-					taskManagerGateway,
-					offer)
-				.<Optional<SlotOffer>>thenApply(
-					(acceptedSlot) -> acceptedSlot ? Optional.of(offer) : Optional.empty()
-				)
-		).collect(Collectors.toList());
-
-		CompletableFuture<Collection<Optional<SlotOffer>>> optionalSlotOffers = FutureUtils.combineAll(acceptedSlotOffers);
-
-		return optionalSlotOffers.thenApply(collection -> collection.stream()
-				.flatMap(opt -> opt.map(Stream::of).orElseGet(Stream::empty))
-				.collect(Collectors.toList()));
+
+		ArrayList<SlotOffer> result = new ArrayList<>(offers.size());
+
+		for (SlotOffer offer : offers) {
+			if (offerSlot(
+				taskManagerLocation,
+				taskManagerGateway,
+				offer)) {
+
+				result.add(offer);
+			}
+		}
+
+		return result;
 	}
 
 	/**
@@ -939,13 +535,12 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 	 * @param slotOffer the offered slot
 	 * @return True if we accept the offering
 	 */
-	@Override
-	public CompletableFuture<Boolean> offerSlot(
+	boolean offerSlot(
 			final TaskManagerLocation taskManagerLocation,
 			final TaskManagerGateway taskManagerGateway,
 			final SlotOffer slotOffer) {
 
-		validateRunsInMainThread();
+		componentMainThreadExecutor.assertRunningInMainThread();
 
 		// check if this TaskManager is valid
 		final ResourceID resourceID = taskManagerLocation.getResourceID();
@@ -954,7 +549,7 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 		if (!registeredTaskManagers.contains(resourceID)) {
 			log.debug("Received outdated slot offering [{}] from unregistered TaskManager: {}",
 					slotOffer.getAllocationId(), taskManagerLocation);
-			return CompletableFuture.completedFuture(false);
+			return false;
 		}
 
 		// check whether we have already using this slot
@@ -977,11 +572,11 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 
 				// return true here so that the sender will get a positive acknowledgement to the retry
 				// and mark the offering as a success
-				return CompletableFuture.completedFuture(true);
+				return true;
 			} else {
 				// the allocation has been fulfilled by another slot, reject the offer so the task executor
 				// will offer the slot to the resource manager
-				return CompletableFuture.completedFuture(false);
+				return false;
 			}
 		}
 
@@ -1015,7 +610,7 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 
 		// we accepted the request in any case. slot will be released after it idled for
 		// too long and timed out
-		return CompletableFuture.completedFuture(true);
+		return true;
 	}
 
 
@@ -1038,12 +633,15 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 	 * @return Optional task executor if it has no more slots registered
 	 */
 	@Override
-	public CompletableFuture<SerializableOptional<ResourceID>> failAllocation(final AllocationID allocationID, final Exception cause) {
+	public Optional<ResourceID> failAllocation(final AllocationID allocationID, final Exception cause) {
+
+		componentMainThreadExecutor.assertRunningInMainThread();
+
 		final PendingRequest pendingRequest = pendingRequests.removeKeyB(allocationID);
 		if (pendingRequest != null) {
 			// request was still pending
 			failPendingRequest(pendingRequest, cause);
-			return CompletableFuture.completedFuture(SerializableOptional.empty());
+			return Optional.empty();
 		}
 		else {
 			return tryFailingAllocatedSlot(allocationID, cause);
@@ -1052,7 +650,7 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 		// TODO: add some unit tests when the previous two are ready, the allocation may failed at any phase
 	}
 
-	private CompletableFuture<SerializableOptional<ResourceID>> tryFailingAllocatedSlot(AllocationID allocationID, Exception cause) {
+	private Optional<ResourceID> tryFailingAllocatedSlot(AllocationID allocationID, Exception cause) {
 		AllocatedSlot allocatedSlot = availableSlots.tryRemove(allocationID);
 
 		if (allocatedSlot == null) {
@@ -1071,11 +669,11 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 			final ResourceID taskManagerId = allocatedSlot.getTaskManagerId();
 
 			if (!availableSlots.containsTaskManager(taskManagerId) && !allocatedSlots.containResource(taskManagerId)) {
-				return CompletableFuture.completedFuture(SerializableOptional.of(taskManagerId));
+				return Optional.of(taskManagerId);
 			}
 		}
 
-		return CompletableFuture.completedFuture(SerializableOptional.empty());
+		return Optional.empty();
 	}
 
 	// ------------------------------------------------------------------------
@@ -1087,14 +685,14 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 	 * Also it provides a way for us to keep "dead" or "abnormal" TaskManagers out of this pool.
 	 *
 	 * @param resourceID The id of the TaskManager
-	 * @return Future acknowledge if th operation was successful
 	 */
 	@Override
-	public CompletableFuture<Acknowledge> registerTaskManager(final ResourceID resourceID) {
-		log.debug("Register new TaskExecutor {}.", resourceID);
-		registeredTaskManagers.add(resourceID);
+	public boolean registerTaskManager(final ResourceID resourceID) {
+
+		componentMainThreadExecutor.assertRunningInMainThread();
 
-		return CompletableFuture.completedFuture(Acknowledge.get());
+		log.debug("Register new TaskExecutor {}.", resourceID);
+		return registeredTaskManagers.add(resourceID);
 	}
 
 	/**
@@ -1105,12 +703,16 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 	 * @param cause for the releasing of the TaskManager
 	 */
 	@Override
-	public CompletableFuture<Acknowledge> releaseTaskManager(final ResourceID resourceId, final Exception cause) {
+	public boolean releaseTaskManager(final ResourceID resourceId, final Exception cause) {
+
+		componentMainThreadExecutor.assertRunningInMainThread();
+
 		if (registeredTaskManagers.remove(resourceId)) {
 			releaseTaskManagerInternal(resourceId, cause);
+			return true;
+		} else {
+			return false;
 		}
-
-		return CompletableFuture.completedFuture(Acknowledge.get());
 	}
 
 	// ------------------------------------------------------------------------
@@ -1166,12 +768,14 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 					cause,
 					rpcTimeout);
 
-				freeSlotFuture.whenCompleteAsync(
+				FutureUtils.whenCompleteAsyncIfNotDone(
+					freeSlotFuture,
+					componentMainThreadExecutor,
 					(Acknowledge ignored, Throwable throwable) -> {
 						if (throwable != null) {
 							if (registeredTaskManagers.contains(expiredSlot.getTaskManagerId())) {
 								log.debug("Releasing slot [{}] of registered TaskExecutor {} failed. " +
-									"Trying to fulfill a different slot request.", allocationID, expiredSlot.getTaskManagerId(),
+										"Trying to fulfill a different slot request.", allocationID, expiredSlot.getTaskManagerId(),
 									throwable);
 								tryFulfillSlotRequestOrMakeAvailable(expiredSlot);
 							} else {
@@ -1179,8 +783,7 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 									"longer registered. Discarding slot.", allocationID, expiredSlot.getTaskManagerId());
 							}
 						}
-					},
-					getMainThreadExecutor());
+					});
 			}
 		}
 
@@ -1196,7 +799,6 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 		pendingRequests.clear();
 		waitingForResourceManager.clear();
 		registeredTaskManagers.clear();
-		slotSharingManagers.clear();
 	}
 
 	// ------------------------------------------------------------------------
@@ -1209,7 +811,6 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 	}
 
 	private String printStatus() {
-		validateRunsInMainThread();
 
 		final StringBuilder builder = new StringBuilder(1024).append("Slot Pool Status:\n");
 
@@ -1229,11 +830,6 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 
 		builder.append("\tpending requests: ").append(pendingRequests.values()).append('\n');
 
-		builder.append("\tsharing groups: {\n");
-		for (Entry<SlotSharingGroupId, SlotSharingManager> manager : slotSharingManagers.entrySet()) {
-			builder.append("\t -------- ").append(manager.getKey()).append(" --------\n");
-			builder.append(manager.getValue());
-		}
 		builder.append("\t}\n");
 		return builder.toString();
 	}
@@ -1263,6 +859,37 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 		runAsync(this::checkIdleSlot);
 	}
 
+	/**
+	 * Execute the runnable in the main thread of the underlying RPC endpoint.
+	 *
+	 * @param runnable Runnable to be executed in the main thread of the underlying RPC endpoint
+	 */
+	protected void runAsync(Runnable runnable) {
+		componentMainThreadExecutor.execute(runnable);
+	}
+
+	/**
+	 * Execute the runnable in the main thread of the underlying RPC endpoint, with
+	 * a delay of the given number of milliseconds.
+	 *
+	 * @param runnable Runnable to be executed
+	 * @param delay    The delay after which the runnable will be executed
+	 */
+	protected void scheduleRunAsync(Runnable runnable, Time delay) {
+		scheduleRunAsync(runnable, delay.getSize(), delay.getUnit());
+	}
+
+	/**
+	 * Execute the runnable in the main thread of the underlying RPC endpoint, with
+	 * a delay of the given number of milliseconds.
+	 *
+	 * @param runnable Runnable to be executed
+	 * @param delay    The delay after which the runnable will be executed
+	 */
+	protected void scheduleRunAsync(Runnable runnable, long delay, TimeUnit unit) {
+		componentMainThreadExecutor.schedule(runnable, delay, unit);
+	}
+
 	// ------------------------------------------------------------------------
 	//  Helper classes
 	// ------------------------------------------------------------------------
@@ -1481,39 +1108,6 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 		}
 
 		/**
-		 * Poll a slot which matches the required resource profile. The polling tries to satisfy the
-		 * location preferences, by TaskManager and by host.
-		 *
-		 * @param slotProfile slot profile that specifies the requirements for the slot
-		 *
-		 * @return Slot which matches the resource profile, null if we can't find a match
-		 */
-		SlotAndLocality poll(SchedulingStrategy schedulingStrategy, SlotProfile slotProfile) {
-			// fast path if no slots are available
-			if (availableSlots.isEmpty()) {
-				return null;
-			}
-			Collection<SlotAndTimestamp> slotAndTimestamps = availableSlots.values();
-
-			SlotAndLocality matchingSlotAndLocality = schedulingStrategy.findMatchWithLocality(
-				slotProfile,
-				slotAndTimestamps::stream,
-				SlotAndTimestamp::slot,
-				(SlotAndTimestamp slot) -> slot.slot().getResourceProfile().isMatching(slotProfile.getResourceProfile()),
-				(SlotAndTimestamp slotAndTimestamp, Locality locality) -> {
-					AllocatedSlot slot = slotAndTimestamp.slot();
-					return new SlotAndLocality(slot, locality);
-				});
-
-			if (matchingSlotAndLocality != null) {
-				AllocatedSlot slot = matchingSlotAndLocality.getSlot();
-				remove(slot.getAllocationId());
-			}
-
-			return matchingSlotAndLocality;
-		}
-
-		/**
 		 * Remove all available slots come from specified TaskManager.
 		 *
 		 * @param taskManager The id of the TaskManager
@@ -1570,6 +1164,15 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 			}
 		}
 
+		@Nonnull
+		List<SlotInfo> listSlotInfo() {
+			return availableSlots
+				.values()
+				.stream()
+				.map(SlotAndTimestamp::slot)
+				.collect(Collectors.toList());
+		}
+
 		private void remove(AllocationID slotId) throws IllegalStateException {
 			if (tryRemove(slotId) == null) {
 				throw new IllegalStateException("slot not contained");
@@ -1601,74 +1204,6 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 	// ------------------------------------------------------------------------
 
 	/**
-	 * An implementation of the {@link SlotOwner} and {@link SlotProvider} interfaces
-	 * that delegates methods as RPC calls to the SlotPool's RPC gateway.
-	 */
-	public static class ProviderAndOwner implements SlotOwner, SlotProvider {
-
-		private final SlotPoolGateway gateway;
-		private final boolean requiresPreviousAllocationsForScheduling;
-
-		ProviderAndOwner(SlotPoolGateway gateway, boolean requiresPreviousAllocationsForScheduling) {
-			this.gateway = gateway;
-			this.requiresPreviousAllocationsForScheduling = requiresPreviousAllocationsForScheduling;
-		}
-
-		public boolean requiresPreviousAllocationsForScheduling() {
-			return requiresPreviousAllocationsForScheduling;
-		}
-
-		@Override
-		public CompletableFuture<Boolean> returnAllocatedSlot(LogicalSlot slot) {
-			return gateway
-				.releaseSlot(
-					slot.getSlotRequestId(),
-					slot.getSlotSharingGroupId(),
-					new FlinkException("Slot is being returned to the SlotPool."))
-				.thenApply(
-					(Acknowledge acknowledge) -> true);
-		}
-
-		@Override
-		public CompletableFuture<LogicalSlot> allocateSlot(
-				SlotRequestId slotRequestId,
-				ScheduledUnit task,
-				boolean allowQueued,
-				SlotProfile slotProfile,
-				Time timeout) {
-
-			CompletableFuture<LogicalSlot> slotFuture = gateway.allocateSlot(
-				slotRequestId,
-				task,
-				slotProfile,
-				allowQueued,
-				timeout);
-
-			slotFuture.whenComplete(
-				(LogicalSlot slot, Throwable failure) -> {
-					if (failure != null) {
-						gateway.releaseSlot(
-							slotRequestId,
-							task.getSlotSharingGroupId(),
-							failure);
-					}
-			});
-
-			return slotFuture;
-		}
-
-		@Override
-		public CompletableFuture<Acknowledge> cancelSlotRequest(
-				SlotRequestId slotRequestId,
-				@Nullable SlotSharingGroupId slotSharingGroupId,
-				Throwable cause) {
-			return gateway.releaseSlot(slotRequestId, slotSharingGroupId, cause);
-		}
-	}
-
-	// ------------------------------------------------------------------------
-
-	/**
 	 * A pending request for a slot.
 	 */
 	private static class PendingRequest {
@@ -1682,10 +1217,16 @@ public class SlotPool extends RpcEndpoint implements SlotPoolGateway, AllocatedS
 		PendingRequest(
 				SlotRequestId slotRequestId,
 				ResourceProfile resourceProfile) {
+			this(slotRequestId, resourceProfile, new CompletableFuture<>());
+		}
+
+		PendingRequest(
+			SlotRequestId slotRequestId,
+			ResourceProfile resourceProfile,
+			CompletableFuture<AllocatedSlot> allocatedSlotFuture) {
 			this.slotRequestId = Preconditions.checkNotNull(slotRequestId);
 			this.resourceProfile = Preconditions.checkNotNull(resourceProfile);
-
-			allocatedSlotFuture = new CompletableFuture<>();
+			this.allocatedSlotFuture = Preconditions.checkNotNull(allocatedSlotFuture);
 		}
 
 		public SlotRequestId getSlotRequestId() {
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SlotProvider.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SlotProvider.java
index 91c0372..6c2c8d8 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SlotProvider.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SlotProvider.java
@@ -24,7 +24,6 @@ import org.apache.flink.runtime.instance.SlotSharingGroupId;
 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.messages.Acknowledge;
 
 import javax.annotation.Nullable;
 
@@ -47,39 +46,39 @@ public interface SlotProvider {
 	 * Allocating slot with specific requirement.
 	 *
 	 * @param slotRequestId identifying the slot request
-	 * @param task The task to allocate the slot for
-	 * @param allowQueued Whether allow the task be queued if we do not have enough resource
+	 * @param scheduledUnit The task to allocate the slot for
 	 * @param slotProfile profile of the requested slot
-	 * @param timeout after which the allocation fails with a timeout exception
+	 * @param allowQueuedScheduling Whether allow the task be queued if we do not have enough resource
+	 * @param allocationTimeout after which the allocation fails with a timeout exception
 	 * @return The future of the allocation
 	 */
 	CompletableFuture<LogicalSlot> allocateSlot(
 		SlotRequestId slotRequestId,
-		ScheduledUnit task,
-		boolean allowQueued,
+		ScheduledUnit scheduledUnit,
 		SlotProfile slotProfile,
-		Time timeout);
+		boolean allowQueuedScheduling,
+		Time allocationTimeout);
 
 	/**
 	 * Allocating slot with specific requirement.
 	 *
-	 * @param task The task to allocate the slot for
+	 * @param scheduledUnit The task to allocate the slot for
 	 * @param allowQueued Whether allow the task be queued if we do not have enough resource
 	 * @param slotProfile profile of the requested slot
-	 * @param timeout after which the allocation fails with a timeout exception
+	 * @param allocationTimeout after which the allocation fails with a timeout exception
 	 * @return The future of the allocation
 	 */
 	default CompletableFuture<LogicalSlot> allocateSlot(
-		ScheduledUnit task,
+		ScheduledUnit scheduledUnit,
 		boolean allowQueued,
 		SlotProfile slotProfile,
-		Time timeout) {
+		Time allocationTimeout) {
 		return allocateSlot(
 			new SlotRequestId(),
-			task,
-			allowQueued,
+			scheduledUnit,
 			slotProfile,
-			timeout);
+			allowQueued,
+			allocationTimeout);
 	}
 
 	/**
@@ -88,9 +87,8 @@ public interface SlotProvider {
 	 * @param slotRequestId identifying the slot request to cancel
 	 * @param slotSharingGroupId identifying the slot request to cancel
 	 * @param cause of the cancellation
-	 * @return Future which is completed once the slot request has been cancelled
 	 */
-	CompletableFuture<Acknowledge> cancelSlotRequest(
+	void cancelSlotRequest(
 		SlotRequestId slotRequestId,
 		@Nullable SlotSharingGroupId slotSharingGroupId,
 		Throwable cause);
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SlotSelectionStrategy.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SlotSelectionStrategy.java
new file mode 100644
index 0000000..1442145
--- /dev/null
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SlotSelectionStrategy.java
@@ -0,0 +1,78 @@
+/*
+ * 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.jobmaster.slotpool;
+
+import org.apache.flink.runtime.clusterframework.types.SlotProfile;
+import org.apache.flink.runtime.jobmanager.scheduler.Locality;
+import org.apache.flink.runtime.jobmaster.SlotInfo;
+
+import javax.annotation.Nonnull;
+
+import java.util.Collection;
+import java.util.Optional;
+
+/**
+ * Interface for slot selection strategies to be used in the {@link Scheduler}.
+ */
+public interface SlotSelectionStrategy {
+
+	/**
+	 * Selects the best {@link SlotInfo} w.r.t. a certain selection criterion from the provided list of available slots
+	 * and considering the given {@link SlotProfile} that describes the requirements.
+	 *
+	 * @param availableSlots a list of the available slots to select from.
+	 * @param slotProfile a slot profile, describing requirements for the slot selection.
+	 * @return the selected slot info with the corresponding locality hint.
+	 */
+	Optional<SlotInfoAndLocality> selectBestSlotForProfile(
+		@Nonnull Collection<? extends SlotInfo> availableSlots,
+		@Nonnull SlotProfile slotProfile);
+
+
+	/**
+	 * This class is a value type that combines a {@link SlotInfo} with a {@link Locality} hint.
+	 */
+	final class SlotInfoAndLocality {
+
+		@Nonnull
+		private final SlotInfo slotInfo;
+
+		@Nonnull
+		private final Locality locality;
+
+		private SlotInfoAndLocality(@Nonnull SlotInfo slotInfo, @Nonnull Locality locality) {
+			this.slotInfo = slotInfo;
+			this.locality = locality;
+		}
+
+		@Nonnull
+		public SlotInfo getSlotInfo() {
+			return slotInfo;
+		}
+
+		@Nonnull
+		public Locality getLocality() {
+			return locality;
+		}
+
+		public static SlotInfoAndLocality of(@Nonnull SlotInfo slotInfo, @Nonnull Locality locality) {
+			return new SlotInfoAndLocality(slotInfo, locality);
+		}
+	}
+}
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SlotSharingManager.java b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SlotSharingManager.java
index af55827..f5d0dec 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SlotSharingManager.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/jobmaster/slotpool/SlotSharingManager.java
@@ -19,11 +19,12 @@
 package org.apache.flink.runtime.jobmaster.slotpool;
 
 import org.apache.flink.annotation.VisibleForTesting;
-import org.apache.flink.runtime.clusterframework.types.SlotProfile;
+import org.apache.flink.runtime.clusterframework.types.AllocationID;
 import org.apache.flink.runtime.instance.SlotSharingGroupId;
 import org.apache.flink.runtime.jobmanager.scheduler.Locality;
 import org.apache.flink.runtime.jobmaster.LogicalSlot;
 import org.apache.flink.runtime.jobmaster.SlotContext;
+import org.apache.flink.runtime.jobmaster.SlotInfo;
 import org.apache.flink.runtime.jobmaster.SlotOwner;
 import org.apache.flink.runtime.jobmaster.SlotRequestId;
 import org.apache.flink.runtime.taskmanager.TaskManagerLocation;
@@ -35,19 +36,19 @@ import org.apache.flink.util.Preconditions;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
 import java.util.AbstractCollection;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Objects;
-import java.util.Set;
 import java.util.concurrent.CompletableFuture;
 import java.util.function.Function;
+import java.util.stream.Collectors;
 
 /**
  * Manager which is responsible for slot sharing. Slot sharing allows to run different
@@ -95,7 +96,7 @@ public class SlotSharingManager {
 	private final Map<SlotRequestId, MultiTaskSlot> unresolvedRootSlots;
 
 	/** Root nodes which have been completed (the underlying allocated slot has been assigned). */
-	private final Map<TaskManagerLocation, Set<MultiTaskSlot>> resolvedRootSlots;
+	private final Map<TaskManagerLocation, Map<AllocationID, MultiTaskSlot>> resolvedRootSlots;
 
 	SlotSharingManager(
 			SlotSharingGroupId slotSharingGroupId,
@@ -133,6 +134,7 @@ public class SlotSharingManager {
 	 *                               to cancel the pending slot request or release the allocated slot
 	 * @return New root slot
 	 */
+	@Nonnull
 	MultiTaskSlot createRootSlot(
 			SlotRequestId slotRequestId,
 			CompletableFuture<? extends SlotContext> slotContextFuture,
@@ -156,13 +158,15 @@ public class SlotSharingManager {
 					final MultiTaskSlot resolvedRootNode = unresolvedRootSlots.remove(slotRequestId);
 
 					if (resolvedRootNode != null) {
-						LOG.trace("Fulfill multi task slot [{}] with slot [{}].", slotRequestId, slotContext.getAllocationId());
+						final AllocationID allocationId = slotContext.getAllocationId();
+						LOG.trace("Fulfill multi task slot [{}] with slot [{}].", slotRequestId, allocationId);
 
-						final Set<MultiTaskSlot> innerCollection = resolvedRootSlots.computeIfAbsent(
+						final Map<AllocationID, MultiTaskSlot> innerMap = resolvedRootSlots.computeIfAbsent(
 							slotContext.getTaskManagerLocation(),
-							taskManagerLocation -> new HashSet<>(4));
+							taskManagerLocation -> new HashMap<>(4));
 
-						innerCollection.add(resolvedRootNode);
+						MultiTaskSlot previousValue = innerMap.put(allocationId, resolvedRootNode);
+						Preconditions.checkState(previousValue == null);
 					}
 				} else {
 					rootMultiTaskSlot.release(throwable);
@@ -172,24 +176,21 @@ public class SlotSharingManager {
 		return rootMultiTaskSlot;
 	}
 
-	/**
-	 * Gets a resolved root slot which does not yet contain the given groupId. First the given set of
-	 * preferred locations is checked.
-	 *
-	 * @param groupId which the returned slot must not contain
-	 * @param matcher slot profile matcher to match slot with the profile requirements
-	 * @return the resolved root slot and its locality wrt to the specified location preferences
-	 * 		or null if there was no root slot which did not contain the given groupId
-	 */
+	@Nonnull
+	public Collection<SlotInfo> listResolvedRootSlotInfo(@Nullable AbstractID groupId) {
+		return resolvedRootSlots
+			.values()
+			.stream()
+			.flatMap((Map<AllocationID, MultiTaskSlot> map) -> map.values().stream())
+			.filter((MultiTaskSlot multiTaskSlot) -> !multiTaskSlot.contains(groupId))
+			.map((MultiTaskSlot multiTaskSlot) -> (SlotInfo) multiTaskSlot.getSlotContextFuture().join())
+			.collect(Collectors.toList());
+	}
+
 	@Nullable
-	MultiTaskSlotLocality getResolvedRootSlot(AbstractID groupId, SchedulingStrategy matcher, SlotProfile slotProfile) {
-		Collection<Set<MultiTaskSlot>> resolvedRootSlotsValues = this.resolvedRootSlots.values();
-		return matcher.findMatchWithLocality(
-			slotProfile,
-			() -> resolvedRootSlotsValues.stream().flatMap(Collection::stream),
-			(MultiTaskSlot multiTaskSlot) -> multiTaskSlot.getSlotContextFuture().join(),
-			(MultiTaskSlot multiTaskSlot) -> !multiTaskSlot.contains(groupId),
-			MultiTaskSlotLocality::of);
+	public MultiTaskSlot getResolvedRootSlot(@Nonnull SlotInfo slotInfo) {
+		Map<AllocationID, MultiTaskSlot> forLocationEntry = resolvedRootSlots.get(slotInfo.getTaskManagerLocation());
+		return forLocationEntry != null ? forLocationEntry.get(slotInfo.getAllocationId()) : null;
 	}
 
 	/**
@@ -297,7 +298,7 @@ public class SlotSharingManager {
 	/**
 	 * {@link TaskSlot} implementation which can have multiple other task slots assigned as children.
 	 */
-	public final class MultiTaskSlot extends TaskSlot implements AllocatedSlot.Payload {
+	public final class MultiTaskSlot extends TaskSlot implements PhysicalSlot.Payload {
 
 		private final Map<AbstractID, TaskSlot> children;
 
@@ -470,10 +471,12 @@ public class SlotSharingManager {
 					final SlotContext slotContext = slotContextFuture.getNow(null);
 
 					if (slotContext != null) {
-						final Set<MultiTaskSlot> multiTaskSlots = resolvedRootSlots.get(slotContext.getTaskManagerLocation());
+						final Map<AllocationID, MultiTaskSlot> multiTaskSlots =
+							resolvedRootSlots.get(slotContext.getTaskManagerLocation());
 
 						if (multiTaskSlots != null) {
-							multiTaskSlots.remove(this);
+							MultiTaskSlot removedSlot = multiTaskSlots.remove(slotContext.getAllocationId());
+							Preconditions.checkState(removedSlot == this);
 
 							if (multiTaskSlots.isEmpty()) {
 								resolvedRootSlots.remove(slotContext.getTaskManagerLocation());
@@ -483,7 +486,7 @@ public class SlotSharingManager {
 				}
 
 				// release the underlying allocated slot
-				allocatedSlotActions.releaseSlot(allocatedSlotRequestId, null, cause);
+				allocatedSlotActions.releaseSlot(allocatedSlotRequestId, cause);
 			}
 		}
 
@@ -508,7 +511,7 @@ public class SlotSharingManager {
 
 		@Override
 		public String toString() {
-			String physicalSlotDescription = "";
+			String physicalSlotDescription;
 			try {
 				physicalSlotDescription = String.valueOf(slotContextFuture.getNow(null));
 			}
@@ -632,7 +635,7 @@ public class SlotSharingManager {
 		public int size() {
 			int numberResolvedMultiTaskSlots = 0;
 
-			for (Set<MultiTaskSlot> multiTaskSlots : resolvedRootSlots.values()) {
+			for (Map<AllocationID, MultiTaskSlot> multiTaskSlots : resolvedRootSlots.values()) {
 				numberResolvedMultiTaskSlots += multiTaskSlots.size();
 			}
 
@@ -644,14 +647,14 @@ public class SlotSharingManager {
 	 * Iterator over all resolved {@link MultiTaskSlot} root slots.
 	 */
 	private static final class ResolvedRootSlotIterator implements Iterator<MultiTaskSlot> {
-		private final Iterator<Set<MultiTaskSlot>> baseIterator;
+		private final Iterator<Map<AllocationID, MultiTaskSlot>> baseIterator;
 		private Iterator<MultiTaskSlot> currentIterator;
 
-		private ResolvedRootSlotIterator(Iterator<Set<MultiTaskSlot>> baseIterator) {
+		private ResolvedRootSlotIterator(Iterator<Map<AllocationID, MultiTaskSlot>> baseIterator) {
 			this.baseIterator = Preconditions.checkNotNull(baseIterator);
 
 			if (baseIterator.hasNext()) {
-				currentIterator = baseIterator.next().iterator();
+				currentIterator = baseIterator.next().values().iterator();
 			} else {
 				currentIterator = Collections.emptyIterator();
 			}
@@ -673,7 +676,7 @@ public class SlotSharingManager {
 
 		private void progressToNextElement() {
 			while (baseIterator.hasNext() && !currentIterator.hasNext()) {
-				currentIterator = baseIterator.next().iterator();
+				currentIterator = baseIterator.next().values().iterator();
 			}
 		}
 	}
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/clusterframework/types/LocationPreferenceSlotSelectionStrategyTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/clusterframework/types/LocationPreferenceSlotSelectionStrategyTest.java
new file mode 100644
index 0000000..2b1d6b0
--- /dev/null
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/clusterframework/types/LocationPreferenceSlotSelectionStrategyTest.java
@@ -0,0 +1,108 @@
+/*
+ * 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.clusterframework.types;
+
+import org.apache.flink.runtime.jobmaster.slotpool.LocationPreferenceSlotSelectionStrategy;
+import org.apache.flink.runtime.jobmaster.slotpool.SlotSelectionStrategy;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Optional;
+
+public class LocationPreferenceSlotSelectionStrategyTest extends SlotSelectionStrategyTestBase {
+
+	public LocationPreferenceSlotSelectionStrategyTest() {
+		super(LocationPreferenceSlotSelectionStrategy.INSTANCE);
+	}
+
+	protected LocationPreferenceSlotSelectionStrategyTest(SlotSelectionStrategy slotSelectionStrategy) {
+		super(slotSelectionStrategy);
+	}
+
+	@Test
+	public void testResourceProfileRespected() {
+
+		SlotProfile slotProfile = new SlotProfile(biggerResourceProfile, Collections.emptyList(), Collections.emptySet());
+
+		Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile);
+		Assert.assertTrue(match.get().getSlotInfo().getResourceProfile().isMatching(slotProfile.getResourceProfile()));
+
+		ResourceProfile evenBiggerResourceProfile =
+			new ResourceProfile(biggerResourceProfile.getCpuCores() + 1, resourceProfile.getHeapMemoryInMB());
+		slotProfile = new SlotProfile(evenBiggerResourceProfile, Collections.emptyList(), Collections.emptySet());
+
+		match = runMatching(slotProfile);
+		Assert.assertFalse(match.isPresent());
+	}
+
+	@Test
+	public void matchNoRequirements() {
+
+		SlotProfile slotProfile = new SlotProfile(ResourceProfile.UNKNOWN, Collections.emptyList(), Collections.emptySet());
+		Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile);
+
+		Assert.assertTrue(candidates.contains(match.get().getSlotInfo()));
+	}
+
+	@Test
+	public void matchPreferredLocationNotAvailable() {
+
+		SlotProfile slotProfile = new SlotProfile(resourceProfile, Collections.singletonList(tmlX), Collections.emptySet());
+		Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile);
+
+		Assert.assertTrue(candidates.contains(match.get().getSlotInfo()));
+	}
+
+	@Test
+	public void matchPreferredLocation() {
+
+		SlotProfile slotProfile = new SlotProfile(resourceProfile, Collections.singletonList(tml2), Collections.emptySet());
+		Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile);
+
+		Assert.assertEquals(ssc2, match.get().getSlotInfo());
+
+		slotProfile = new SlotProfile(resourceProfile, Arrays.asList(tmlX, tml4), Collections.emptySet());
+		match = runMatching(slotProfile);
+
+		Assert.assertEquals(ssc4, match.get().getSlotInfo());
+
+		slotProfile = new SlotProfile(resourceProfile, Arrays.asList(tml3, tml1, tml3, tmlX), Collections.emptySet());
+		match = runMatching(slotProfile);
+
+		Assert.assertEquals(ssc3, match.get().getSlotInfo());
+	}
+
+	@Test
+	public void matchPreviousLocationAvailableButAlsoBlacklisted() {
+		HashSet<AllocationID> blacklisted = new HashSet<>(4);
+		blacklisted.add(aid1);
+		blacklisted.add(aid2);
+		blacklisted.add(aid3);
+		blacklisted.add(aid4);
+		SlotProfile slotProfile = new SlotProfile(resourceProfile, Collections.singletonList(tml3), Collections.singletonList(aid3), blacklisted);
+		Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile);
+
+		// available previous allocation should override blacklisting
+		Assert.assertEquals(ssc3, match.get().getSlotInfo());
+	}
+}
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/clusterframework/types/PreviousAllocationSlotSelectionStrategyTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/clusterframework/types/PreviousAllocationSlotSelectionStrategyTest.java
new file mode 100644
index 0000000..2a3a16f
--- /dev/null
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/clusterframework/types/PreviousAllocationSlotSelectionStrategyTest.java
@@ -0,0 +1,87 @@
+/*
+ * 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.clusterframework.types;
+
+import org.apache.flink.runtime.jobmaster.slotpool.PreviousAllocationSlotSelectionStrategy;
+import org.apache.flink.runtime.jobmaster.slotpool.SlotSelectionStrategy;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Optional;
+
+public class PreviousAllocationSlotSelectionStrategyTest extends LocationPreferenceSlotSelectionStrategyTest {
+
+	public PreviousAllocationSlotSelectionStrategyTest() {
+		super(PreviousAllocationSlotSelectionStrategy.INSTANCE);
+	}
+
+	@Test
+	public void matchPreviousAllocationOverridesPreferredLocation() {
+
+		SlotProfile slotProfile = new SlotProfile(resourceProfile, Collections.singletonList(tml2), Collections.singleton(aid3));
+		Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile);
+
+		Assert.assertEquals(ssc3, match.get().getSlotInfo());
+
+		slotProfile = new SlotProfile(resourceProfile, Arrays.asList(tmlX, tml1), new HashSet<>(Arrays.asList(aidX, aid2)));
+		match = runMatching(slotProfile);
+
+		Assert.assertEquals(ssc2, match.get().getSlotInfo());
+	}
+
+	@Test
+	public void matchPreviousLocationNotAvailableButByLocality() {
+
+		SlotProfile slotProfile = new SlotProfile(resourceProfile, Collections.singletonList(tml4), Collections.singleton(aidX));
+		Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile);
+
+		Assert.assertEquals(ssc4, match.get().getSlotInfo());
+	}
+
+	@Test
+	public void matchPreviousLocationNotAvailableAndAllOthersBlacklisted() {
+		HashSet<AllocationID> blacklisted = new HashSet<>(4);
+		blacklisted.add(aid1);
+		blacklisted.add(aid2);
+		blacklisted.add(aid3);
+		blacklisted.add(aid4);
+		SlotProfile slotProfile = new SlotProfile(resourceProfile, Collections.singletonList(tml4), Collections.singletonList(aidX), blacklisted);
+		Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile);
+
+		// there should be no valid option left and we expect null as return
+		Assert.assertFalse(match.isPresent());
+	}
+
+	@Test
+	public void matchPreviousLocationNotAvailableAndSomeOthersBlacklisted() {
+		HashSet<AllocationID> blacklisted = new HashSet<>(3);
+		blacklisted.add(aid1);
+		blacklisted.add(aid3);
+		blacklisted.add(aid4);
+		SlotProfile slotProfile = new SlotProfile(resourceProfile, Collections.singletonList(tml4), Collections.singletonList(aidX), blacklisted);
+		Optional<SlotSelectionStrategy.SlotInfoAndLocality> match = runMatching(slotProfile);
+
+		// we expect that the candidate that is not blacklisted is returned
+		Assert.assertEquals(ssc2, match.get().getSlotInfo());
+	}
+}
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/clusterframework/types/SlotProfileTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/clusterframework/types/SlotProfileTest.java
deleted file mode 100644
index ee49149..0000000
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/clusterframework/types/SlotProfileTest.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * 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.clusterframework.types;
-
-import org.apache.flink.runtime.executiongraph.utils.SimpleAckingTaskManagerGateway;
-import org.apache.flink.runtime.instance.SimpleSlotContext;
-import org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway;
-import org.apache.flink.runtime.jobmaster.SlotContext;
-import org.apache.flink.runtime.jobmaster.slotpool.PreviousAllocationSchedulingStrategy;
-import org.apache.flink.runtime.jobmaster.slotpool.SchedulingStrategy;
-import org.apache.flink.runtime.taskmanager.TaskManagerLocation;
-import org.apache.flink.util.TestLogger;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.net.InetAddress;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-public class SlotProfileTest extends TestLogger {
-
-	private final ResourceProfile resourceProfile = new ResourceProfile(2, 1024);
-
-	private final AllocationID aid1 = new AllocationID();
-	private final AllocationID aid2 = new AllocationID();
-	private final AllocationID aid3 = new AllocationID();
-	private final AllocationID aid4 = new AllocationID();
-	private final AllocationID aidX = new AllocationID();
-
-	private final TaskManagerLocation tml1 = new TaskManagerLocation(new ResourceID("tm-1"), InetAddress.getLoopbackAddress(), 42);
-	private final TaskManagerLocation tml2 = new TaskManagerLocation(new ResourceID("tm-2"), InetAddress.getLoopbackAddress(), 43);
-	private final TaskManagerLocation tml3 = new TaskManagerLocation(new ResourceID("tm-3"), InetAddress.getLoopbackAddress(), 44);
-	private final TaskManagerLocation tml4 = new TaskManagerLocation(new ResourceID("tm-4"), InetAddress.getLoopbackAddress(), 45);
-	private final TaskManagerLocation tmlX = new TaskManagerLocation(new ResourceID("tm-X"), InetAddress.getLoopbackAddress(), 46);
-
-	private final TaskManagerGateway taskManagerGateway = new SimpleAckingTaskManagerGateway();
-
-	private SimpleSlotContext ssc1 = new SimpleSlotContext(aid1, tml1, 1, taskManagerGateway);
-	private SimpleSlotContext ssc2 = new SimpleSlotContext(aid2, tml2, 2, taskManagerGateway);
-	private SimpleSlotContext ssc3 = new SimpleSlotContext(aid3, tml3, 3, taskManagerGateway);
-	private SimpleSlotContext ssc4 = new SimpleSlotContext(aid4, tml4, 4, taskManagerGateway);
-
-	private final Set<SlotContext> candidates = Collections.unmodifiableSet(createCandidates());
-
-	private final SchedulingStrategy schedulingStrategy = PreviousAllocationSchedulingStrategy.getInstance();
-
-	private Set<SlotContext> createCandidates() {
-		Set<SlotContext> candidates = new HashSet<>(4);
-		candidates.add(ssc1);
-		candidates.add(ssc2);
-		candidates.add(ssc3);
-		candidates.add(ssc4);
-		return candidates;
-	}
-
-	@Test
-	public void matchNoRequirements() {
-
-		SlotProfile slotProfile = new SlotProfile(resourceProfile, Collections.emptyList(), Collections.emptyList());
-		SlotContext match = runMatching(slotProfile);
-
-		Assert.assertTrue(candidates.contains(match));
-	}
-
-	@Test
-	public void matchPreferredLocationNotAvailable() {
-
-		SlotProfile slotProfile = new SlotProfile(resourceProfile, Collections.singletonList(tmlX), Collections.emptyList());
-		SlotContext match = runMatching(slotProfile);
-
-		Assert.assertTrue(candidates.contains(match));
-	}
-
-	@Test
-	public void matchPreferredLocation() {
-
-		SlotProfile slotProfile = new SlotProfile(resourceProfile, Collections.singletonList(tml2), Collections.emptyList());
-		SlotContext match = runMatching(slotProfile);
-
-		Assert.assertEquals(ssc2, match);
-
-		slotProfile = new SlotProfile(resourceProfile, Arrays.asList(tmlX, tml4), Collections.emptyList());
-		match = runMatching(slotProfile);
-
-		Assert.assertEquals(ssc4, match);
-
-		slotProfile = new SlotProfile(resourceProfile, Arrays.asList(tml3, tml1, tml3, tmlX), Collections.emptyList());
-		match = runMatching(slotProfile);
-
-		Assert.assertEquals(ssc3, match);
-	}
-
-	@Test
-	public void matchPreviousAllocationOverridesPreferredLocation() {
-
-		SlotProfile slotProfile = new SlotProfile(resourceProfile, Collections.singletonList(tml2), Collections.singletonList(aid3));
-		SlotContext match = runMatching(slotProfile);
-
-		Assert.assertEquals(ssc3, match);
-
-		slotProfile = new SlotProfile(resourceProfile, Arrays.asList(tmlX, tml1), Arrays.asList(aidX, aid2));
-		match = runMatching(slotProfile);
-
-		Assert.assertEquals(ssc2, match);
-	}
-
-	@Test
-	public void matchPreviousLocationNotAvailableButByLocality() {
-
-		SlotProfile slotProfile = new SlotProfile(resourceProfile, Collections.singletonList(tml4), Collections.singletonList(aidX));
-		SlotContext match = runMatching(slotProfile);
-
-		Assert.assertEquals(ssc4, match);
-	}
-
-	@Test
-	public void matchPreviousLocationNotAvailableAndAllOthersBlacklisted() {
-		HashSet<AllocationID> blacklisted = new HashSet<>(4);
-		blacklisted.add(aid1);
-		blacklisted.add(aid2);
-		blacklisted.add(aid3);
-		blacklisted.add(aid4);
-		SlotProfile slotProfile = new SlotProfile(resourceProfile, Collections.singletonList(tml4), Collections.singletonList(aidX), blacklisted);
-		SlotContext match = runMatching(slotProfile);
-
-		// there should be no valid option left and we expect null as return
-		Assert.assertNull(match);
-	}
-
-	@Test
-	public void matchPreviousLocationNotAvailableAndSomeOthersBlacklisted() {
-		HashSet<AllocationID> blacklisted = new HashSet<>(3);
-		blacklisted.add(aid1);
-		blacklisted.add(aid3);
-		blacklisted.add(aid4);
-		SlotProfile slotProfile = new SlotProfile(resourceProfile, Collections.singletonList(tml4), Collections.singletonList(aidX), blacklisted);
-		SlotContext match = runMatching(slotProfile);
-
-		// we expect that the candidate that is not blacklisted is returned
-		Assert.assertEquals(ssc2, match);
-	}
-
-	@Test
-	public void matchPreviousLocationAvailableButAlsoBlacklisted() {
-		HashSet<AllocationID> blacklisted = new HashSet<>(4);
-		blacklisted.add(aid1);
-		blacklisted.add(aid2);
-		blacklisted.add(aid3);
-		blacklisted.add(aid4);
-		SlotProfile slotProfile = new SlotProfile(resourceProfile, Collections.singletonList(tml3), Collections.singletonList(aid3), blacklisted);
-		SlotContext match = runMatching(slotProfile);
-
-		// available previous allocation should override blacklisting
-		Assert.assertEquals(ssc3, match);
-	}
-
-	private SlotContext runMatching(SlotProfile slotProfile) {
-		return schedulingStrategy.findMatchWithLocality(
-			slotProfile,
-			candidates::stream,
-			(candidate) -> candidate,
-			(candidate) -> true,
-			(candidate, locality) -> candidate);
-	}
-}
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/clusterframework/types/SlotSelectionStrategyTestBase.java b/flink-runtime/src/test/java/org/apache/flink/runtime/clusterframework/types/SlotSelectionStrategyTestBase.java
new file mode 100644
index 0000000..914f6e3
--- /dev/null
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/clusterframework/types/SlotSelectionStrategyTestBase.java
@@ -0,0 +1,79 @@
+/*
+ * 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.clusterframework.types;
+
+import org.apache.flink.runtime.executiongraph.utils.SimpleAckingTaskManagerGateway;
+import org.apache.flink.runtime.instance.SimpleSlotContext;
+import org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway;
+import org.apache.flink.runtime.jobmaster.SlotContext;
+import org.apache.flink.runtime.jobmaster.slotpool.SlotSelectionStrategy;
+import org.apache.flink.runtime.taskmanager.TaskManagerLocation;
+import org.apache.flink.util.TestLogger;
+
+import java.net.InetAddress;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Optional;
+import java.util.Set;
+
+public abstract class SlotSelectionStrategyTestBase extends TestLogger {
+
+	protected final ResourceProfile resourceProfile = new ResourceProfile(2, 1024);
+	protected final ResourceProfile biggerResourceProfile = new ResourceProfile(3, 1024);
+
+	protected final AllocationID aid1 = new AllocationID();
+	protected final AllocationID aid2 = new AllocationID();
+	protected final AllocationID aid3 = new AllocationID();
+	protected final AllocationID aid4 = new AllocationID();
+	protected final AllocationID aidX = new AllocationID();
+
+	protected final TaskManagerLocation tml1 = new TaskManagerLocation(new ResourceID("tm-1"), InetAddress.getLoopbackAddress(), 42);
+	protected final TaskManagerLocation tml2 = new TaskManagerLocation(new ResourceID("tm-2"), InetAddress.getLoopbackAddress(), 43);
+	protected final TaskManagerLocation tml3 = new TaskManagerLocation(new ResourceID("tm-3"), InetAddress.getLoopbackAddress(), 44);
+	protected final TaskManagerLocation tml4 = new TaskManagerLocation(new ResourceID("tm-4"), InetAddress.getLoopbackAddress(), 45);
+	protected final TaskManagerLocation tmlX = new TaskManagerLocation(new ResourceID("tm-X"), InetAddress.getLoopbackAddress(), 46);
+
+	protected final TaskManagerGateway taskManagerGateway = new SimpleAckingTaskManagerGateway();
+
+	protected final SimpleSlotContext ssc1 = new SimpleSlotContext(aid1, tml1, 1, taskManagerGateway, resourceProfile);
+	protected final SimpleSlotContext ssc2 = new SimpleSlotContext(aid2, tml2, 2, taskManagerGateway, biggerResourceProfile);
+	protected final SimpleSlotContext ssc3 = new SimpleSlotContext(aid3, tml3, 3, taskManagerGateway, resourceProfile);
+	protected final SimpleSlotContext ssc4 = new SimpleSlotContext(aid4, tml4, 4, taskManagerGateway, resourceProfile);
+
+	protected final Set<SlotContext> candidates = Collections.unmodifiableSet(createCandidates());
+
+	protected final SlotSelectionStrategy selectionStrategy;
+
+	public SlotSelectionStrategyTestBase(SlotSelectionStrategy slotSelectionStrategy) {
+		this.selectionStrategy = slotSelectionStrategy;
+	}
+
+	private Set<SlotContext> createCandidates() {
+		Set<SlotContext> candidates = new HashSet<>(4);
+		candidates.add(ssc1);
+		candidates.add(ssc2);
+		candidates.add(ssc3);
+		candidates.add(ssc4);
+		return candidates;
+	}
+
+	protected Optional<SlotSelectionStrategy.SlotInfoAndLocality> runMatching(SlotProfile slotProfile) {
+		return selectionStrategy.selectBestSlotForProfile(candidates, slotProfile);
+	}
+}
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ArchivedExecutionGraphTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ArchivedExecutionGraphTest.java
index db4da10..a646ac5 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ArchivedExecutionGraphTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ArchivedExecutionGraphTest.java
@@ -141,7 +141,7 @@ public class ArchivedExecutionGraphTest extends TestLogger {
 
 		runtimeGraph.setJsonPlan("{}");
 
-		runtimeGraph.getJobVertex(v2ID).getTaskVertices()[0].getCurrentExecutionAttempt().failAsync(new RuntimeException("This exception was thrown on purpose."));
+		runtimeGraph.getJobVertex(v2ID).getTaskVertices()[0].getCurrentExecutionAttempt().fail(new RuntimeException("This exception was thrown on purpose."));
 	}
 
 	@Test
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ConcurrentFailoverStrategyExecutionGraphTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ConcurrentFailoverStrategyExecutionGraphTest.java
index 2712005..b06dfe6 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ConcurrentFailoverStrategyExecutionGraphTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ConcurrentFailoverStrategyExecutionGraphTest.java
@@ -129,7 +129,7 @@ public class ConcurrentFailoverStrategyExecutionGraphTest extends TestLogger {
 		assertEquals(JobStatus.RUNNING, graph.getState());
 
 		// let one of the vertices fail - that triggers a local recovery action
-		vertex1.getCurrentExecutionAttempt().failSync(new Exception("test failure"));
+		vertex1.getCurrentExecutionAttempt().fail(new Exception("test failure"));
 		assertEquals(ExecutionState.FAILED, vertex1.getCurrentExecutionAttempt().getState());
 
 		// graph should still be running and the failover recovery action should be queued
@@ -198,7 +198,7 @@ public class ConcurrentFailoverStrategyExecutionGraphTest extends TestLogger {
 		assertEquals(JobStatus.RUNNING, graph.getState());
 
 		// let one of the vertices fail - that triggers a local recovery action
-		vertex1.getCurrentExecutionAttempt().failSync(new Exception("test failure"));
+		vertex1.getCurrentExecutionAttempt().fail(new Exception("test failure"));
 		assertEquals(ExecutionState.FAILED, vertex1.getCurrentExecutionAttempt().getState());
 
 		// graph should still be running and the failover recovery action should be queued
@@ -268,7 +268,7 @@ public class ConcurrentFailoverStrategyExecutionGraphTest extends TestLogger {
 		assertEquals(JobStatus.RUNNING, strategy.getFailoverRegion(vertex1).getState());
 
 		// let one of the vertices fail - that triggers a local recovery action
-		vertex2.getCurrentExecutionAttempt().failSync(new Exception("test failure"));
+		vertex2.getCurrentExecutionAttempt().fail(new Exception("test failure"));
 		assertEquals(ExecutionState.FAILED, vertex2.getCurrentExecutionAttempt().getState());
 		assertEquals(JobStatus.CANCELLING, strategy.getFailoverRegion(vertex2).getState());
 
@@ -316,7 +316,7 @@ public class ConcurrentFailoverStrategyExecutionGraphTest extends TestLogger {
 		strategy.setBlockerFuture(blocker);
 
 		// validate that a task failure then can be handled by the local recovery
-		vertex2.getCurrentExecutionAttempt().failSync(new Exception("test failure"));
+		vertex2.getCurrentExecutionAttempt().fail(new Exception("test failure"));
 
 		// let the local recovery action continue - this should recover the vertex2
 		blocker.complete(null);
@@ -451,7 +451,7 @@ public class ConcurrentFailoverStrategyExecutionGraphTest extends TestLogger {
 		}
 
 		// let one of the vertices fail - this should trigger the failing of not acknowledged pending checkpoints
-		vertex1.getCurrentExecutionAttempt().failSync(new Exception("test failure"));
+		vertex1.getCurrentExecutionAttempt().fail(new Exception("test failure"));
 
 		for (PendingCheckpoint pendingCheckpoint : oldPendingCheckpoints.values()) {
 			if (pendingCheckpoint.getCheckpointId() == checkpointToAcknowledge) {
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphCoLocationRestartTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphCoLocationRestartTest.java
index 42e5cb4..b5478e6 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphCoLocationRestartTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphCoLocationRestartTest.java
@@ -28,7 +28,6 @@ import org.apache.flink.runtime.jobmanager.scheduler.SlotSharingGroup;
 import org.apache.flink.runtime.jobmaster.slotpool.SlotProvider;
 import org.apache.flink.util.FlinkException;
 
-import org.junit.ClassRule;
 import org.junit.Test;
 
 import java.util.function.Predicate;
@@ -47,13 +46,6 @@ public class ExecutionGraphCoLocationRestartTest extends SchedulerTestBase {
 
 	private static final int NUM_TASKS = 31;
 
-	@ClassRule
-	public static final TestingComponentMainThreadExecutor.Resource EXECUTOR_RESOURCE =
-		new TestingComponentMainThreadExecutor.Resource();
-
-	private final TestingComponentMainThreadExecutor testMainThreadUtil =
-		EXECUTOR_RESOURCE.getComponentMainThreadTestExecutor();
-
 	@Test
 	public void testConstraintsAfterRestart() throws Exception {
 
@@ -82,14 +74,11 @@ public class ExecutionGraphCoLocationRestartTest extends SchedulerTestBase {
 
 		// enable the queued scheduling for the slot pool
 		eg.setQueuedSchedulingAllowed(true);
-		eg.start(testMainThreadUtil.getMainThreadExecutor());
+		eg.start(TestingComponentMainThreadExecutorServiceAdapter.forMainThread());
 
-		testMainThreadUtil.execute(() -> {
+		assertEquals(JobStatus.CREATED, eg.getState());
 
-			assertEquals(JobStatus.CREATED, eg.getState());
-
-			eg.scheduleForExecution();
-		});
+		eg.scheduleForExecution();
 
 		Predicate<AccessExecution> isDeploying = ExecutionGraphTestUtils.isInExecutionState(ExecutionState.DEPLOYING);
 		ExecutionGraphTestUtils.waitForAllExecutionsPredicate(
@@ -97,21 +86,18 @@ public class ExecutionGraphCoLocationRestartTest extends SchedulerTestBase {
 			isDeploying,
 			timeout);
 
-		testMainThreadUtil.execute(() -> {
-
-			assertEquals(JobStatus.RUNNING, eg.getState());
+		assertEquals(JobStatus.RUNNING, eg.getState());
 
-			//sanity checks
-			validateConstraints(eg);
+		//sanity checks
+		validateConstraints(eg);
 
-			eg.getAllExecutionVertices().iterator().next().fail(new FlinkException("Test exception"));
+		eg.getAllExecutionVertices().iterator().next().fail(new FlinkException("Test exception"));
 
-			assertEquals(JobStatus.FAILING, eg.getState());
+		assertEquals(JobStatus.FAILING, eg.getState());
 
-			for (ExecutionVertex vertex : eg.getAllExecutionVertices()) {
-				vertex.getCurrentExecutionAttempt().cancelingComplete();
-			}
-		});
+		for (ExecutionVertex vertex : eg.getAllExecutionVertices()) {
+			vertex.getCurrentExecutionAttempt().cancelingComplete();
+		}
 
 		// wait until we have restarted
 		ExecutionGraphTestUtils.waitUntilJobStatus(eg, JobStatus.RUNNING, timeout);
@@ -121,15 +107,12 @@ public class ExecutionGraphCoLocationRestartTest extends SchedulerTestBase {
 			isDeploying,
 			timeout);
 
-		testMainThreadUtil.execute(() -> {
-
-			//checking execution vertex properties
-			validateConstraints(eg);
+		//checking execution vertex properties
+		validateConstraints(eg);
 
-			ExecutionGraphTestUtils.finishAllVertices(eg);
+		ExecutionGraphTestUtils.finishAllVertices(eg);
 
-			assertThat(eg.getState(), is(FINISHED));
-		});
+		assertThat(eg.getState(), is(FINISHED));
 	}
 
 	private void validateConstraints(ExecutionGraph eg) {
@@ -142,6 +125,5 @@ public class ExecutionGraphCoLocationRestartTest extends SchedulerTestBase {
 			assertThat(constr1.isAssigned(), is(true));
 			assertThat(constr1.getLocation(), equalTo(constr2.getLocation()));
 		}
-
 	}
 }
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphDeploymentTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphDeploymentTest.java
index 704d70c..7e1eee8 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphDeploymentTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphDeploymentTest.java
@@ -293,7 +293,7 @@ public class ExecutionGraphDeploymentTest extends TestLogger {
 			Map<ExecutionAttemptID, Execution> executions = setupExecution(v1, 7, v2, 6).f1;
 
 			for (Execution e : executions.values()) {
-				e.failAsync(null);
+				e.fail(null);
 			}
 
 			assertEquals(0, executions.size());
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphRestartTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphRestartTest.java
index e9cc0e8..a5477fe 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphRestartTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionGraphRestartTest.java
@@ -345,7 +345,7 @@ public class ExecutionGraphRestartTest extends TestLogger {
 
 		finishedExecution.markFinished();
 
-		failedExecution.failSync(new Exception("Test Exception"));
+		failedExecution.fail(new Exception("Test Exception"));
 		failedExecution.cancelingComplete();
 
 		assertEquals(JobStatus.RUNNING, eg.getState());
@@ -357,7 +357,7 @@ public class ExecutionGraphRestartTest extends TestLogger {
 		}
 
 		// fail old finished execution, this should not affect the execution
-		finishedExecution.failSync(new Exception("This should have no effect"));
+		finishedExecution.fail(new Exception("This should have no effect"));
 
 		for (ExecutionVertex vertex: eg.getAllExecutionVertices()) {
 			vertex.getCurrentExecutionAttempt().markFinished();
@@ -405,7 +405,7 @@ public class ExecutionGraphRestartTest extends TestLogger {
 		eg.cancel();
 
 		for (ExecutionVertex v : eg.getAllExecutionVertices()) {
-			v.getCurrentExecutionAttempt().failSync(new Exception("Test Exception"));
+			v.getCurrentExecutionAttempt().fail(new Exception("Test Exception"));
 		}
 
 		assertEquals(JobStatus.CANCELED, eg.getTerminationFuture().get());
@@ -542,8 +542,8 @@ public class ExecutionGraphRestartTest extends TestLogger {
 		final Execution last = vertex.getTaskVertices()[vertex.getParallelism() - 1].getCurrentExecutionAttempt();
 
 		// Have two executions fail
-		first.failSync(new Exception("intended test failure 1"));
-		last.failSync(new Exception("intended test failure 2"));
+		first.fail(new Exception("intended test failure 1"));
+		last.fail(new Exception("intended test failure 2"));
 
 		Assert.assertEquals(JobStatus.FAILING, eg.getState());
 
@@ -645,7 +645,7 @@ public class ExecutionGraphRestartTest extends TestLogger {
 		switchToRunning(eg);
 
 		// fail into 'RESTARTING'
-		eg.getAllExecutionVertices().iterator().next().getCurrentExecutionAttempt().failAsync(
+		eg.getAllExecutionVertices().iterator().next().getCurrentExecutionAttempt().fail(
 			new Exception("intended test failure"));
 
 		assertEquals(JobStatus.FAILING, eg.getState());
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionTest.java
index a23adc1..4881384 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionTest.java
@@ -52,8 +52,6 @@ import java.util.Collections;
 import java.util.Set;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
 
 import static org.hamcrest.Matchers.containsInAnyOrder;
 import static org.hamcrest.Matchers.equalTo;
@@ -478,37 +476,31 @@ public class ExecutionTest extends TestLogger {
 			}
 		);
 
-		final ExecutorService executorService = Executors.newFixedThreadPool(1);
+		slotRequestIdFuture.thenAcceptAsync(
+			(SlotRequestId slotRequestId) -> {
+				final SingleLogicalSlot singleLogicalSlot = ExecutionGraphSchedulingTest.createSingleLogicalSlot(
+					slotOwner,
+					taskManagerGateway,
+					slotRequestId);
+				slotProvider.complete(slotRequestId, singleLogicalSlot);
+			},
+			testMainThreadUtil.getMainThreadExecutor());
+
+		final CompletableFuture<Void> schedulingFuture = testMainThreadUtil.execute(
+			() -> execution.scheduleForExecution(
+				slotProvider,
+				false,
+				LocationPreferenceConstraint.ANY,
+				Collections.emptySet()));
 
 		try {
-			slotRequestIdFuture.thenAcceptAsync(
-				(SlotRequestId slotRequestId) -> {
-					final SingleLogicalSlot singleLogicalSlot = ExecutionGraphSchedulingTest.createSingleLogicalSlot(
-						slotOwner,
-						taskManagerGateway,
-						slotRequestId);
-					slotProvider.complete(slotRequestId, singleLogicalSlot);
-				},
-				executorService);
-
-			final CompletableFuture<Void> schedulingFuture = testMainThreadUtil.execute(
-				() -> execution.scheduleForExecution(
-					slotProvider,
-					false,
-					LocationPreferenceConstraint.ANY,
-					Collections.emptySet()));
-
-			try {
-				schedulingFuture.get();
-				// cancel the execution in case we could schedule the execution
-				testMainThreadUtil.execute(execution::cancel);
-			} catch (ExecutionException ignored) {
-			}
-
-			assertThat(returnedSlotFuture.get(), is(equalTo(slotRequestIdFuture.get())));
-		} finally {
-			executorService.shutdownNow();
+			schedulingFuture.get();
+			// cancel the execution in case we could schedule the execution
+			testMainThreadUtil.execute(execution::cancel);
+		} catch (ExecutionException ignored) {
 		}
+
+		assertThat(returnedSlotFuture.get(), is(equalTo(slotRequestIdFuture.get())));
 	}
 
 	@Nonnull
@@ -555,8 +547,8 @@ public class ExecutionTest extends TestLogger {
 		}
 
 		@Override
-		public CompletableFuture<Boolean> returnAllocatedSlot(LogicalSlot logicalSlot) {
-			return CompletableFuture.completedFuture(returnedSlot.complete(logicalSlot));
+		public void returnLogicalSlot(LogicalSlot logicalSlot) {
+			returnedSlot.complete(logicalSlot);
 		}
 	}
 }
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionVertexCancelTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionVertexCancelTest.java
index 5582f09..65c8c0b 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionVertexCancelTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionVertexCancelTest.java
@@ -40,7 +40,6 @@ import org.junit.Test;
 
 import java.io.IOException;
 import java.util.Collections;
-import java.util.concurrent.CompletableFuture;
 
 import scala.concurrent.ExecutionContext;
 
@@ -315,11 +314,7 @@ public class ExecutionVertexCancelTest extends TestLogger {
 			// scheduling after being canceled should be tolerated (no exception) because
 			// it can occur as the result of races
 			{
-				vertex.scheduleForExecution(
-					new TestingSlotProvider(ignore -> new CompletableFuture<>()),
-					false,
-					LocationPreferenceConstraint.ALL,
-					Collections.emptySet());
+				vertex.scheduleForExecution(new ProgrammedSlotProvider(1), false, LocationPreferenceConstraint.ALL, Collections.emptySet());
 
 				assertEquals(ExecutionState.CANCELED, vertex.getExecutionState());
 			}
@@ -356,18 +351,12 @@ public class ExecutionVertexCancelTest extends TestLogger {
 				ExecutionVertex vertex = new ExecutionVertex(ejv, 0, new IntermediateResult[0],
 						AkkaUtils.getDefaultTimeout());
 				setVertexState(vertex, ExecutionState.CANCELING);
-
-				vertex.scheduleForExecution(
-					new TestingSlotProvider(ignore -> new CompletableFuture<>()),
-					false,
-					LocationPreferenceConstraint.ALL,
-					Collections.emptySet());
+				vertex.scheduleForExecution(new ProgrammedSlotProvider(1), false, LocationPreferenceConstraint.ALL, Collections.emptySet());
 			}
 			catch (Exception e) {
 				fail("should not throw an exception");
 			}
 
-
 			// deploying while in canceling state is illegal (should immediately go to canceled)
 			try {
 				ExecutionVertex vertex = new ExecutionVertex(ejv, 0, new IntermediateResult[0],
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionVertexSchedulingTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionVertexSchedulingTest.java
index 0bc53d4..abb58c7 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionVertexSchedulingTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ExecutionVertexSchedulingTest.java
@@ -28,6 +28,7 @@ import org.apache.flink.runtime.jobmanager.scheduler.LocationPreferenceConstrain
 import org.apache.flink.runtime.jobmanager.slots.ActorTaskManagerGateway;
 import org.apache.flink.runtime.jobmaster.LogicalSlot;
 import org.apache.flink.runtime.testingUtils.TestingUtils;
+import org.apache.flink.util.TestLogger;
 
 import org.junit.Test;
 
@@ -40,7 +41,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-public class ExecutionVertexSchedulingTest {
+public class ExecutionVertexSchedulingTest extends TestLogger {
 
 	@Test
 	public void testSlotReleasedWhenScheduledImmediately() {
@@ -61,11 +62,7 @@ public class ExecutionVertexSchedulingTest {
 
 			assertEquals(ExecutionState.CREATED, vertex.getExecutionState());
 			// try to deploy to the slot
-			vertex.scheduleForExecution(
-				new TestingSlotProvider(ignore -> future),
-				false,
-				LocationPreferenceConstraint.ALL,
-				Collections.emptySet());
+			vertex.scheduleForExecution(new TestingSlotProvider((i) -> future), false, LocationPreferenceConstraint.ALL, Collections.emptySet());
 
 			// will have failed
 			assertEquals(ExecutionState.FAILED, vertex.getExecutionState());
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/FailoverRegionTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/FailoverRegionTest.java
index 07644e2..bddb335 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/FailoverRegionTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/FailoverRegionTest.java
@@ -74,7 +74,7 @@ public class FailoverRegionTest extends TestLogger {
 
 		assertEquals(JobStatus.RUNNING, strategy.getFailoverRegion(ev).getState());
 
-		ev.getCurrentExecutionAttempt().failAsync(new Exception("Test Exception"));
+		ev.getCurrentExecutionAttempt().fail(new Exception("Test Exception"));
 		assertEquals(JobStatus.CANCELLING, strategy.getFailoverRegion(ev).getState());
 
 		for (ExecutionVertex evs : eg.getAllExecutionVertices()) {
@@ -159,7 +159,7 @@ public class FailoverRegionTest extends TestLogger {
 		assertEquals(JobStatus.RUNNING, strategy.getFailoverRegion(ev11).getState());
 
 		ev21.scheduleForExecution(slotProvider, true, LocationPreferenceConstraint.ALL, Collections.emptySet());
-		ev21.getCurrentExecutionAttempt().failAsync(new Exception("New fail"));
+		ev21.getCurrentExecutionAttempt().fail(new Exception("New fail"));
 		assertEquals(JobStatus.CANCELLING, strategy.getFailoverRegion(ev11).getState());
 		assertEquals(JobStatus.RUNNING, strategy.getFailoverRegion(ev22).getState());
 		assertEquals(JobStatus.RUNNING, strategy.getFailoverRegion(ev31).getState());
@@ -180,7 +180,7 @@ public class FailoverRegionTest extends TestLogger {
 		waitUntilExecutionState(ev31.getCurrentExecutionAttempt(), ExecutionState.DEPLOYING, 2000);
 		waitUntilExecutionState(ev32.getCurrentExecutionAttempt(), ExecutionState.DEPLOYING, 2000);
 
-		ev31.getCurrentExecutionAttempt().failAsync(new Exception("New fail"));
+		ev31.getCurrentExecutionAttempt().fail(new Exception("New fail"));
 		assertEquals(JobStatus.RUNNING, strategy.getFailoverRegion(ev11).getState());
 		assertEquals(JobStatus.RUNNING, strategy.getFailoverRegion(ev22).getState());
 		assertEquals(JobStatus.CANCELLING, strategy.getFailoverRegion(ev31).getState());
@@ -276,8 +276,8 @@ public class FailoverRegionTest extends TestLogger {
 		assertEquals(JobStatus.RUNNING, strategy.getFailoverRegion(ev11).getState());
 		assertEquals(JobStatus.RUNNING, strategy.getFailoverRegion(ev31).getState());
 
-		ev11.getCurrentExecutionAttempt().failAsync(new Exception("new fail"));
-		ev31.getCurrentExecutionAttempt().failAsync(new Exception("new fail"));
+		ev11.getCurrentExecutionAttempt().fail(new Exception("new fail"));
+		ev31.getCurrentExecutionAttempt().fail(new Exception("new fail"));
 		assertEquals(JobStatus.CANCELLING, strategy.getFailoverRegion(ev11).getState());
 		assertEquals(JobStatus.CANCELLING, strategy.getFailoverRegion(ev31).getState());
 
@@ -344,7 +344,7 @@ public class FailoverRegionTest extends TestLogger {
 
 		ExecutionVertex ev11 = eg.getJobVertex(v2.getID()).getTaskVertices()[0];
 		ExecutionVertex ev21 = eg.getJobVertex(v2.getID()).getTaskVertices()[0];
-		ev21.getCurrentExecutionAttempt().failAsync(new Exception("Fail with v1"));
+		ev21.getCurrentExecutionAttempt().fail(new Exception("Fail with v1"));
 
 		assertEquals(JobStatus.CANCELLING, strategy.getFailoverRegion(ev21).getState());
 		assertEquals(JobStatus.CANCELLING, strategy.getFailoverRegion(ev11).getState());
@@ -365,11 +365,11 @@ public class FailoverRegionTest extends TestLogger {
 		ev1.getCurrentExecutionAttempt().switchToRunning();
 		assertEquals(JobStatus.RUNNING, strategy.getFailoverRegion(ev1).getState());
 
-		ev1.getCurrentExecutionAttempt().failAsync(new Exception("new fail"));
+		ev1.getCurrentExecutionAttempt().fail(new Exception("new fail"));
 		assertEquals(JobStatus.CANCELLING, strategy.getFailoverRegion(ev1).getState());
 
 		ExecutionVertex ev2 = iter.next();
-		ev2.getCurrentExecutionAttempt().failAsync(new Exception("new fail"));
+		ev2.getCurrentExecutionAttempt().fail(new Exception("new fail"));
 		assertEquals(JobStatus.RUNNING, eg.getState());
 		assertEquals(JobStatus.CANCELLING, strategy.getFailoverRegion(ev1).getState());
 	}
@@ -388,7 +388,7 @@ public class FailoverRegionTest extends TestLogger {
 		ExecutionVertex ev1 = iter.next();
 		assertEquals(JobStatus.RUNNING, strategy.getFailoverRegion(ev1).getState());
 
-		ev1.getCurrentExecutionAttempt().failAsync(new Exception("new fail"));
+		ev1.getCurrentExecutionAttempt().fail(new Exception("new fail"));
 		assertEquals(JobStatus.CANCELLING, strategy.getFailoverRegion(ev1).getState());
 
 		for (ExecutionVertex evs : eg.getAllExecutionVertices()) {
@@ -396,7 +396,7 @@ public class FailoverRegionTest extends TestLogger {
 		}
 		assertEquals(JobStatus.RUNNING, strategy.getFailoverRegion(ev1).getState());
 
-		ev1.getCurrentExecutionAttempt().failAsync(new Exception("new fail"));
+		ev1.getCurrentExecutionAttempt().fail(new Exception("new fail"));
 		assertEquals(JobStatus.CANCELLING, strategy.getFailoverRegion(ev1).getState());
 	}
 
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/FinalizeOnMasterTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/FinalizeOnMasterTest.java
index 43ae680..a2b1c58 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/FinalizeOnMasterTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/FinalizeOnMasterTest.java
@@ -86,7 +86,7 @@ public class FinalizeOnMasterTest extends TestLogger {
 
 		// fail the execution
 		final Execution exec = eg.getJobVertex(vertex.getID()).getTaskVertices()[0].getCurrentExecutionAttempt();
-		exec.failAsync(new Exception("test"));
+		exec.fail(new Exception("test"));
 
 		assertEquals(JobStatus.FAILED, eg.waitUntilTerminal());
 
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/GlobalModVersionTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/GlobalModVersionTest.java
index bb9498c..26d71fd 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/GlobalModVersionTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/GlobalModVersionTest.java
@@ -80,7 +80,7 @@ public class GlobalModVersionTest extends TestLogger {
 		}
 
 		// let a vertex fail
-		testVertex.getCurrentExecutionAttempt().failAsync(new Exception("test exception"));
+		testVertex.getCurrentExecutionAttempt().fail(new Exception("test exception"));
 
 		// all cancellations are done now
 		for (ExecutionVertex v : graph.getVerticesTopologically().iterator().next().getTaskVertices()) {
@@ -134,7 +134,7 @@ public class GlobalModVersionTest extends TestLogger {
 		}
 
 		// let a vertex fail
-		testVertex.getCurrentExecutionAttempt().failAsync(new Exception("test exception"));
+		testVertex.getCurrentExecutionAttempt().fail(new Exception("test exception"));
 
 		// all cancellations are done now
 		for (ExecutionVertex v : graph.getVerticesTopologically().iterator().next().getTaskVertices()) {
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ProgrammedSlotProvider.java b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ProgrammedSlotProvider.java
index daaf63b..7c5a848 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ProgrammedSlotProvider.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/ProgrammedSlotProvider.java
@@ -20,14 +20,15 @@ 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.concurrent.ComponentMainThreadExecutor;
 import org.apache.flink.runtime.instance.SlotSharingGroupId;
 import org.apache.flink.runtime.jobgraph.JobVertexID;
 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.runtime.messages.Acknowledge;
+import org.apache.flink.runtime.jobmaster.slotpool.Scheduler;
 
+import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
 import java.util.Collections;
@@ -44,7 +45,7 @@ import static org.apache.flink.util.Preconditions.checkNotNull;
  * A slot provider where one can pre-set the slot futures for tasks based on
  * vertex ID and subtask index.
  */
-class ProgrammedSlotProvider implements SlotProvider {
+class ProgrammedSlotProvider implements Scheduler {
 
 	private final Map<JobVertexID, CompletableFuture<LogicalSlot>[]> slotFutures = new HashMap<>();
 
@@ -115,8 +116,8 @@ class ProgrammedSlotProvider implements SlotProvider {
 	public CompletableFuture<LogicalSlot> allocateSlot(
 			SlotRequestId slotRequestId,
 			ScheduledUnit task,
-			boolean allowQueued,
 			SlotProfile slotProfile,
+			boolean allowQueued,
 			Time allocationTimeout) {
 		JobVertexID vertexId = task.getTaskToExecute().getVertex().getJobvertexId();
 		int subtask = task.getTaskToExecute().getParallelSubtaskIndex();
@@ -136,8 +137,25 @@ class ProgrammedSlotProvider implements SlotProvider {
 	}
 
 	@Override
-	public CompletableFuture<Acknowledge> cancelSlotRequest(SlotRequestId slotRequestId, @Nullable SlotSharingGroupId slotSharingGroupId, Throwable cause) {
+	public void cancelSlotRequest(
+			SlotRequestId slotRequestId,
+			@Nullable SlotSharingGroupId slotSharingGroupId,
+			Throwable cause) {
 		canceledSlotRequests.add(slotRequestId);
-		return CompletableFuture.completedFuture(Acknowledge.get());
+	}
+
+	@Override
+	public void start(@Nonnull ComponentMainThreadExecutor mainThreadExecutor) {
+
+	}
+
+	@Override
+	public boolean requiresPreviousExecutionGraphAllocations() {
+		return false;
+	}
+
+	@Override
+	public void returnLogicalSlot(LogicalSlot logicalSlot) {
+		throw new UnsupportedOperationException();
 	}
 }
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/TestingComponentMainThreadExecutor.java b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/TestingComponentMainThreadExecutor.java
index 907648e..93131a3 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/TestingComponentMainThreadExecutor.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/TestingComponentMainThreadExecutor.java
@@ -77,9 +77,18 @@ public class TestingComponentMainThreadExecutor {
 	 */
 	public static class Resource extends ExternalResource {
 
+		private long shutdownTimeoutMillis;
 		private TestingComponentMainThreadExecutor componentMainThreadTestExecutor;
 		private ScheduledExecutorService innerExecutorService;
 
+		public Resource() {
+			this(500L);
+		}
+
+		public Resource(long shutdownTimeoutMillis) {
+			this.shutdownTimeoutMillis = shutdownTimeoutMillis;
+		}
+
 		@Override
 		protected void before() {
 			this.innerExecutorService = Executors.newSingleThreadScheduledExecutor();
@@ -90,7 +99,7 @@ public class TestingComponentMainThreadExecutor {
 
 		@Override
 		protected void after() {
-			ExecutorUtils.gracefulShutdown(5000, TimeUnit.MILLISECONDS, innerExecutorService);
+			ExecutorUtils.gracefulShutdown(shutdownTimeoutMillis, TimeUnit.MILLISECONDS, innerExecutorService);
 		}
 
 		public TestingComponentMainThreadExecutor getComponentMainThreadTestExecutor() {
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/TestingSlotProvider.java b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/TestingSlotProvider.java
index 9943441..b0ca786 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/TestingSlotProvider.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/TestingSlotProvider.java
@@ -25,7 +25,6 @@ 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.runtime.messages.Acknowledge;
 import org.apache.flink.util.Preconditions;
 
 import javax.annotation.Nullable;
@@ -57,7 +56,7 @@ public final class TestingSlotProvider implements SlotProvider {
 	}
 
 	@Override
-	public CompletableFuture<LogicalSlot> allocateSlot(SlotRequestId slotRequestId, ScheduledUnit task, boolean allowQueued, SlotProfile slotProfile, Time timeout) {
+	public CompletableFuture<LogicalSlot> allocateSlot(SlotRequestId slotRequestId, ScheduledUnit task, SlotProfile slotProfile, boolean allowQueued, Time timeout) {
 		Preconditions.checkState(!slotFutures.containsKey(slotRequestId));
 		final CompletableFuture<LogicalSlot> slotFuture = slotFutureCreator.apply(slotRequestId);
 
@@ -67,13 +66,11 @@ public final class TestingSlotProvider implements SlotProvider {
 	}
 
 	@Override
-	public CompletableFuture<Acknowledge> cancelSlotRequest(SlotRequestId slotRequestId, @Nullable SlotSharingGroupId slotSharingGroupId, Throwable cause) {
+	public void cancelSlotRequest(SlotRequestId slotRequestId, @Nullable SlotSharingGroupId slotSharingGroupId, Throwable cause) {
 		final CompletableFuture<LogicalSlot> slotFuture = slotFutures.remove(slotRequestId);
 		slotFuture.cancel(false);
 
 		slotCanceller.accept(slotRequestId);
-
-		return CompletableFuture.completedFuture(Acknowledge.get());
 	}
 
 	public void complete(SlotRequestId slotRequestId, LogicalSlot logicalSlot) {
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/utils/SimpleSlotProvider.java b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/utils/SimpleSlotProvider.java
index 7d11d37..007684d 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/utils/SimpleSlotProvider.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/executiongraph/utils/SimpleSlotProvider.java
@@ -36,9 +36,8 @@ import org.apache.flink.runtime.jobmaster.SlotContext;
 import org.apache.flink.runtime.jobmaster.SlotOwner;
 import org.apache.flink.runtime.jobmaster.SlotRequestId;
 import org.apache.flink.runtime.jobmaster.slotpool.SlotProvider;
-import org.apache.flink.runtime.messages.Acknowledge;
 import org.apache.flink.runtime.taskmanager.TaskManagerLocation;
-import org.apache.flink.util.FlinkException;
+import org.apache.flink.util.FlinkRuntimeException;
 import org.apache.flink.util.Preconditions;
 
 import javax.annotation.Nullable;
@@ -88,8 +87,8 @@ public class SimpleSlotProvider implements SlotProvider, SlotOwner {
 	public CompletableFuture<LogicalSlot> allocateSlot(
 			SlotRequestId slotRequestId,
 			ScheduledUnit task,
-			boolean allowQueued,
 			SlotProfile slotProfile,
+			boolean allowQueued,
 			Time allocationTimeout) {
 		final SlotContext slot;
 
@@ -111,21 +110,20 @@ public class SimpleSlotProvider implements SlotProvider, SlotOwner {
 	}
 
 	@Override
-	public CompletableFuture<Acknowledge> cancelSlotRequest(SlotRequestId slotRequestId, @Nullable SlotSharingGroupId slotSharingGroupId, Throwable cause) {
+	public void cancelSlotRequest(SlotRequestId slotRequestId, @Nullable SlotSharingGroupId slotSharingGroupId, Throwable cause) {
 		synchronized (lock) {
 			final SlotContext slotContext = allocatedSlots.remove(slotRequestId);
 
 			if (slotContext != null) {
 				slots.add(slotContext);
-				return CompletableFuture.completedFuture(Acknowledge.get());
 			} else {
-				return FutureUtils.completedExceptionally(new FlinkException("Unknown slot request id " + slotRequestId + '.'));
+				throw new FlinkRuntimeException("Unknown slot request id " + slotRequestId + '.');
 			}
 		}
 	}
 
 	@Override
-	public CompletableFuture<Boolean> returnAllocatedSlot(LogicalSlot logicalSlot) {
+	public void returnLogicalSlot(LogicalSlot logicalSlot) {
 		Preconditions.checkArgument(logicalSlot instanceof Slot);
 
 		final Slot slot = ((Slot) logicalSlot);
@@ -134,7 +132,6 @@ public class SimpleSlotProvider implements SlotProvider, SlotOwner {
 			slots.add(slot.getSlotContext());
 			allocatedSlots.remove(logicalSlot.getSlotRequestId());
 		}
-		return CompletableFuture.completedFuture(true);
 	}
 
 	public int getNumberOfAvailableSlots() {
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/instance/InstanceTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/instance/InstanceTest.java
index 6d7d1ae..0c2b7c1 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/instance/InstanceTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/instance/InstanceTest.java
@@ -28,7 +28,6 @@ import java.lang.reflect.Method;
 import java.net.InetAddress;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
@@ -76,7 +75,7 @@ public class InstanceTest {
 			// no more slots
 			assertNull(instance.allocateSimpleSlot());
 			try {
-				instance.returnAllocatedSlot(slot2);
+				instance.returnLogicalSlot(slot2);
 				fail("instance accepted a non-cancelled slot.");
 			}
 			catch (IllegalArgumentException e) {
@@ -92,10 +91,10 @@ public class InstanceTest {
 			assertEquals(4, instance.getNumberOfAvailableSlots());
 			assertEquals(0, instance.getNumberOfAllocatedSlots());
 
-			assertFalse(instance.returnAllocatedSlot(slot1).get());
-			assertFalse(instance.returnAllocatedSlot(slot2).get());
-			assertFalse(instance.returnAllocatedSlot(slot3).get());
-			assertFalse(instance.returnAllocatedSlot(slot4).get());
+			instance.returnLogicalSlot(slot1);
+			instance.returnLogicalSlot(slot2);
+			instance.returnLogicalSlot(slot3);
+			instance.returnLogicalSlot(slot4);
 
 			assertEquals(4, instance.getNumberOfAvailableSlots());
 			assertEquals(0, instance.getNumberOfAllocatedSlots());
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmanager/scheduler/ScheduleWithCoLocationHintTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmanager/scheduler/ScheduleWithCoLocationHintTest.java
index eaa85e3..eccccf7 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmanager/scheduler/ScheduleWithCoLocationHintTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmanager/scheduler/ScheduleWithCoLocationHintTest.java
@@ -536,6 +536,6 @@ public class ScheduleWithCoLocationHintTest extends SchedulerTestBase {
 	}
 
 	private static SlotProfile slotProfileForLocation(TaskManagerLocation location) {
-		return new SlotProfile(ResourceProfile.UNKNOWN, Collections.singletonList(location), Collections.emptyList());
+		return new SlotProfile(ResourceProfile.UNKNOWN, Collections.singletonList(location), Collections.emptySet());
 	}
 }
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmanager/scheduler/SchedulerIsolatedTasksTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmanager/scheduler/SchedulerIsolatedTasksTest.java
index 4fbb7f1..ad2810f 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmanager/scheduler/SchedulerIsolatedTasksTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmanager/scheduler/SchedulerIsolatedTasksTest.java
@@ -111,16 +111,13 @@ public class SchedulerIsolatedTasksTest extends SchedulerTestBase {
 
 		assertEquals(5, testingSlotProvider.getNumberOfAvailableSlots());
 	}
-	
+
 	@Test
 	public void testScheduleQueueing() throws Exception {
 		final int NUM_INSTANCES = 50;
 		final int NUM_SLOTS_PER_INSTANCE = 3;
 		final int NUM_TASKS_TO_SCHEDULE = 2000;
 
-		// note: since this test asynchronously releases slots, the executor needs release workers.
-		// doing the release call synchronous can lead to a deadlock
-
 		for (int i = 0; i < NUM_INSTANCES; i++) {
 			testingSlotProvider.addTaskManager((int) (Math.random() * NUM_SLOTS_PER_INSTANCE) + 1);
 		}
@@ -136,36 +133,6 @@ public class SchedulerIsolatedTasksTest extends SchedulerTestBase {
 		// flag to track errors in the concurrent thread
 		final AtomicBoolean errored = new AtomicBoolean(false);
 
-		// thread to asynchronously release slots
-		Runnable disposer = new Runnable() {
-
-			@Override
-			public void run() {
-				try {
-					int recycled = 0;
-					while (recycled < NUM_TASKS_TO_SCHEDULE) {
-						synchronized (toRelease) {
-							while (toRelease.isEmpty()) {
-								toRelease.wait();
-							}
-
-							Iterator<LogicalSlot> iter = toRelease.iterator();
-							LogicalSlot next = iter.next();
-							iter.remove();
-
-							next.releaseSlot();
-							recycled++;
-						}
-					}
-				} catch (Throwable t) {
-					errored.set(true);
-				}
-			}
-		};
-
-		Thread disposeThread = new Thread(disposer);
-		disposeThread.start();
-
 		for (int i = 0; i < NUM_TASKS_TO_SCHEDULE; i++) {
 			CompletableFuture<LogicalSlot> future = testingSlotProvider.allocateSlot(new ScheduledUnit(getDummyTask()), true, SlotProfile.noRequirements(), TestingUtils.infiniteTime());
 			future.thenAcceptAsync(
@@ -179,7 +146,25 @@ public class SchedulerIsolatedTasksTest extends SchedulerTestBase {
 			allAllocatedSlots.add(future);
 		}
 
-		disposeThread.join();
+		try {
+			int recycled = 0;
+			while (recycled < NUM_TASKS_TO_SCHEDULE) {
+				synchronized (toRelease) {
+					while (toRelease.isEmpty()) {
+						toRelease.wait();
+					}
+
+					Iterator<LogicalSlot> iter = toRelease.iterator();
+					LogicalSlot next = iter.next();
+					iter.remove();
+
+					next.releaseSlot();
+					recycled++;
+				}
+			}
+		} catch (Throwable t) {
+			errored.set(true);
+		}
 
 		assertFalse("The slot releasing thread caused an error.", errored.get());
 
@@ -301,6 +286,6 @@ public class SchedulerIsolatedTasksTest extends SchedulerTestBase {
 	}
 
 	private static SlotProfile slotProfileForLocation(TaskManagerLocation... location) {
-		return new SlotProfile(ResourceProfile.UNKNOWN, Arrays.asList(location), Collections.emptyList());
+		return new SlotProfile(ResourceProfile.UNKNOWN, Arrays.asList(location), Collections.emptySet());
 	}
 }
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmanager/scheduler/SchedulerTestBase.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmanager/scheduler/SchedulerTestBase.java
index f62f89f..fca13aa 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmanager/scheduler/SchedulerTestBase.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmanager/scheduler/SchedulerTestBase.java
@@ -24,6 +24,8 @@ import org.apache.flink.runtime.clusterframework.types.AllocationID;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
 import org.apache.flink.runtime.clusterframework.types.ResourceProfile;
 import org.apache.flink.runtime.clusterframework.types.SlotProfile;
+import org.apache.flink.runtime.concurrent.ComponentMainThreadExecutor;
+import org.apache.flink.runtime.executiongraph.TestingComponentMainThreadExecutorServiceAdapter;
 import org.apache.flink.runtime.executiongraph.utils.SimpleAckingTaskManagerGateway;
 import org.apache.flink.runtime.instance.SlotSharingGroupId;
 import org.apache.flink.runtime.jobgraph.JobVertexID;
@@ -31,31 +33,30 @@ import org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway;
 import org.apache.flink.runtime.jobmaster.JobMasterId;
 import org.apache.flink.runtime.jobmaster.LogicalSlot;
 import org.apache.flink.runtime.jobmaster.SlotRequestId;
-import org.apache.flink.runtime.jobmaster.slotpool.LocationPreferenceSchedulingStrategy;
-import org.apache.flink.runtime.jobmaster.slotpool.SchedulingStrategy;
+import org.apache.flink.runtime.jobmaster.slotpool.LocationPreferenceSlotSelectionStrategy;
+import org.apache.flink.runtime.jobmaster.slotpool.SchedulerImpl;
 import org.apache.flink.runtime.jobmaster.slotpool.SlotPool;
-import org.apache.flink.runtime.jobmaster.slotpool.SlotPoolGateway;
+import org.apache.flink.runtime.jobmaster.slotpool.SlotPoolImpl;
 import org.apache.flink.runtime.jobmaster.slotpool.SlotProvider;
+import org.apache.flink.runtime.jobmaster.slotpool.SlotSelectionStrategy;
 import org.apache.flink.runtime.jobmaster.slotpool.SlotSharingManager;
-import org.apache.flink.runtime.messages.Acknowledge;
-import org.apache.flink.runtime.rpc.RpcService;
-import org.apache.flink.runtime.rpc.RpcUtils;
-import org.apache.flink.runtime.rpc.TestingRpcService;
 import org.apache.flink.runtime.taskexecutor.slot.SlotOffer;
 import org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation;
 import org.apache.flink.runtime.taskmanager.TaskManagerLocation;
-import org.apache.flink.runtime.testingUtils.TestingUtils;
-import org.apache.flink.util.FlinkException;
+import org.apache.flink.util.FlinkRuntimeException;
 import org.apache.flink.util.Preconditions;
 import org.apache.flink.util.TestLogger;
 
 import org.junit.After;
 import org.junit.Before;
 
+import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -67,21 +68,22 @@ public class SchedulerTestBase extends TestLogger {
 
 	protected TestingSlotProvider testingSlotProvider;
 
-	private RpcService rpcService;
-
 	@Before
 	public void setup() throws Exception {
-		rpcService = new TestingRpcService();
 		final JobID jobId = new JobID();
-		final TestingSlotPool slotPool = new TestingSlotPool(
-			rpcService,
-			jobId,
-			LocationPreferenceSchedulingStrategy.getInstance());
-		testingSlotProvider = new TestingSlotPoolSlotProvider(slotPool);
+		final SlotPool slotPool = new SlotPoolImpl(jobId);
+		final TestingScheduler testingScheduler = new TestingScheduler(
+			new HashMap<>(16),
+			LocationPreferenceSlotSelectionStrategy.INSTANCE,
+			slotPool);
+
+		testingSlotProvider = new TestingSlotPoolSlotProvider(slotPool, testingScheduler);
 
 		final JobMasterId jobMasterId = JobMasterId.generate();
 		final String jobManagerAddress = "localhost";
-		slotPool.start(jobMasterId, jobManagerAddress);
+		ComponentMainThreadExecutor executor = TestingComponentMainThreadExecutorServiceAdapter.forMainThread();
+		slotPool.start(jobMasterId, jobManagerAddress, executor);
+		testingScheduler.start(executor);
 	}
 
 	@After
@@ -90,11 +92,6 @@ public class SchedulerTestBase extends TestLogger {
 			testingSlotProvider.shutdown();
 			testingSlotProvider = null;
 		}
-
-		if (rpcService != null) {
-			rpcService.stopService().get();
-			rpcService = null;
-		}
 	}
 
 	protected interface TestingSlotProvider extends SlotProvider {
@@ -121,9 +118,9 @@ public class SchedulerTestBase extends TestLogger {
 
 	private static final class TestingSlotPoolSlotProvider implements TestingSlotProvider {
 
-		private final TestingSlotPool slotPool;
+		private final SlotPool slotPool;
 
-		private final SlotProvider slotProvider;
+		private final TestingScheduler scheduler;
 
 		private final AtomicInteger numberOfLocalizedAssignments;
 
@@ -133,9 +130,10 @@ public class SchedulerTestBase extends TestLogger {
 
 		private final AtomicInteger numberOfHostLocalizedAssignments;
 
-		private TestingSlotPoolSlotProvider(TestingSlotPool slotPool) {
+		private TestingSlotPoolSlotProvider(SlotPool slotPool, TestingScheduler testingScheduler) {
 			this.slotPool = Preconditions.checkNotNull(slotPool);
-			this.slotProvider = slotPool.getSlotProvider();
+
+			this.scheduler = testingScheduler;
 
 			this.numberOfLocalizedAssignments = new AtomicInteger();
 			this.numberOfNonLocalizedAssignments = new AtomicInteger();
@@ -147,10 +145,10 @@ public class SchedulerTestBase extends TestLogger {
 		public TaskManagerLocation addTaskManager(int numberSlots) {
 			final TaskManagerLocation taskManagerLocation = new LocalTaskManagerLocation();
 			final ResourceID resourceId = taskManagerLocation.getResourceID();
-			final SlotPoolGateway slotPoolGateway = slotPool.getSelfGateway(SlotPoolGateway.class);
+			final SlotPool slotPoolGateway = slotPool;
 
 			try {
-				slotPoolGateway.registerTaskManager(resourceId).get();
+				slotPoolGateway.registerTaskManager(resourceId);
 			} catch (Exception e) {
 				throw new RuntimeException("Unexpected exception occurred. This indicates a programming bug.", e);
 			}
@@ -173,7 +171,7 @@ public class SchedulerTestBase extends TestLogger {
 				acceptedSlotOffers = slotPoolGateway.offerSlots(
 					taskManagerLocation,
 					taskManagerGateway,
-					slotOffers).get();
+					slotOffers);
 			} catch (Exception e) {
 				throw new RuntimeException("Unexpected exception occurred. This indicates a programming bug.", e);
 			}
@@ -186,7 +184,7 @@ public class SchedulerTestBase extends TestLogger {
 		@Override
 		public void releaseTaskManager(ResourceID resourceId) {
 			try {
-				slotPool.releaseTaskManager(resourceId, null).get();
+				slotPool.releaseTaskManager(resourceId, null);
 			} catch (Exception e) {
 				throw new RuntimeException("Should not have happened.", e);
 			}
@@ -194,11 +192,7 @@ public class SchedulerTestBase extends TestLogger {
 
 		@Override
 		public int getNumberOfAvailableSlots() {
-			try {
-				return slotPool.getNumberOfAvailableSlots().get();
-			} catch (Exception e) {
-				throw new RuntimeException("Should not have happened.", e);
-			}
+			return slotPool.getAvailableSlotsInformation().size();
 		}
 
 		@Override
@@ -223,35 +217,27 @@ public class SchedulerTestBase extends TestLogger {
 
 		@Override
 		public int getNumberOfSlots(SlotSharingGroup slotSharingGroup) {
-			try {
-				return slotPool.getNumberOfSharedSlots(slotSharingGroup.getSlotSharingGroupId()).get();
-			} catch (Exception e) {
-				throw new RuntimeException("Should not have happened.", e);
-			}
+				return scheduler.getNumberOfSharedSlots(slotSharingGroup.getSlotSharingGroupId());
 		}
 
 		@Override
 		public int getNumberOfAvailableSlotsForGroup(SlotSharingGroup slotSharingGroup, JobVertexID jobVertexId) {
-			try {
-				return slotPool.getNumberOfAvailableSlotsForGroup(slotSharingGroup.getSlotSharingGroupId(), jobVertexId).get();
-			} catch (Exception e) {
-				throw new RuntimeException("Should not have happened.", e);
-			}
+				return scheduler.getNumberOfAvailableSlotsForGroup(slotSharingGroup.getSlotSharingGroupId(), jobVertexId);
 		}
 
 		@Override
-		public void shutdown() throws Exception {
-			RpcUtils.terminateRpcEndpoint(slotPool, TestingUtils.TIMEOUT());
+		public void shutdown() {
+			slotPool.close();
 		}
 
 		@Override
 		public CompletableFuture<LogicalSlot> allocateSlot(
 			SlotRequestId slotRequestId,
 			ScheduledUnit task,
-			boolean allowQueued,
 			SlotProfile slotProfile,
+			boolean allowQueued,
 			Time allocationTimeout) {
-			return slotProvider.allocateSlot(task, allowQueued, slotProfile, allocationTimeout).thenApply(
+			return scheduler.allocateSlot(task, allowQueued, slotProfile, allocationTimeout).thenApply(
 				(LogicalSlot logicalSlot) -> {
 					switch (logicalSlot.getLocality()) {
 						case LOCAL:
@@ -275,58 +261,53 @@ public class SchedulerTestBase extends TestLogger {
 		}
 
 		@Override
-		public CompletableFuture<Acknowledge> cancelSlotRequest(SlotRequestId slotRequestId, @Nullable SlotSharingGroupId slotSharingGroupId, Throwable cause) {
-			return CompletableFuture.completedFuture(Acknowledge.get());
+		public void cancelSlotRequest(SlotRequestId slotRequestId, @Nullable SlotSharingGroupId slotSharingGroupId, Throwable cause) {
 		}
 	}
 
-	private static final class TestingSlotPool extends SlotPool {
 
-		public TestingSlotPool(RpcService rpcService, JobID jobId, SchedulingStrategy schedulingStrategy) {
-			super(rpcService, jobId, schedulingStrategy);
-		}
+	/**
+	 * Test implementation of scheduler that offers a bit more introspection.
+	 */
+	private static final class TestingScheduler extends SchedulerImpl {
 
-		CompletableFuture<Integer> getNumberOfAvailableSlots() {
-			return callAsync(
-				() -> getAvailableSlots().size(),
-				TestingUtils.infiniteTime());
-		}
+		private final Map<SlotSharingGroupId, SlotSharingManager> slotSharingManagersMap;
 
-		CompletableFuture<Integer> getNumberOfSharedSlots(SlotSharingGroupId slotSharingGroupId) {
-			return callAsync(
-				() -> {
-					final SlotSharingManager multiTaskSlotManager = slotSharingManagers.get(slotSharingGroupId);
+		public TestingScheduler(
+			@Nonnull Map<SlotSharingGroupId, SlotSharingManager> slotSharingManagersMap,
+			@Nonnull SlotSelectionStrategy slotSelectionStrategy,
+			@Nonnull SlotPool slotPoolGateway) {
 
-					if (multiTaskSlotManager != null) {
-						return multiTaskSlotManager.getResolvedRootSlots().size();
-					} else {
-						throw new FlinkException("No MultiTaskSlotManager registered under " + slotSharingGroupId + '.');
-					}
-				},
-				TestingUtils.infiniteTime());
+			super(slotSelectionStrategy, slotPoolGateway, slotSharingManagersMap);
+			this.slotSharingManagersMap = slotSharingManagersMap;
 		}
 
-		CompletableFuture<Integer> getNumberOfAvailableSlotsForGroup(SlotSharingGroupId slotSharingGroupId, JobVertexID jobVertexId) {
-			return callAsync(
-				() -> {
-					final SlotSharingManager multiTaskSlotManager = slotSharingManagers.get(slotSharingGroupId);
+		public int getNumberOfSharedSlots(SlotSharingGroupId slotSharingGroupId) {
+			final SlotSharingManager multiTaskSlotManager = slotSharingManagersMap.get(slotSharingGroupId);
+
+			if (multiTaskSlotManager != null) {
+				return multiTaskSlotManager.getResolvedRootSlots().size();
+			} else {
+				throw new FlinkRuntimeException("No MultiTaskSlotManager registered under " + slotSharingGroupId + '.');
+			}
+		}
 
-					if (multiTaskSlotManager != null) {
-						int availableSlots = 0;
+		public int getNumberOfAvailableSlotsForGroup(SlotSharingGroupId slotSharingGroupId, JobVertexID jobVertexId) {
+			final SlotSharingManager multiTaskSlotManager = slotSharingManagersMap.get(slotSharingGroupId);
 
-						for (SlotSharingManager.MultiTaskSlot multiTaskSlot : multiTaskSlotManager.getResolvedRootSlots()) {
-							if (!multiTaskSlot.contains(jobVertexId)) {
-								availableSlots++;
-							}
-						}
+			if (multiTaskSlotManager != null) {
+				int availableSlots = 0;
 
-						return availableSlots;
-					} else {
-						throw new FlinkException("No MultiTaskSlotmanager registered under " + slotSharingGroupId + '.');
+				for (SlotSharingManager.MultiTaskSlot multiTaskSlot : multiTaskSlotManager.getResolvedRootSlots()) {
+					if (!multiTaskSlot.contains(jobVertexId)) {
+						availableSlots++;
 					}
-				},
-				TestingUtils.infiniteTime());
+				}
+
+				return availableSlots;
+			} else {
+				throw new FlinkRuntimeException("No MultiTaskSlotmanager registered under " + slotSharingGroupId + '.');
+			}
 		}
 	}
-
 }
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmanager/slots/DummySlotOwner.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmanager/slots/DummySlotOwner.java
index add1ec2..0c0350f 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmanager/slots/DummySlotOwner.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmanager/slots/DummySlotOwner.java
@@ -21,14 +21,11 @@ package org.apache.flink.runtime.jobmanager.slots;
 import org.apache.flink.runtime.jobmaster.LogicalSlot;
 import org.apache.flink.runtime.jobmaster.SlotOwner;
 
-import java.util.concurrent.CompletableFuture;
-
 /**
  * SlotOwner implementation used for testing purposes only.
  */
 public class DummySlotOwner implements SlotOwner {
 	@Override
-	public CompletableFuture<Boolean> returnAllocatedSlot(LogicalSlot logicalSlot) {
-		return CompletableFuture.completedFuture(false);
+	public void returnLogicalSlot(LogicalSlot logicalSlot) {
 	}
 }
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmanager/slots/TestingSlotOwner.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmanager/slots/TestingSlotOwner.java
index b922204..66d4650 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmanager/slots/TestingSlotOwner.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmanager/slots/TestingSlotOwner.java
@@ -21,7 +21,6 @@ package org.apache.flink.runtime.jobmanager.slots;
 import org.apache.flink.runtime.jobmaster.LogicalSlot;
 import org.apache.flink.runtime.jobmaster.SlotOwner;
 
-import java.util.concurrent.CompletableFuture;
 import java.util.function.Consumer;
 
 /**
@@ -36,13 +35,11 @@ public class TestingSlotOwner implements SlotOwner {
 	}
 
 	@Override
-	public CompletableFuture<Boolean> returnAllocatedSlot(LogicalSlot logicalSlot) {
+	public void returnLogicalSlot(LogicalSlot logicalSlot) {
 		final Consumer<LogicalSlot> currentReturnAllocatedSlotConsumer = returnAllocatedSlotConsumer;
 
 		if (currentReturnAllocatedSlotConsumer != null) {
 			currentReturnAllocatedSlotConsumer.accept(logicalSlot);
 		}
-
-		return CompletableFuture.completedFuture(true);
 	}
 }
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java
index 5d4df0b..e53c47f 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/JobMasterTest.java
@@ -79,6 +79,7 @@ import org.apache.flink.runtime.jobgraph.tasks.JobCheckpointingSettings;
 import org.apache.flink.runtime.jobmanager.OnCompletionActions;
 import org.apache.flink.runtime.jobmanager.PartitionProducerDisposedException;
 import org.apache.flink.runtime.jobmaster.factories.UnregisteredJobManagerJobMetricGroupFactory;
+import org.apache.flink.runtime.jobmaster.slotpool.DefaultSchedulerFactory;
 import org.apache.flink.runtime.jobmaster.slotpool.DefaultSlotPoolFactory;
 import org.apache.flink.runtime.leaderretrieval.SettableLeaderRetrievalService;
 import org.apache.flink.runtime.messages.Acknowledge;
@@ -274,7 +275,8 @@ public class JobMasterTest extends TestLogger {
 				jmResourceId,
 				jobGraph,
 				haServices,
-				DefaultSlotPoolFactory.fromConfiguration(configuration, rpcService1),
+				DefaultSlotPoolFactory.fromConfiguration(configuration),
+				DefaultSchedulerFactory.fromConfiguration(configuration),
 				jobManagerSharedServices,
 				heartbeatServices,
 				UnregisteredJobManagerJobMetricGroupFactory.INSTANCE,
@@ -1317,7 +1319,8 @@ public class JobMasterTest extends TestLogger {
 			jmResourceId,
 			jobGraph,
 			haServices,
-			DefaultSlotPoolFactory.fromConfiguration(configuration, rpcService),
+			DefaultSlotPoolFactory.fromConfiguration(configuration),
+			DefaultSchedulerFactory.fromConfiguration(configuration),
 			new TestingJobManagerSharedServicesBuilder().build(),
 			heartbeatServices,
 			UnregisteredJobManagerJobMetricGroupFactory.INSTANCE,
@@ -1665,7 +1668,8 @@ public class JobMasterTest extends TestLogger {
 			jmResourceId,
 			jobGraph,
 			highAvailabilityServices,
-			DefaultSlotPoolFactory.fromConfiguration(configuration, rpcService),
+			DefaultSlotPoolFactory.fromConfiguration(configuration),
+			DefaultSchedulerFactory.fromConfiguration(configuration),
 			jobManagerSharedServices,
 			heartbeatServices,
 			UnregisteredJobManagerJobMetricGroupFactory.INSTANCE,
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/TestingPayload.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/TestingPayload.java
index 1c9cc99..e9f71b8 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/TestingPayload.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/TestingPayload.java
@@ -31,14 +31,8 @@ public class TestingPayload implements LogicalSlot.Payload {
 		this.terminationFuture = new CompletableFuture<>();
 	}
 
-
-	@Override
-	public void failAsync(Throwable cause) {
-		failSync(cause);
-	}
-
 	@Override
-	public void failSync(Throwable cause) {
+	public void fail(Throwable cause) {
 		terminationFuture.complete(null);
 	}
 
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/AllocatedSlotsTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/AllocatedSlotsTest.java
index 4dee924..3a6e0ed 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/AllocatedSlotsTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/AllocatedSlotsTest.java
@@ -38,7 +38,7 @@ public class AllocatedSlotsTest extends TestLogger {
 
 	@Test
 	public void testOperations() throws Exception {
-		SlotPool.AllocatedSlots allocatedSlots = new SlotPool.AllocatedSlots();
+		SlotPoolImpl.AllocatedSlots allocatedSlots = new SlotPoolImpl.AllocatedSlots();
 
 		final AllocationID allocation1 = new AllocationID();
 		final SlotRequestId slotRequestID = new SlotRequestId();
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/AvailableSlotsTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/AvailableSlotsTest.java
index caa174d..03625c8 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/AvailableSlotsTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/AvailableSlotsTest.java
@@ -21,29 +21,25 @@ package org.apache.flink.runtime.jobmaster.slotpool;
 import org.apache.flink.runtime.clusterframework.types.AllocationID;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
 import org.apache.flink.runtime.clusterframework.types.ResourceProfile;
-import org.apache.flink.runtime.clusterframework.types.SlotProfile;
-import org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway;
+import org.apache.flink.runtime.executiongraph.utils.SimpleAckingTaskManagerGateway;
 import org.apache.flink.runtime.taskmanager.TaskManagerLocation;
 import org.apache.flink.util.TestLogger;
 
 import org.junit.Test;
 
+import java.net.InetAddress;
+
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 
 public class AvailableSlotsTest extends TestLogger {
 
 	static final ResourceProfile DEFAULT_TESTING_PROFILE = new ResourceProfile(1.0, 512);
 
-	static final ResourceProfile DEFAULT_TESTING_BIG_PROFILE = new ResourceProfile(2.0, 1024);
-
 	@Test
-	public void testAddAndRemove() throws Exception {
-		SlotPool.AvailableSlots availableSlots = new SlotPool.AvailableSlots();
+	public void testAddAndRemove() {
+		SlotPoolImpl.AvailableSlots availableSlots = new SlotPoolImpl.AvailableSlots();
 
 		final ResourceID resource1 = new ResourceID("resource1");
 		final ResourceID resource2 = new ResourceID("resource2");
@@ -82,39 +78,12 @@ public class AvailableSlotsTest extends TestLogger {
 		assertFalse(availableSlots.containsTaskManager(resource2));
 	}
 
-	@Test
-	public void testPollFreeSlot() {
-		SlotPool.AvailableSlots availableSlots = new SlotPool.AvailableSlots();
-
-		final ResourceID resource1 = new ResourceID("resource1");
-		final AllocatedSlot slot1 = createAllocatedSlot(resource1);
-
-		availableSlots.add(slot1, 1L);
-
-		assertEquals(1, availableSlots.size());
-		assertTrue(availableSlots.contains(slot1.getAllocationId()));
-		assertTrue(availableSlots.containsTaskManager(resource1));
-
-		assertNull(availableSlots.poll(LocationPreferenceSchedulingStrategy.getInstance(), SlotProfile.noLocality(DEFAULT_TESTING_BIG_PROFILE)));
-
-		SlotAndLocality slotAndLocality = availableSlots.poll(LocationPreferenceSchedulingStrategy.getInstance(), SlotProfile.noLocality(DEFAULT_TESTING_PROFILE));
-		assertEquals(slot1, slotAndLocality.getSlot());
-		assertEquals(0, availableSlots.size());
-		assertFalse(availableSlots.contains(slot1.getAllocationId()));
-		assertFalse(availableSlots.containsTaskManager(resource1));
-	}
-
-	static AllocatedSlot createAllocatedSlot(final ResourceID resourceId) {
-		TaskManagerLocation mockTaskManagerLocation = mock(TaskManagerLocation.class);
-		when(mockTaskManagerLocation.getResourceID()).thenReturn(resourceId);
-
-		TaskManagerGateway mockTaskManagerGateway = mock(TaskManagerGateway.class);
-
+	private static AllocatedSlot createAllocatedSlot(final ResourceID resourceId) {
 		return new AllocatedSlot(
 			new AllocationID(),
-			mockTaskManagerLocation,
+			new TaskManagerLocation(resourceId, InetAddress.getLoopbackAddress(), 42),
 			0,
 			DEFAULT_TESTING_PROFILE,
-			mockTaskManagerGateway);
+			new SimpleAckingTaskManagerGateway());
 	}
 }
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/DummyPayload.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/DummyPayload.java
index c0ddaab..f89e354 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/DummyPayload.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/DummyPayload.java
@@ -28,28 +28,23 @@ import java.util.concurrent.CompletableFuture;
  */
 final class DummyPayload implements LogicalSlot.Payload {
 
-    private final CompletableFuture<?> terminalStateFuture;
+	private final CompletableFuture<?> terminalStateFuture;
 
-    DummyPayload() {
-    	this(new CompletableFuture<>());
+	DummyPayload() {
+		this(new CompletableFuture<>());
 	}
 
-    DummyPayload(CompletableFuture<?> terminalStateFuture) {
-        this.terminalStateFuture = Preconditions.checkNotNull(terminalStateFuture);
-    }
-
-    @Override
-    public void failAsync(Throwable cause) {
-		failSync(cause);
-    }
+	DummyPayload(CompletableFuture<?> terminalStateFuture) {
+		this.terminalStateFuture = Preconditions.checkNotNull(terminalStateFuture);
+	}
 
 	@Override
-	public void failSync(Throwable cause) {
+	public void fail(Throwable cause) {
 		terminalStateFuture.complete(null);
 	}
 
 	@Override
-    public CompletableFuture<?> getTerminalStateFuture() {
-        return terminalStateFuture;
-    }
+	public CompletableFuture<?> getTerminalStateFuture() {
+		return terminalStateFuture;
+	}
 }
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SingleLogicalSlotTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SingleLogicalSlotTest.java
index 4890eea..071fcc4 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SingleLogicalSlotTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SingleLogicalSlotTest.java
@@ -19,6 +19,7 @@
 package org.apache.flink.runtime.jobmaster.slotpool;
 
 import org.apache.flink.runtime.clusterframework.types.AllocationID;
+import org.apache.flink.runtime.clusterframework.types.ResourceProfile;
 import org.apache.flink.runtime.concurrent.FutureUtils;
 import org.apache.flink.runtime.executiongraph.utils.SimpleAckingTaskManagerGateway;
 import org.apache.flink.runtime.jobmanager.scheduler.Locality;
@@ -109,31 +110,8 @@ public class SingleLogicalSlotTest extends TestLogger {
 		assertThat(singleLogicalSlot.tryAssignPayload(dummyPayload), is(false));
 	}
 
-	@Test
-	public void testReleaseOnlyHappensAfterReturningSlotCompleted() {
-
-		final CompletableFuture<Boolean> allocateSlotFuture = new CompletableFuture<>();
-
-		final SingleLogicalSlot singleLogicalSlot = createSingleLogicalSlot(new DummySlotOwner() {
-			@Override
-			public CompletableFuture<Boolean> returnAllocatedSlot(LogicalSlot logicalSlot) {
-				// we return a future that will never complete instead
-				return allocateSlotFuture;
-			}
-		});
-
-		CompletableFuture<?> releaseFuture = singleLogicalSlot.releaseSlot(new FlinkException("Test exception"));
-
-		// this must not be done, because the future that signals a successful return never completed.
-		assertThat(releaseFuture.isDone(), is(false));
-
-		// and completing the allocation should now also make the release complete.
-		allocateSlotFuture.complete(null);
-		assertThat(releaseFuture.isDone(), is(true));
-	}
-
 	/**
-	 * Tests that the {@link AllocatedSlot.Payload#release(Throwable)} does not wait
+	 * Tests that the {@link PhysicalSlot.Payload#release(Throwable)} does not wait
 	 * for the payload to reach a terminal state.
 	 */
 	@Test
@@ -240,12 +218,7 @@ public class SingleLogicalSlotTest extends TestLogger {
 		}
 
 		@Override
-		public void failAsync(Throwable cause) {
-			failSync(cause);
-		}
-
-		@Override
-		public void failSync(Throwable cause) {
+		public void fail(Throwable cause) {
 			failCounter.incrementAndGet();
 		}
 
@@ -268,9 +241,8 @@ public class SingleLogicalSlotTest extends TestLogger {
 		}
 
 		@Override
-		public CompletableFuture<Boolean> returnAllocatedSlot(LogicalSlot logicalSlot) {
+		public void returnLogicalSlot(LogicalSlot logicalSlot) {
 			counter.incrementAndGet();
-			return CompletableFuture.completedFuture(true);
 		}
 	}
 
@@ -286,12 +258,7 @@ public class SingleLogicalSlotTest extends TestLogger {
 		}
 
 		@Override
-		public void failAsync(Throwable cause) {
-			failSync(cause);
-		}
-
-		@Override
-		public void failSync(Throwable cause) {
+		public void fail(Throwable cause) {
 			failFuture.completeExceptionally(cause);
 		}
 
@@ -313,9 +280,8 @@ public class SingleLogicalSlotTest extends TestLogger {
 		}
 
 		@Override
-		public CompletableFuture<Boolean> returnAllocatedSlot(LogicalSlot logicalSlot) {
+		public void returnLogicalSlot(LogicalSlot logicalSlot) {
 			returnAllocatedSlotFuture.complete(logicalSlot);
-			return returnAllocatedSlotResponse;
 		}
 	}
 
@@ -349,6 +315,11 @@ public class SingleLogicalSlotTest extends TestLogger {
 		}
 
 		@Override
+		public ResourceProfile getResourceProfile() {
+			return ResourceProfile.UNKNOWN;
+		}
+
+		@Override
 		public TaskManagerGateway getTaskManagerGateway() {
 			return taskManagerGateway;
 		}
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolCoLocationTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolCoLocationTest.java
index d76eb57..44c9977 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolCoLocationTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolCoLocationTest.java
@@ -41,17 +41,19 @@ import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 
+import java.util.Collection;
+import java.util.Collections;
 import java.util.concurrent.ArrayBlockingQueue;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.ExecutionException;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
 
 /**
- * Test cases for {@link CoLocationConstraint} with the {@link SlotPool}.
+ * Test cases for {@link CoLocationConstraint} with the {@link SlotPoolImpl}.
  */
 public class SlotPoolCoLocationTest extends TestLogger {
 
@@ -59,9 +61,8 @@ public class SlotPoolCoLocationTest extends TestLogger {
 	public static final TestingRpcServiceResource rpcServiceResource = new TestingRpcServiceResource();
 
 	@Rule
-	public final SlotPoolResource slotPoolResource = new SlotPoolResource(
-		rpcServiceResource.getTestingRpcService(),
-		PreviousAllocationSchedulingStrategy.getInstance());
+	public final SlotPoolResource slotPoolResource =
+		new SlotPoolResource(PreviousAllocationSlotSelectionStrategy.INSTANCE);
 
 	/**
 	 * Tests the scheduling of two tasks with a parallelism of 2 and a co-location constraint.
@@ -77,8 +78,8 @@ public class SlotPoolCoLocationTest extends TestLogger {
 
 		final TaskManagerLocation taskManagerLocation = new LocalTaskManagerLocation();
 
-		final SlotPoolGateway slotPoolGateway = slotPoolResource.getSlotPoolGateway();
-		slotPoolGateway.registerTaskManager(taskManagerLocation.getResourceID()).get();
+		final SlotPool slotPoolGateway = slotPoolResource.getSlotPool();
+		slotPoolGateway.registerTaskManager(taskManagerLocation.getResourceID());
 
 		CoLocationGroup group = new CoLocationGroup();
 		CoLocationConstraint coLocationConstraint1 = group.getLocationConstraint(0);
@@ -129,24 +130,24 @@ public class SlotPoolCoLocationTest extends TestLogger {
 		final AllocationID allocationId1 = allocationIds.take();
 		final AllocationID allocationId2 = allocationIds.take();
 
-		CompletableFuture<Boolean> slotOfferFuture1 = slotPoolGateway.offerSlot(
+		Collection<SlotOffer> slotOfferFuture1 = slotPoolGateway.offerSlots(
 			taskManagerLocation,
 			new SimpleAckingTaskManagerGateway(),
-			new SlotOffer(
+			Collections.singletonList(new SlotOffer(
 				allocationId1,
 				0,
-				ResourceProfile.UNKNOWN));
+				ResourceProfile.UNKNOWN)));
 
-		CompletableFuture<Boolean> slotOfferFuture2 = slotPoolGateway.offerSlot(
+		Collection<SlotOffer> slotOfferFuture2 = slotPoolGateway.offerSlots(
 			taskManagerLocation,
 			new SimpleAckingTaskManagerGateway(),
-			new SlotOffer(
+			Collections.singletonList(new SlotOffer(
 				allocationId2,
 				0,
-				ResourceProfile.UNKNOWN));
+				ResourceProfile.UNKNOWN)));
 
-		assertTrue(slotOfferFuture1.get());
-		assertTrue(slotOfferFuture2.get());
+		assertFalse(slotOfferFuture1.isEmpty());
+		assertFalse(slotOfferFuture2.isEmpty());
 
 		LogicalSlot logicalSlot11 = logicalSlotFuture11.get();
 		LogicalSlot logicalSlot12 = logicalSlotFuture12.get();
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolRpcTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolInteractionsTest.java
similarity index 63%
rename from flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolRpcTest.java
rename to flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolInteractionsTest.java
index 33104c2..ec22e9b 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolRpcTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolInteractionsTest.java
@@ -20,12 +20,10 @@ package org.apache.flink.runtime.jobmaster.slotpool;
 
 import org.apache.flink.api.common.JobID;
 import org.apache.flink.api.common.time.Time;
-import org.apache.flink.configuration.Configuration;
-import org.apache.flink.runtime.akka.AkkaUtils;
 import org.apache.flink.runtime.clusterframework.types.AllocationID;
 import org.apache.flink.runtime.clusterframework.types.SlotProfile;
+import org.apache.flink.runtime.executiongraph.TestingComponentMainThreadExecutor;
 import org.apache.flink.runtime.executiongraph.utils.SimpleAckingTaskManagerGateway;
-import org.apache.flink.runtime.instance.SlotSharingGroupId;
 import org.apache.flink.runtime.jobmanager.scheduler.DummyScheduledUnit;
 import org.apache.flink.runtime.jobmanager.scheduler.ScheduledUnit;
 import org.apache.flink.runtime.jobmanager.scheduler.SchedulerTestUtils;
@@ -33,14 +31,9 @@ import org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway;
 import org.apache.flink.runtime.jobmaster.JobMasterId;
 import org.apache.flink.runtime.jobmaster.LogicalSlot;
 import org.apache.flink.runtime.jobmaster.SlotRequestId;
-import org.apache.flink.runtime.messages.Acknowledge;
 import org.apache.flink.runtime.resourcemanager.ResourceManagerGateway;
 import org.apache.flink.runtime.resourcemanager.SlotRequest;
 import org.apache.flink.runtime.resourcemanager.utils.TestingResourceManagerGateway;
-import org.apache.flink.runtime.rpc.RpcService;
-import org.apache.flink.runtime.rpc.RpcUtils;
-import org.apache.flink.runtime.rpc.akka.AkkaRpcService;
-import org.apache.flink.runtime.rpc.akka.AkkaRpcServiceConfiguration;
 import org.apache.flink.runtime.taskexecutor.slot.SlotOffer;
 import org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation;
 import org.apache.flink.runtime.taskmanager.TaskManagerLocation;
@@ -51,11 +44,10 @@ import org.apache.flink.util.ExceptionUtils;
 import org.apache.flink.util.Preconditions;
 import org.apache.flink.util.TestLogger;
 
-import akka.actor.ActorSystem;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.ClassRule;
 import org.junit.Test;
 
+import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
 import java.util.concurrent.CompletableFuture;
@@ -69,33 +61,18 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 /**
- * Tests for the SlotPool using a proper RPC setup.
+ * Tests for the SlotPoolImpl interactions.
  */
-public class SlotPoolRpcTest extends TestLogger {
-
-	private static RpcService rpcService;
-
-	private static final Time timeout = Time.seconds(10L);
+public class SlotPoolInteractionsTest extends TestLogger {
 
 	private static final Time fastTimeout = Time.milliseconds(1L);
 
-	// ------------------------------------------------------------------------
-	//  setup
-	// ------------------------------------------------------------------------
-
-	@BeforeClass
-	public static void setup() {
-		ActorSystem actorSystem = AkkaUtils.createLocalActorSystem(new Configuration());
-		rpcService = new AkkaRpcService(actorSystem, AkkaRpcServiceConfiguration.defaultConfiguration());
-	}
+	@ClassRule
+	public static final TestingComponentMainThreadExecutor.Resource EXECUTOR_RESOURCE =
+		new TestingComponentMainThreadExecutor.Resource(10L);
 
-	@AfterClass
-	public static  void shutdown() throws InterruptedException, ExecutionException, TimeoutException {
-		if (rpcService != null) {
-			RpcUtils.terminateRpcService(rpcService, timeout);
-			rpcService = null;
-		}
-	}
+	private final TestingComponentMainThreadExecutor testMainThreadExecutor =
+		EXECUTOR_RESOURCE.getComponentMainThreadTestExecutor();
 
 	// ------------------------------------------------------------------------
 	//  tests
@@ -104,25 +81,24 @@ public class SlotPoolRpcTest extends TestLogger {
 	@Test
 	public void testSlotAllocationNoResourceManager() throws Exception {
 		final JobID jid = new JobID();
-		
-		final SlotPool pool = new SlotPool(
-			rpcService,
+
+		try (SlotPool pool = new SlotPoolImpl(
 			jid,
-			LocationPreferenceSchedulingStrategy.getInstance(),
 			SystemClock.getInstance(),
 			TestingUtils.infiniteTime(),
 			TestingUtils.infiniteTime()
-		);
+		)) {
 
-		try {
-			pool.start(JobMasterId.generate(), "foobar");
+			pool.start(JobMasterId.generate(), "foobar", testMainThreadExecutor.getMainThreadExecutor());
+			Scheduler scheduler = new SchedulerImpl(LocationPreferenceSlotSelectionStrategy.INSTANCE, pool);
+			scheduler.start(testMainThreadExecutor.getMainThreadExecutor());
 
-			CompletableFuture<LogicalSlot> future = pool.allocateSlot(
+			CompletableFuture<LogicalSlot> future = testMainThreadExecutor.execute(() -> scheduler.allocateSlot(
 				new SlotRequestId(),
 				new ScheduledUnit(SchedulerTestUtils.getDummyTask()),
 				SlotProfile.noLocality(DEFAULT_TESTING_PROFILE),
 				true,
-				fastTimeout);
+				fastTimeout));
 
 			try {
 				future.get();
@@ -130,8 +106,6 @@ public class SlotPoolRpcTest extends TestLogger {
 			} catch (ExecutionException e) {
 				assertTrue(ExceptionUtils.stripExecutionException(e) instanceof TimeoutException);
 			}
-		} finally {
-			RpcUtils.terminateRpcEndpoint(pool, timeout);
 		}
 	}
 
@@ -139,26 +113,25 @@ public class SlotPoolRpcTest extends TestLogger {
 	public void testCancelSlotAllocationWithoutResourceManager() throws Exception {
 		final JobID jid = new JobID();
 
-		final TestingSlotPool pool = new TestingSlotPool(
-			rpcService,
+		try (TestingSlotPool pool = new TestingSlotPool(
 			jid,
 			SystemClock.getInstance(),
 			TestingUtils.infiniteTime(),
-			TestingUtils.infiniteTime());
+			TestingUtils.infiniteTime())) {
 
-		try {
 			final CompletableFuture<SlotRequestId> timeoutFuture = new CompletableFuture<>();
-			pool.setTimeoutPendingSlotRequestConsumer(slotRequestId -> timeoutFuture.complete(slotRequestId));
-			pool.start(JobMasterId.generate(), "foobar");
-			SlotPoolGateway slotPoolGateway = pool.getSelfGateway(SlotPoolGateway.class);
+			pool.setTimeoutPendingSlotRequestConsumer(timeoutFuture::complete);
+			pool.start(JobMasterId.generate(), "foobar", testMainThreadExecutor.getMainThreadExecutor());
+			Scheduler scheduler = new SchedulerImpl(LocationPreferenceSlotSelectionStrategy.INSTANCE, pool);
+			scheduler.start(testMainThreadExecutor.getMainThreadExecutor());
 
 			SlotRequestId requestId = new SlotRequestId();
-			CompletableFuture<LogicalSlot> future = slotPoolGateway.allocateSlot(
+			CompletableFuture<LogicalSlot> future = testMainThreadExecutor.execute(() -> scheduler.allocateSlot(
 				requestId,
 				new ScheduledUnit(SchedulerTestUtils.getDummyTask()),
 				SlotProfile.noLocality(DEFAULT_TESTING_PROFILE),
 				true,
-				fastTimeout);
+				fastTimeout));
 
 			try {
 				future.get();
@@ -170,9 +143,7 @@ public class SlotPoolRpcTest extends TestLogger {
 			// wait for the timeout of the pending slot request
 			timeoutFuture.get();
 
-			assertEquals(0L, (long) pool.getNumberOfWaitingForResourceRequests().get());
-		} finally {
-			RpcUtils.terminateRpcEndpoint(pool, timeout);
+			assertEquals(0L, pool.getNumberOfWaitingForResourceRequests());
 		}
 	}
 
@@ -183,16 +154,13 @@ public class SlotPoolRpcTest extends TestLogger {
 	public void testSlotAllocationTimeout() throws Exception {
 		final JobID jid = new JobID();
 
-		final TestingSlotPool pool = new TestingSlotPool(
-			rpcService,
+		try (TestingSlotPool pool = new TestingSlotPool(
 			jid,
 			SystemClock.getInstance(),
 			TestingUtils.infiniteTime(),
-			TestingUtils.infiniteTime());
+			TestingUtils.infiniteTime())) {
 
-		try {
-			pool.start(JobMasterId.generate(), "foobar");
-			SlotPoolGateway slotPoolGateway = pool.getSelfGateway(SlotPoolGateway.class);
+			pool.start(JobMasterId.generate(), "foobar", testMainThreadExecutor.getMainThreadExecutor());
 
 			final CompletableFuture<SlotRequestId> slotRequestTimeoutFuture = new CompletableFuture<>();
 			pool.setTimeoutPendingSlotRequestConsumer(slotRequestTimeoutFuture::complete);
@@ -200,13 +168,16 @@ public class SlotPoolRpcTest extends TestLogger {
 			ResourceManagerGateway resourceManagerGateway = new TestingResourceManagerGateway();
 			pool.connectToResourceManager(resourceManagerGateway);
 
+			Scheduler scheduler = new SchedulerImpl(LocationPreferenceSlotSelectionStrategy.INSTANCE, pool);
+			scheduler.start(testMainThreadExecutor.getMainThreadExecutor());
+
 			SlotRequestId requestId = new SlotRequestId();
-			CompletableFuture<LogicalSlot> future = slotPoolGateway.allocateSlot(
+			CompletableFuture<LogicalSlot> future = testMainThreadExecutor.execute(() -> scheduler.allocateSlot(
 				requestId,
 				new DummyScheduledUnit(),
 				SlotProfile.noLocality(DEFAULT_TESTING_PROFILE),
 				true,
-				fastTimeout);
+				fastTimeout));
 
 			try {
 				future.get();
@@ -218,29 +189,27 @@ public class SlotPoolRpcTest extends TestLogger {
 			// wait until we have timed out the slot request
 			slotRequestTimeoutFuture.get();
 
-			assertEquals(0L, (long) pool.getNumberOfPendingRequests().get());
-		} finally {
-			RpcUtils.terminateRpcEndpoint(pool, timeout);
+			assertEquals(0L, pool.getNumberOfPendingRequests());
 		}
 	}
 
 	/**
-	 * Tests that extra slots are kept by the {@link SlotPool}.
+	 * Tests that extra slots are kept by the {@link SlotPoolImpl}.
 	 */
 	@Test
 	public void testExtraSlotsAreKept() throws Exception {
 		final JobID jid = new JobID();
 
-		final TestingSlotPool pool = new TestingSlotPool(
-			rpcService,
+		try (TestingSlotPool pool = new TestingSlotPool(
 			jid,
 			SystemClock.getInstance(),
 			TestingUtils.infiniteTime(),
-			TestingUtils.infiniteTime());
+			TestingUtils.infiniteTime())) {
 
-		try {
-			pool.start(JobMasterId.generate(), "foobar");
-			SlotPoolGateway slotPoolGateway = pool.getSelfGateway(SlotPoolGateway.class);
+			pool.start(JobMasterId.generate(), "foobar", testMainThreadExecutor.getMainThreadExecutor());
+
+			Scheduler scheduler = new SchedulerImpl(LocationPreferenceSlotSelectionStrategy.INSTANCE, pool);
+			scheduler.start(testMainThreadExecutor.getMainThreadExecutor());
 
 			final CompletableFuture<AllocationID> allocationIdFuture = new CompletableFuture<>();
 
@@ -254,12 +223,12 @@ public class SlotPoolRpcTest extends TestLogger {
 			pool.connectToResourceManager(resourceManagerGateway);
 
 			SlotRequestId requestId = new SlotRequestId();
-			CompletableFuture<LogicalSlot> future = slotPoolGateway.allocateSlot(
+			CompletableFuture<LogicalSlot> future = testMainThreadExecutor.execute(() -> scheduler.allocateSlot(
 				requestId,
 				new ScheduledUnit(SchedulerTestUtils.getDummyTask()),
 				SlotProfile.noLocality(DEFAULT_TESTING_PROFILE),
 				true,
-				fastTimeout);
+				fastTimeout));
 
 			try {
 				future.get();
@@ -271,7 +240,7 @@ public class SlotPoolRpcTest extends TestLogger {
 			// wait until we have timed out the slot request
 			slotRequestTimeoutFuture.get();
 
-			assertEquals(0L, (long) pool.getNumberOfPendingRequests().get());
+			assertEquals(0L, pool.getNumberOfPendingRequests());
 
 			AllocationID allocationId = allocationIdFuture.get();
 			final SlotOffer slotOffer = new SlotOffer(
@@ -281,13 +250,11 @@ public class SlotPoolRpcTest extends TestLogger {
 			final TaskManagerLocation taskManagerLocation = new LocalTaskManagerLocation();
 			final TaskManagerGateway taskManagerGateway = new SimpleAckingTaskManagerGateway();
 
-			slotPoolGateway.registerTaskManager(taskManagerLocation.getResourceID()).get();
+			testMainThreadExecutor.execute(() -> pool.registerTaskManager(taskManagerLocation.getResourceID()));
 
-			assertTrue(slotPoolGateway.offerSlot(taskManagerLocation, taskManagerGateway, slotOffer).get());
+			assertTrue(testMainThreadExecutor.execute(() -> pool.offerSlot(taskManagerLocation, taskManagerGateway, slotOffer)));
 
-			assertTrue(pool.containsAvailableSlot(allocationId).get());
-		} finally {
-			RpcUtils.terminateRpcEndpoint(pool, timeout);
+			assertTrue(pool.containsAvailableSlot(allocationId));
 		}
 	}
 
@@ -299,30 +266,29 @@ public class SlotPoolRpcTest extends TestLogger {
 	public void testProviderAndOwnerSlotAllocationTimeout() throws Exception {
 		final JobID jid = new JobID();
 
-		final TestingSlotPool pool = new TestingSlotPool(
-			rpcService,
+		try (TestingSlotPool pool = new TestingSlotPool(
 			jid,
 			SystemClock.getInstance(),
 			TestingUtils.infiniteTime(),
-			TestingUtils.infiniteTime());
+			TestingUtils.infiniteTime())) {
 
-		final CompletableFuture<SlotRequestId> releaseSlotFuture = new CompletableFuture<>();
+			final CompletableFuture<SlotRequestId> releaseSlotFuture = new CompletableFuture<>();
 
-		pool.setReleaseSlotConsumer(
-			slotRequestID -> releaseSlotFuture.complete(slotRequestID));
+			pool.setReleaseSlotConsumer(releaseSlotFuture::complete);
 
-		try {
-			pool.start(JobMasterId.generate(), "foobar");
+			pool.start(JobMasterId.generate(), "foobar", testMainThreadExecutor.getMainThreadExecutor());
 			ResourceManagerGateway resourceManagerGateway = new TestingResourceManagerGateway();
 			pool.connectToResourceManager(resourceManagerGateway);
 
+			Scheduler scheduler = new SchedulerImpl(LocationPreferenceSlotSelectionStrategy.INSTANCE, pool);
+			scheduler.start(testMainThreadExecutor.getMainThreadExecutor());
+
 			// test the pending request is clear when timed out
-			CompletableFuture<LogicalSlot> future = pool.getSlotProvider().allocateSlot(
+			CompletableFuture<LogicalSlot> future = testMainThreadExecutor.execute(() -> scheduler.allocateSlot(
 				new DummyScheduledUnit(),
 				true,
 				SlotProfile.noRequirements(),
-				fastTimeout);
-
+				fastTimeout));
 			try {
 				future.get();
 				fail("We expected a TimeoutException.");
@@ -330,34 +296,29 @@ public class SlotPoolRpcTest extends TestLogger {
 				assertTrue(ExceptionUtils.stripExecutionException(e) instanceof TimeoutException);
 			}
 
-			// wait for the cancel call on the SlotPool
+			// wait for the cancel call on the SlotPoolImpl
 			releaseSlotFuture.get();
 
-			assertEquals(0L, (long) pool.getNumberOfPendingRequests().get());
-		} finally {
-			RpcUtils.terminateRpcEndpoint(pool, timeout);
+			assertEquals(0L, pool.getNumberOfPendingRequests());
 		}
 	}
 
 	/**
-	 * Testing SlotPool which exposes internal state via some testing methods.
+	 * Testing SlotPoolImpl which exposes internal state via some testing methods.
 	 */
-	private static final class TestingSlotPool extends SlotPool {
+	private static final class TestingSlotPool extends SlotPoolImpl {
 
 		private volatile Consumer<SlotRequestId> releaseSlotConsumer;
 
 		private volatile Consumer<SlotRequestId> timeoutPendingSlotRequestConsumer;
 
 		public TestingSlotPool(
-				RpcService rpcService,
 				JobID jobId,
 				Clock clock,
 				Time rpcTimeout,
 				Time idleSlotTimeout) {
 			super(
-				rpcService,
 				jobId,
-				LocationPreferenceSchedulingStrategy.getInstance(),
 				clock,
 				rpcTimeout,
 				idleSlotTimeout);
@@ -375,19 +336,16 @@ public class SlotPoolRpcTest extends TestLogger {
 		}
 
 		@Override
-		public CompletableFuture<Acknowledge> releaseSlot(
-			SlotRequestId slotRequestId,
-			@Nullable SlotSharingGroupId slotSharingGroupId,
+		public void releaseSlot(
+			@Nonnull SlotRequestId slotRequestId,
 			@Nullable Throwable cause) {
 			final Consumer<SlotRequestId> currentReleaseSlotConsumer = releaseSlotConsumer;
 
-			final CompletableFuture<Acknowledge> acknowledgeCompletableFuture = super.releaseSlot(slotRequestId, slotSharingGroupId, cause);
+			super.releaseSlot(slotRequestId, cause);
 
 			if (currentReleaseSlotConsumer != null) {
 				currentReleaseSlotConsumer.accept(slotRequestId);
 			}
-
-			return acknowledgeCompletableFuture;
 		}
 
 		@Override
@@ -401,29 +359,20 @@ public class SlotPoolRpcTest extends TestLogger {
 			super.timeoutPendingSlotRequest(slotRequestId);
 		}
 
-		CompletableFuture<Boolean> containsAllocatedSlot(AllocationID allocationId) {
-			return callAsync(
-				() -> getAllocatedSlots().contains(allocationId),
-				timeout);
+		boolean containsAllocatedSlot(AllocationID allocationId) {
+			return getAllocatedSlots().contains(allocationId);
 		}
 
-		CompletableFuture<Boolean> containsAvailableSlot(AllocationID allocationId) {
-			return callAsync(
-				() -> getAvailableSlots().contains(allocationId),
-				timeout);
+		boolean containsAvailableSlot(AllocationID allocationId) {
+			return getAvailableSlots().contains(allocationId);
 		}
 
-		CompletableFuture<Integer> getNumberOfPendingRequests() {
-			return callAsync(
-				() -> getPendingRequests().size(),
-				timeout);
+		int getNumberOfPendingRequests() {
+			return getPendingRequests().size();
 		}
 
-		CompletableFuture<Integer> getNumberOfWaitingForResourceRequests() {
-			return callAsync(
-				() -> getWaitingForResourceManager().size(),
-				timeout);
+		int getNumberOfWaitingForResourceRequests() {
+			return getWaitingForResourceManager().size();
 		}
 	}
-
 }
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolResource.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolResource.java
index fdcade2..ce8aedb 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolResource.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolResource.java
@@ -19,42 +19,41 @@
 package org.apache.flink.runtime.jobmaster.slotpool;
 
 import org.apache.flink.api.common.JobID;
+import org.apache.flink.runtime.concurrent.ComponentMainThreadExecutor;
+import org.apache.flink.runtime.executiongraph.TestingComponentMainThreadExecutorServiceAdapter;
 import org.apache.flink.runtime.jobmaster.JobMasterId;
 import org.apache.flink.runtime.resourcemanager.utils.TestingResourceManagerGateway;
-import org.apache.flink.runtime.rpc.RpcService;
 
 import org.junit.rules.ExternalResource;
 
 import javax.annotation.Nonnull;
 
 /**
- * {@link ExternalResource} which provides a {@link SlotPool}.
+ * {@link ExternalResource} which provides a {@link SlotPoolImpl}.
  */
 public class SlotPoolResource extends ExternalResource {
 
 	@Nonnull
-	private final RpcService rpcService;
+	private final SlotSelectionStrategy schedulingStrategy;
 
-	@Nonnull
-	private final SchedulingStrategy schedulingStrategy;
-
-	private SlotPool slotPool;
+	private SlotPoolImpl slotPool;
 
-	private SlotPoolGateway slotPoolGateway;
+	private Scheduler scheduler;
 
 	private TestingResourceManagerGateway testingResourceManagerGateway;
 
-	public SlotPoolResource(@Nonnull RpcService rpcService, @Nonnull SchedulingStrategy schedulingStrategy) {
-		this.rpcService = rpcService;
+	private final ComponentMainThreadExecutor mainThreadExecutor;
+
+	public SlotPoolResource(@Nonnull SlotSelectionStrategy schedulingStrategy) {
 		this.schedulingStrategy = schedulingStrategy;
+		this.mainThreadExecutor = TestingComponentMainThreadExecutorServiceAdapter.forMainThread();
 		slotPool = null;
-		slotPoolGateway = null;
 		testingResourceManagerGateway = null;
 	}
 
 	public SlotProvider getSlotProvider() {
 		checkInitialized();
-		return slotPool.getSlotProvider();
+		return scheduler;
 	}
 
 	public TestingResourceManagerGateway getTestingResourceManagerGateway() {
@@ -62,9 +61,9 @@ public class SlotPoolResource extends ExternalResource {
 		return testingResourceManagerGateway;
 	}
 
-	public SlotPoolGateway getSlotPoolGateway() {
+	public SlotPoolImpl getSlotPool() {
 		checkInitialized();
-		return slotPoolGateway;
+		return slotPool;
 	}
 
 	private void checkInitialized() {
@@ -79,15 +78,10 @@ public class SlotPoolResource extends ExternalResource {
 
 		testingResourceManagerGateway = new TestingResourceManagerGateway();
 
-		slotPool = new SlotPool(
-			rpcService,
-			new JobID(),
-			schedulingStrategy);
-
-		slotPool.start(JobMasterId.generate(), "foobar");
-
-		slotPoolGateway = slotPool.getSelfGateway(SlotPoolGateway.class);
-
+		slotPool = new SlotPoolImpl(new JobID());
+		scheduler = new SchedulerImpl(schedulingStrategy, slotPool);
+		slotPool.start(JobMasterId.generate(), "foobar", mainThreadExecutor);
+		scheduler.start(mainThreadExecutor);
 		slotPool.connectToResourceManager(testingResourceManagerGateway);
 	}
 
@@ -100,6 +94,6 @@ public class SlotPoolResource extends ExternalResource {
 	}
 
 	private void terminateSlotPool() {
-		slotPool.closeAsync().join();
+		slotPool.close();
 	}
 }
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolSlotSharingTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolSlotSharingTest.java
index 9a736c7..f1447d0 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolSlotSharingTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolSlotSharingTest.java
@@ -28,7 +28,6 @@ import org.apache.flink.runtime.jobmanager.scheduler.ScheduledUnit;
 import org.apache.flink.runtime.jobmaster.LogicalSlot;
 import org.apache.flink.runtime.resourcemanager.SlotRequest;
 import org.apache.flink.runtime.resourcemanager.utils.TestingResourceManagerGateway;
-import org.apache.flink.runtime.rpc.TestingRpcServiceResource;
 import org.apache.flink.runtime.taskexecutor.slot.SlotOffer;
 import org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation;
 import org.apache.flink.runtime.taskmanager.TaskManagerLocation;
@@ -37,7 +36,6 @@ import org.apache.flink.util.ExceptionUtils;
 import org.apache.flink.util.FlinkException;
 import org.apache.flink.util.TestLogger;
 
-import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 
@@ -52,17 +50,13 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 /**
- * Test cases for slot sharing with the {@link SlotPool}.
+ * Test cases for slot sharing with the {@link SlotPoolImpl}.
  */
 public class SlotPoolSlotSharingTest extends TestLogger {
 
-	@ClassRule
-	public static final TestingRpcServiceResource testingRpcServiceResource = new TestingRpcServiceResource();
-
 	@Rule
-	public final SlotPoolResource slotPoolResource = new SlotPoolResource(
-		testingRpcServiceResource.getTestingRpcService(),
-		PreviousAllocationSchedulingStrategy.getInstance());
+	public final SlotPoolResource slotPoolResource =
+		new SlotPoolResource(PreviousAllocationSlotSelectionStrategy.INSTANCE);
 
 	@Test
 	public void testSingleQueuedSharedSlotScheduling() throws Exception {
@@ -72,8 +66,8 @@ public class SlotPoolSlotSharingTest extends TestLogger {
 			(SlotRequest slotRequest) -> allocationIdFuture.complete(slotRequest.getAllocationId()));
 
 		LocalTaskManagerLocation taskManagerLocation = new LocalTaskManagerLocation();
-		final SlotPoolGateway slotPoolGateway = slotPoolResource.getSlotPoolGateway();
-		slotPoolGateway.registerTaskManager(taskManagerLocation.getResourceID()).get();
+		final SlotPoolImpl slotPool = slotPoolResource.getSlotPool();
+		slotPool.registerTaskManager(taskManagerLocation.getResourceID());
 
 		SlotSharingGroupId slotSharingGroupId = new SlotSharingGroupId();
 		final SlotProvider slotProvider = slotPoolResource.getSlotProvider();
@@ -90,7 +84,7 @@ public class SlotPoolSlotSharingTest extends TestLogger {
 
 		final AllocationID allocationId = allocationIdFuture.get();
 
-		CompletableFuture<Boolean> booleanCompletableFuture = slotPoolGateway.offerSlot(
+		boolean booleanCompletableFuture = slotPool.offerSlot(
 			taskManagerLocation,
 			new SimpleAckingTaskManagerGateway(),
 			new SlotOffer(
@@ -98,7 +92,7 @@ public class SlotPoolSlotSharingTest extends TestLogger {
 				0,
 				ResourceProfile.UNKNOWN));
 
-		assertTrue(booleanCompletableFuture.get());
+		assertTrue(booleanCompletableFuture);
 
 		final LogicalSlot logicalSlot = logicalSlotFuture.get();
 
@@ -109,7 +103,7 @@ public class SlotPoolSlotSharingTest extends TestLogger {
 	 * Tests that returned slot futures are failed if the allocation request is failed.
 	 */
 	@Test
-	public void testFailingQueuedSharedSlotScheduling() throws ExecutionException, InterruptedException {
+	public void testFailingQueuedSharedSlotScheduling() throws Exception {
 		final CompletableFuture<AllocationID> allocationIdFuture = new CompletableFuture<>();
 		final TestingResourceManagerGateway testingResourceManagerGateway = slotPoolResource.getTestingResourceManagerGateway();
 		testingResourceManagerGateway.setRequestSlotConsumer(
@@ -128,7 +122,7 @@ public class SlotPoolSlotSharingTest extends TestLogger {
 		final AllocationID allocationId = allocationIdFuture.get();
 
 		// this should fail the returned logical slot future
-		final SlotPoolGateway slotPoolGateway = slotPoolResource.getSlotPoolGateway();
+		final SlotPool slotPoolGateway = slotPoolResource.getSlotPool();
 		slotPoolGateway.failAllocation(allocationId, new FlinkException("Testing Exception"));
 
 		try {
@@ -143,7 +137,7 @@ public class SlotPoolSlotSharingTest extends TestLogger {
 	 * Tests queued slot scheduling with a single slot sharing group
 	 */
 	@Test
-	public void testQueuedSharedSlotScheduling() throws InterruptedException, ExecutionException {
+	public void testQueuedSharedSlotScheduling() throws Exception {
 		final BlockingQueue<AllocationID> allocationIds = new ArrayBlockingQueue<>(2);
 		final TestingResourceManagerGateway testingResourceManagerGateway = slotPoolResource.getTestingResourceManagerGateway();
 		testingResourceManagerGateway.setRequestSlotConsumer(
@@ -151,8 +145,8 @@ public class SlotPoolSlotSharingTest extends TestLogger {
 
 		final TaskManagerLocation taskManagerLocation = new LocalTaskManagerLocation();
 
-		final SlotPoolGateway slotPoolGateway = slotPoolResource.getSlotPoolGateway();
-		slotPoolGateway.registerTaskManager(taskManagerLocation.getResourceID()).get();
+		final SlotPoolImpl slotPool = slotPoolResource.getSlotPool();
+		slotPool.registerTaskManager(taskManagerLocation.getResourceID());
 
 		final SlotSharingGroupId slotSharingGroupId = new SlotSharingGroupId();
 		final JobVertexID jobVertexId1 = new JobVertexID();
@@ -203,10 +197,10 @@ public class SlotPoolSlotSharingTest extends TestLogger {
 		assertFalse(logicalSlotFuture3.isDone());
 		assertFalse(logicalSlotFuture4.isDone());
 
-		final AllocationID allocationId2 = allocationIds.take();
+		allocationIds.take();
 
 		// this should fulfill the first two slot futures
-		CompletableFuture<Boolean> offerFuture = slotPoolGateway.offerSlot(
+		boolean offerFuture = slotPool.offerSlot(
 			taskManagerLocation,
 			new SimpleAckingTaskManagerGateway(),
 			new SlotOffer(
@@ -214,7 +208,7 @@ public class SlotPoolSlotSharingTest extends TestLogger {
 				0,
 				ResourceProfile.UNKNOWN));
 
-		assertTrue(offerFuture.get());
+		assertTrue(offerFuture);
 
 		LogicalSlot logicalSlot1 = logicalSlotFuture1.get();
 		LogicalSlot logicalSlot2 = logicalSlotFuture2.get();
@@ -242,7 +236,7 @@ public class SlotPoolSlotSharingTest extends TestLogger {
 	 * Tests queued slot scheduling with multiple slot sharing groups.
 	 */
 	@Test
-	public void testQueuedMultipleSlotSharingGroups() throws ExecutionException, InterruptedException {
+	public void testQueuedMultipleSlotSharingGroups() throws Exception {
 		final BlockingQueue<AllocationID> allocationIds = new ArrayBlockingQueue<>(4);
 
 		final TestingResourceManagerGateway testingResourceManagerGateway = slotPoolResource.getTestingResourceManagerGateway();
@@ -257,8 +251,8 @@ public class SlotPoolSlotSharingTest extends TestLogger {
 		final JobVertexID jobVertexId3 = new JobVertexID();
 		final JobVertexID jobVertexId4 = new JobVertexID();
 
-		final SlotPoolGateway slotPoolGateway = slotPoolResource.getSlotPoolGateway();
-		slotPoolGateway.registerTaskManager(taskManagerLocation.getResourceID()).get();
+		final SlotPoolImpl slotPool = slotPoolResource.getSlotPool();
+		slotPool.registerTaskManager(taskManagerLocation.getResourceID());
 
 		final SlotProvider slotProvider = slotPoolResource.getSlotProvider();
 		CompletableFuture<LogicalSlot> logicalSlotFuture1 = slotProvider.allocateSlot(
@@ -306,7 +300,7 @@ public class SlotPoolSlotSharingTest extends TestLogger {
 		final AllocationID allocationId1 = allocationIds.take();
 		final AllocationID allocationId2 = allocationIds.take();
 
-		CompletableFuture<Boolean> offerFuture1 = slotPoolGateway.offerSlot(
+		boolean offerFuture1 = slotPool.offerSlot(
 			taskManagerLocation,
 			new SimpleAckingTaskManagerGateway(),
 			new SlotOffer(
@@ -314,7 +308,7 @@ public class SlotPoolSlotSharingTest extends TestLogger {
 				0,
 				ResourceProfile.UNKNOWN));
 
-		CompletableFuture<Boolean> offerFuture2 = slotPoolGateway.offerSlot(
+		boolean offerFuture2 = slotPool.offerSlot(
 			taskManagerLocation,
 			new SimpleAckingTaskManagerGateway(),
 			new SlotOffer(
@@ -322,8 +316,8 @@ public class SlotPoolSlotSharingTest extends TestLogger {
 				0,
 				ResourceProfile.UNKNOWN));
 
-		assertTrue(offerFuture1.get());
-		assertTrue(offerFuture2.get());
+		assertTrue(offerFuture1);
+		assertTrue(offerFuture2);
 
 		LogicalSlot logicalSlot1 = logicalSlotFuture1.get();
 		LogicalSlot logicalSlot2 = logicalSlotFuture2.get();
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolTest.java
index 6e90eb1..2846bb8 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolTest.java
@@ -24,7 +24,9 @@ import org.apache.flink.runtime.clusterframework.types.AllocationID;
 import org.apache.flink.runtime.clusterframework.types.ResourceID;
 import org.apache.flink.runtime.clusterframework.types.ResourceProfile;
 import org.apache.flink.runtime.clusterframework.types.SlotProfile;
+import org.apache.flink.runtime.concurrent.ComponentMainThreadExecutor;
 import org.apache.flink.runtime.concurrent.FutureUtils;
+import org.apache.flink.runtime.executiongraph.TestingComponentMainThreadExecutorServiceAdapter;
 import org.apache.flink.runtime.executiongraph.utils.SimpleAckingTaskManagerGateway;
 import org.apache.flink.runtime.jobgraph.JobVertexID;
 import org.apache.flink.runtime.jobmanager.scheduler.DummyScheduledUnit;
@@ -36,26 +38,19 @@ import org.apache.flink.runtime.messages.Acknowledge;
 import org.apache.flink.runtime.resourcemanager.ResourceManagerGateway;
 import org.apache.flink.runtime.resourcemanager.SlotRequest;
 import org.apache.flink.runtime.resourcemanager.utils.TestingResourceManagerGateway;
-import org.apache.flink.runtime.rpc.RpcService;
-import org.apache.flink.runtime.rpc.RpcUtils;
-import org.apache.flink.runtime.rpc.TestingRpcService;
 import org.apache.flink.runtime.taskexecutor.TaskExecutor;
 import org.apache.flink.runtime.taskexecutor.slot.SlotOffer;
 import org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation;
 import org.apache.flink.runtime.taskmanager.TaskManagerLocation;
 import org.apache.flink.runtime.testingUtils.TestingUtils;
 import org.apache.flink.runtime.util.clock.ManualClock;
-import org.apache.flink.types.SerializableOptional;
 import org.apache.flink.util.ExceptionUtils;
 import org.apache.flink.util.FlinkException;
 import org.apache.flink.util.TestLogger;
 
 import org.hamcrest.Matchers;
-import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import java.util.ArrayDeque;
 import java.util.ArrayList;
@@ -64,6 +59,7 @@ import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.concurrent.ArrayBlockingQueue;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.CompletableFuture;
@@ -83,12 +79,8 @@ import static org.junit.Assert.fail;
 
 public class SlotPoolTest extends TestLogger {
 
-	private static final Logger LOG = LoggerFactory.getLogger(SlotPoolTest.class);
-
 	private final Time timeout = Time.seconds(10L);
 
-	private RpcService rpcService;
-
 	private JobID jobId;
 
 	private TaskManagerLocation taskManagerLocation;
@@ -97,9 +89,11 @@ public class SlotPoolTest extends TestLogger {
 
 	private TestingResourceManagerGateway resourceManagerGateway;
 
+	private ComponentMainThreadExecutor mainThreadExecutor =
+		TestingComponentMainThreadExecutorServiceAdapter.forMainThread();
+
 	@Before
 	public void setUp() throws Exception {
-		this.rpcService = new TestingRpcService();
 		this.jobId = new JobID();
 
 		taskManagerLocation = new LocalTaskManagerLocation();
@@ -107,24 +101,18 @@ public class SlotPoolTest extends TestLogger {
 		resourceManagerGateway = new TestingResourceManagerGateway();
 	}
 
-	@After
-	public void tearDown() throws Exception {
-		RpcUtils.terminateRpcService(rpcService, timeout);
-	}
-
 	@Test
 	public void testAllocateSimpleSlot() throws Exception {
 		CompletableFuture<SlotRequest> slotRequestFuture = new CompletableFuture<>();
-		resourceManagerGateway.setRequestSlotConsumer(slotRequest -> slotRequestFuture.complete(slotRequest));
-
-		final SlotPool slotPool = new SlotPool(rpcService, jobId, LocationPreferenceSchedulingStrategy.getInstance());
+		resourceManagerGateway.setRequestSlotConsumer(slotRequestFuture::complete);
 
-		try {
-			SlotPoolGateway slotPoolGateway = setupSlotPool(slotPool, resourceManagerGateway);
-			slotPoolGateway.registerTaskManager(taskManagerLocation.getResourceID());
+		try (SlotPoolImpl slotPool = new SlotPoolImpl(jobId)) {
+			setupSlotPool(slotPool, resourceManagerGateway, mainThreadExecutor);
+			Scheduler scheduler = setupScheduler(slotPool, mainThreadExecutor);
+			slotPool.registerTaskManager(taskManagerLocation.getResourceID());
 
 			SlotRequestId requestId = new SlotRequestId();
-			CompletableFuture<LogicalSlot> future = slotPoolGateway.allocateSlot(
+			CompletableFuture<LogicalSlot> future = scheduler.allocateSlot(
 				requestId,
 				new DummyScheduledUnit(),
 				SlotProfile.noLocality(DEFAULT_TESTING_PROFILE),
@@ -139,14 +127,12 @@ public class SlotPoolTest extends TestLogger {
 				0,
 				DEFAULT_TESTING_PROFILE);
 
-			assertTrue(slotPoolGateway.offerSlot(taskManagerLocation, taskManagerGateway, slotOffer).get());
+			assertTrue(slotPool.offerSlot(taskManagerLocation, taskManagerGateway, slotOffer));
 
 			LogicalSlot slot = future.get(1, TimeUnit.SECONDS);
 			assertTrue(future.isDone());
 			assertTrue(slot.isAlive());
 			assertEquals(taskManagerLocation, slot.getTaskManagerLocation());
-		} finally {
-			RpcUtils.terminateRpcEndpoint(slotPool, timeout);
 		}
 	}
 
@@ -160,19 +146,18 @@ public class SlotPoolTest extends TestLogger {
 			}
 		});
 
-		final SlotPool slotPool = new SlotPool(rpcService, jobId, LocationPreferenceSchedulingStrategy.getInstance());
-
-		try {
-			SlotPoolGateway slotPoolGateway = setupSlotPool(slotPool, resourceManagerGateway);
+		try (SlotPoolImpl slotPool = new SlotPoolImpl(jobId)) {
+			setupSlotPool(slotPool, resourceManagerGateway, mainThreadExecutor);
+			Scheduler scheduler = setupScheduler(slotPool, mainThreadExecutor);
 			slotPool.registerTaskManager(taskManagerLocation.getResourceID());
 
-			CompletableFuture<LogicalSlot> future1 = slotPoolGateway.allocateSlot(
+			CompletableFuture<LogicalSlot> future1 = scheduler.allocateSlot(
 				new SlotRequestId(),
 				new DummyScheduledUnit(),
 				SlotProfile.noLocality(DEFAULT_TESTING_PROFILE),
 				true,
 				timeout);
-			CompletableFuture<LogicalSlot> future2 = slotPoolGateway.allocateSlot(
+			CompletableFuture<LogicalSlot> future2 = scheduler.allocateSlot(
 				new SlotRequestId(),
 				new DummyScheduledUnit(),
 				SlotProfile.noLocality(DEFAULT_TESTING_PROFILE),
@@ -193,7 +178,7 @@ public class SlotPoolTest extends TestLogger {
 				0,
 				DEFAULT_TESTING_PROFILE);
 
-			assertTrue(slotPoolGateway.offerSlot(taskManagerLocation, taskManagerGateway, slotOffer).get());
+			assertTrue(slotPool.offerSlot(taskManagerLocation, taskManagerGateway, slotOffer));
 
 			LogicalSlot slot1 = future1.get(1, TimeUnit.SECONDS);
 			assertTrue(future1.isDone());
@@ -212,23 +197,20 @@ public class SlotPoolTest extends TestLogger {
 			assertEquals(slot1.getTaskManagerLocation(), slot2.getTaskManagerLocation());
 			assertEquals(slot1.getPhysicalSlotNumber(), slot2.getPhysicalSlotNumber());
 			assertEquals(slot1.getAllocationId(), slot2.getAllocationId());
-		} finally {
-			RpcUtils.terminateRpcEndpoint(slotPool, timeout);
 		}
 	}
 
 	@Test
 	public void testAllocateWithFreeSlot() throws Exception {
 		final CompletableFuture<SlotRequest> slotRequestFuture = new CompletableFuture<>();
-		resourceManagerGateway.setRequestSlotConsumer(slotRequest -> slotRequestFuture.complete(slotRequest));
-
-		final SlotPool slotPool = new SlotPool(rpcService, jobId, LocationPreferenceSchedulingStrategy.getInstance());
+		resourceManagerGateway.setRequestSlotConsumer(slotRequestFuture::complete);
 
-		try {
-			SlotPoolGateway slotPoolGateway = setupSlotPool(slotPool, resourceManagerGateway);
-			slotPoolGateway.registerTaskManager(taskManagerLocation.getResourceID());
+		try (SlotPoolImpl slotPool = new SlotPoolImpl(jobId)) {
+			setupSlotPool(slotPool, resourceManagerGateway, mainThreadExecutor);
+			Scheduler scheduler = setupScheduler(slotPool, mainThreadExecutor);
+			slotPool.registerTaskManager(taskManagerLocation.getResourceID());
 
-			CompletableFuture<LogicalSlot> future1 = slotPoolGateway.allocateSlot(
+			CompletableFuture<LogicalSlot> future1 = scheduler.allocateSlot(
 				new SlotRequestId(),
 				new DummyScheduledUnit(),
 				SlotProfile.noLocality(DEFAULT_TESTING_PROFILE),
@@ -243,7 +225,7 @@ public class SlotPoolTest extends TestLogger {
 				0,
 				DEFAULT_TESTING_PROFILE);
 
-			assertTrue(slotPoolGateway.offerSlot(taskManagerLocation, taskManagerGateway, slotOffer).get());
+			assertTrue(slotPool.offerSlot(taskManagerLocation, taskManagerGateway, slotOffer));
 
 			LogicalSlot slot1 = future1.get(1, TimeUnit.SECONDS);
 			assertTrue(future1.isDone());
@@ -251,7 +233,7 @@ public class SlotPoolTest extends TestLogger {
 			// return this slot to pool
 			slot1.releaseSlot();
 
-			CompletableFuture<LogicalSlot> future2 = slotPoolGateway.allocateSlot(
+			CompletableFuture<LogicalSlot> future2 = scheduler.allocateSlot(
 				new SlotRequestId(),
 				new DummyScheduledUnit(),
 				SlotProfile.noLocality(DEFAULT_TESTING_PROFILE),
@@ -267,8 +249,6 @@ public class SlotPoolTest extends TestLogger {
 			assertTrue(slot2.isAlive());
 			assertEquals(slot1.getTaskManagerLocation(), slot2.getTaskManagerLocation());
 			assertEquals(slot1.getPhysicalSlotNumber(), slot2.getPhysicalSlotNumber());
-		} finally {
-			RpcUtils.terminateRpcEndpoint(slotPool, timeout);
 		}
 	}
 
@@ -276,15 +256,14 @@ public class SlotPoolTest extends TestLogger {
 	public void testOfferSlot() throws Exception {
 		final CompletableFuture<SlotRequest> slotRequestFuture = new CompletableFuture<>();
 
-		resourceManagerGateway.setRequestSlotConsumer(slotRequest -> slotRequestFuture.complete(slotRequest));
-
-		final SlotPool slotPool = new SlotPool(rpcService, jobId, LocationPreferenceSchedulingStrategy.getInstance());
+		resourceManagerGateway.setRequestSlotConsumer(slotRequestFuture::complete);
 
-		try {
-			SlotPoolGateway slotPoolGateway = setupSlotPool(slotPool, resourceManagerGateway);
-			slotPoolGateway.registerTaskManager(taskManagerLocation.getResourceID());
+		try (SlotPoolImpl slotPool = new SlotPoolImpl(jobId)) {
+			setupSlotPool(slotPool, resourceManagerGateway, mainThreadExecutor);
+			Scheduler scheduler = setupScheduler(slotPool, mainThreadExecutor);
+			slotPool.registerTaskManager(taskManagerLocation.getResourceID());
 
-			CompletableFuture<LogicalSlot> future = slotPoolGateway.allocateSlot(
+			CompletableFuture<LogicalSlot> future = scheduler.allocateSlot(
 				new SlotRequestId(),
 				new DummyScheduledUnit(),
 				SlotProfile.noLocality(DEFAULT_TESTING_PROFILE),
@@ -302,7 +281,7 @@ public class SlotPoolTest extends TestLogger {
 			final TaskManagerLocation invalidTaskManagerLocation = new LocalTaskManagerLocation();
 
 			// slot from unregistered resource
-			assertFalse(slotPoolGateway.offerSlot(invalidTaskManagerLocation, taskManagerGateway, slotOffer).get());
+			assertFalse(slotPool.offerSlot(invalidTaskManagerLocation, taskManagerGateway, slotOffer));
 
 			final SlotOffer nonRequestedSlotOffer = new SlotOffer(
 				new AllocationID(),
@@ -310,33 +289,31 @@ public class SlotPoolTest extends TestLogger {
 				DEFAULT_TESTING_PROFILE);
 
 			// we'll also accept non requested slots
-			assertTrue(slotPoolGateway.offerSlot(taskManagerLocation, taskManagerGateway, nonRequestedSlotOffer).get());
+			assertTrue(slotPool.offerSlot(taskManagerLocation, taskManagerGateway, nonRequestedSlotOffer));
 
 			// accepted slot
-			assertTrue(slotPoolGateway.offerSlot(taskManagerLocation, taskManagerGateway, slotOffer).get());
+			assertTrue(slotPool.offerSlot(taskManagerLocation, taskManagerGateway, slotOffer));
 			LogicalSlot slot = future.get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS);
 			assertTrue(slot.isAlive());
 
 			// duplicated offer with using slot
-			assertTrue(slotPoolGateway.offerSlot(taskManagerLocation, taskManagerGateway, slotOffer).get());
+			assertTrue(slotPool.offerSlot(taskManagerLocation, taskManagerGateway, slotOffer));
 			assertTrue(slot.isAlive());
 
 			final SlotOffer anotherSlotOfferWithSameAllocationId = new SlotOffer(
-					slotRequest.getAllocationId(),
-					1,
-					DEFAULT_TESTING_PROFILE);
-			assertFalse(slotPoolGateway.offerSlot(taskManagerLocation, taskManagerGateway, anotherSlotOfferWithSameAllocationId).get());
+				slotRequest.getAllocationId(),
+				1,
+				DEFAULT_TESTING_PROFILE);
+			assertFalse(slotPool.offerSlot(taskManagerLocation, taskManagerGateway, anotherSlotOfferWithSameAllocationId));
 
 			TaskManagerLocation anotherTaskManagerLocation = new LocalTaskManagerLocation();
-			assertFalse(slotPoolGateway.offerSlot(anotherTaskManagerLocation, taskManagerGateway, slotOffer).get());
+			assertFalse(slotPool.offerSlot(anotherTaskManagerLocation, taskManagerGateway, slotOffer));
 
 			// duplicated offer with free slot
 			slot.releaseSlot();
-			assertTrue(slotPoolGateway.offerSlot(taskManagerLocation, taskManagerGateway, slotOffer).get());
-			assertFalse(slotPoolGateway.offerSlot(taskManagerLocation, taskManagerGateway, anotherSlotOfferWithSameAllocationId).get());
-			assertFalse(slotPoolGateway.offerSlot(anotherTaskManagerLocation, taskManagerGateway, slotOffer).get());
-		} finally {
-			RpcUtils.terminateRpcEndpoint(slotPool, timeout);
+			assertTrue(slotPool.offerSlot(taskManagerLocation, taskManagerGateway, slotOffer));
+			assertFalse(slotPool.offerSlot(taskManagerLocation, taskManagerGateway, anotherSlotOfferWithSameAllocationId));
+			assertFalse(slotPool.offerSlot(anotherTaskManagerLocation, taskManagerGateway, slotOffer));
 		}
 	}
 
@@ -344,15 +321,14 @@ public class SlotPoolTest extends TestLogger {
 	public void testReleaseResource() throws Exception {
 		final CompletableFuture<SlotRequest> slotRequestFuture = new CompletableFuture<>();
 
-		resourceManagerGateway.setRequestSlotConsumer(slotRequest -> slotRequestFuture.complete(slotRequest));
-
-		final SlotPool slotPool = new SlotPool(rpcService, jobId, LocationPreferenceSchedulingStrategy.getInstance());
+		resourceManagerGateway.setRequestSlotConsumer(slotRequestFuture::complete);
 
-		try {
-			SlotPoolGateway slotPoolGateway = setupSlotPool(slotPool, resourceManagerGateway);
-			slotPoolGateway.registerTaskManager(taskManagerLocation.getResourceID());
+		try (SlotPoolImpl slotPool = new SlotPoolImpl(jobId)) {
+			setupSlotPool(slotPool, resourceManagerGateway, mainThreadExecutor);
+			Scheduler scheduler = setupScheduler(slotPool, mainThreadExecutor);
+			slotPool.registerTaskManager(taskManagerLocation.getResourceID());
 
-			CompletableFuture<LogicalSlot> future1 = slotPoolGateway.allocateSlot(
+			CompletableFuture<LogicalSlot> future1 = scheduler.allocateSlot(
 				new SlotRequestId(),
 				new DummyScheduledUnit(),
 				SlotProfile.noLocality(DEFAULT_TESTING_PROFILE),
@@ -361,7 +337,7 @@ public class SlotPoolTest extends TestLogger {
 
 			final SlotRequest slotRequest = slotRequestFuture.get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS);
 
-			CompletableFuture<LogicalSlot> future2 = slotPoolGateway.allocateSlot(
+			CompletableFuture<LogicalSlot> future2 = scheduler.allocateSlot(
 				new SlotRequestId(),
 				new DummyScheduledUnit(),
 				SlotProfile.noLocality(DEFAULT_TESTING_PROFILE),
@@ -373,7 +349,7 @@ public class SlotPoolTest extends TestLogger {
 				0,
 				DEFAULT_TESTING_PROFILE);
 
-			assertTrue(slotPoolGateway.offerSlot(taskManagerLocation, taskManagerGateway, slotOffer).get());
+			assertTrue(slotPool.offerSlot(taskManagerLocation, taskManagerGateway, slotOffer));
 
 			LogicalSlot slot1 = future1.get(1, TimeUnit.SECONDS);
 			assertTrue(future1.isDone());
@@ -384,7 +360,7 @@ public class SlotPoolTest extends TestLogger {
 
 			slot1.tryAssignPayload(dummyPayload);
 
-			slotPoolGateway.releaseTaskManager(taskManagerLocation.getResourceID(), null);
+			slotPool.releaseTaskManager(taskManagerLocation.getResourceID(), null);
 
 			releaseFuture.get();
 			assertFalse(slot1.isAlive());
@@ -392,8 +368,6 @@ public class SlotPoolTest extends TestLogger {
 			// slot released and not usable, second allocation still not fulfilled
 			Thread.sleep(10);
 			assertFalse(future2.isDone());
-		} finally {
-			RpcUtils.terminateRpcEndpoint(slotPool, timeout);
 		}
 	}
 
@@ -404,29 +378,27 @@ public class SlotPoolTest extends TestLogger {
 	 */
 	@Test
 	public void testSlotRequestCancellationUponFailingRequest() throws Exception {
-		final SlotPool slotPool = new SlotPool(rpcService, jobId, LocationPreferenceSchedulingStrategy.getInstance());
-		final CompletableFuture<Acknowledge> requestSlotFuture = new CompletableFuture<>();
-		final CompletableFuture<AllocationID> cancelSlotFuture = new CompletableFuture<>();
-		final CompletableFuture<AllocationID> requestSlotFutureAllocationId = new CompletableFuture<>();
-
-		resourceManagerGateway.setRequestSlotFuture(requestSlotFuture);
-		resourceManagerGateway.setRequestSlotConsumer(slotRequest -> requestSlotFutureAllocationId.complete(slotRequest.getAllocationId()));
-		resourceManagerGateway.setCancelSlotConsumer(allocationID -> cancelSlotFuture.complete(allocationID));
-
-		final ScheduledUnit scheduledUnit = new ScheduledUnit(
-			new JobVertexID(),
-			null,
-			null);
 
-		try {
-			final SlotPoolGateway slotPoolGateway = setupSlotPool(slotPool, resourceManagerGateway);
+		try (SlotPoolImpl slotPool = new SlotPoolImpl(jobId)) {
+			final CompletableFuture<Acknowledge> requestSlotFuture = new CompletableFuture<>();
+			final CompletableFuture<AllocationID> cancelSlotFuture = new CompletableFuture<>();
+			final CompletableFuture<AllocationID> requestSlotFutureAllocationId = new CompletableFuture<>();
+			resourceManagerGateway.setRequestSlotFuture(requestSlotFuture);
+			resourceManagerGateway.setRequestSlotConsumer(slotRequest -> requestSlotFutureAllocationId.complete(slotRequest.getAllocationId()));
+			resourceManagerGateway.setCancelSlotConsumer(cancelSlotFuture::complete);
+			final ScheduledUnit scheduledUnit = new ScheduledUnit(
+				new JobVertexID(),
+				null,
+				null);
+			setupSlotPool(slotPool, resourceManagerGateway, mainThreadExecutor);
+			Scheduler scheduler = setupScheduler(slotPool, mainThreadExecutor);
 
 			SlotProfile slotProfile = new SlotProfile(
 				ResourceProfile.UNKNOWN,
 				Collections.emptyList(),
-				Collections.emptyList());
+				Collections.emptySet());
 
-			CompletableFuture<LogicalSlot> slotFuture = slotPoolGateway.allocateSlot(
+			CompletableFuture<LogicalSlot> slotFuture = scheduler.allocateSlot(
 				new SlotRequestId(),
 				scheduledUnit,
 				slotProfile,
@@ -445,12 +417,6 @@ public class SlotPoolTest extends TestLogger {
 			// check that a failure triggered the slot request cancellation
 			// with the correct allocation id
 			assertEquals(requestSlotFutureAllocationId.get(), cancelSlotFuture.get());
-		} finally {
-			try {
-				RpcUtils.terminateRpcEndpoint(slotPool, timeout);
-			} catch (Exception e) {
-				LOG.warn("Could not properly terminate the SlotPool.", e);
-			}
 		}
 	}
 
@@ -464,28 +430,24 @@ public class SlotPoolTest extends TestLogger {
 	 */
 	@Test
 	public void testFulfillingSlotRequestsWithUnusedOfferedSlots() throws Exception {
-		final SlotPool slotPool = new SlotPool(rpcService, jobId, LocationPreferenceSchedulingStrategy.getInstance());
-
-		final ArrayBlockingQueue<AllocationID> allocationIds = new ArrayBlockingQueue<>(2);
-
-		resourceManagerGateway.setRequestSlotConsumer(
-			(SlotRequest slotRequest) -> allocationIds.offer(slotRequest.getAllocationId()));
 
-		final ArrayBlockingQueue<AllocationID> canceledAllocations = new ArrayBlockingQueue<>(2);
-		resourceManagerGateway.setCancelSlotConsumer(canceledAllocations::offer);
-
-		final SlotRequestId slotRequestId1 = new SlotRequestId();
-		final SlotRequestId slotRequestId2 = new SlotRequestId();
-
-		try {
-			final SlotPoolGateway slotPoolGateway = setupSlotPool(slotPool, resourceManagerGateway);
+		try (SlotPoolImpl slotPool = new SlotPoolImpl(jobId)) {
+			final ArrayBlockingQueue<AllocationID> allocationIds = new ArrayBlockingQueue<>(2);
+			resourceManagerGateway.setRequestSlotConsumer(
+				(SlotRequest slotRequest) -> allocationIds.offer(slotRequest.getAllocationId()));
+			final ArrayBlockingQueue<AllocationID> canceledAllocations = new ArrayBlockingQueue<>(2);
+			resourceManagerGateway.setCancelSlotConsumer(canceledAllocations::offer);
+			final SlotRequestId slotRequestId1 = new SlotRequestId();
+			final SlotRequestId slotRequestId2 = new SlotRequestId();
+			setupSlotPool(slotPool, resourceManagerGateway, mainThreadExecutor);
+			final Scheduler scheduler = setupScheduler(slotPool, mainThreadExecutor);
 
 			final ScheduledUnit scheduledUnit = new ScheduledUnit(
 				new JobVertexID(),
 				null,
 				null);
 
-			CompletableFuture<LogicalSlot> slotFuture1 = slotPoolGateway.allocateSlot(
+			CompletableFuture<LogicalSlot> slotFuture1 = scheduler.allocateSlot(
 				slotRequestId1,
 				scheduledUnit,
 				SlotProfile.noRequirements(),
@@ -495,7 +457,7 @@ public class SlotPoolTest extends TestLogger {
 			// wait for the first slot request
 			final AllocationID allocationId1 = allocationIds.take();
 
-			CompletableFuture<LogicalSlot> slotFuture2 = slotPoolGateway.allocateSlot(
+			CompletableFuture<LogicalSlot> slotFuture2 = scheduler.allocateSlot(
 				slotRequestId2,
 				scheduledUnit,
 				SlotProfile.noRequirements(),
@@ -505,7 +467,7 @@ public class SlotPoolTest extends TestLogger {
 			// wait for the second slot request
 			final AllocationID allocationId2 = allocationIds.take();
 
-			slotPoolGateway.releaseSlot(slotRequestId1, null, null);
+			slotPool.releaseSlot(slotRequestId1, null);
 
 			try {
 				// this should fail with a CancellationException
@@ -520,31 +482,28 @@ public class SlotPoolTest extends TestLogger {
 
 			final SlotOffer slotOffer = new SlotOffer(allocationId1, 0, ResourceProfile.UNKNOWN);
 
-			slotPoolGateway.registerTaskManager(taskManagerLocation.getResourceID()).get();
+			slotPool.registerTaskManager(taskManagerLocation.getResourceID());
 
-			assertTrue(slotPoolGateway.offerSlot(taskManagerLocation, taskManagerGateway, slotOffer).get());
+			assertTrue(slotPool.offerSlot(taskManagerLocation, taskManagerGateway, slotOffer));
 
 			// the slot offer should fulfill the second slot request
 			assertEquals(allocationId1, slotFuture2.get().getAllocationId());
 
 			// check that the second slot allocation has been canceled
 			assertEquals(allocationId2, canceledAllocations.take());
-		} finally {
-			RpcUtils.terminateRpcEndpoint(slotPool, timeout);
 		}
 	}
 
 	/**
-	 * Tests that a SlotPool shutdown releases all registered slots
+	 * Tests that a SlotPoolImpl shutdown releases all registered slots
 	 */
 	@Test
 	public void testShutdownReleasesAllSlots() throws Exception {
-		final SlotPool slotPool = new SlotPool(rpcService, jobId, LocationPreferenceSchedulingStrategy.getInstance());
 
-		try {
-			final SlotPoolGateway slotPoolGateway = setupSlotPool(slotPool, resourceManagerGateway);
+		try (SlotPoolImpl slotPool = new SlotPoolImpl(jobId)) {
+			setupSlotPool(slotPool, resourceManagerGateway, mainThreadExecutor);
 
-			slotPoolGateway.registerTaskManager(taskManagerLocation.getResourceID());
+			slotPool.registerTaskManager(taskManagerLocation.getResourceID());
 
 			final int numSlotOffers = 2;
 
@@ -570,14 +529,12 @@ public class SlotPoolTest extends TestLogger {
 					}
 				});
 
-			final CompletableFuture<Collection<SlotOffer>> acceptedSlotOffersFuture = slotPoolGateway.offerSlots(taskManagerLocation, taskManagerGateway, slotOffers);
-
-			final Collection<SlotOffer> acceptedSlotOffers = acceptedSlotOffersFuture.get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS);
+			final Collection<SlotOffer> acceptedSlotOffers = slotPool.offerSlots(taskManagerLocation, taskManagerGateway, slotOffers);
 
 			assertThat(acceptedSlotOffers, Matchers.equalTo(slotOffers));
 
 			// shut down the slot pool
-			slotPool.closeAsync().get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS);
+			slotPool.close();
 
 			// the shut down operation should have freed all registered slots
 			ArrayList<AllocationID> freedSlots = new ArrayList<>(numSlotOffers);
@@ -587,23 +544,18 @@ public class SlotPoolTest extends TestLogger {
 			}
 
 			assertThat(freedSlots, Matchers.containsInAnyOrder(slotOffers.stream().map(SlotOffer::getAllocationId).toArray()));
-		} finally {
-			RpcUtils.terminateRpcEndpoint(slotPool, timeout);
 		}
 	}
 
 	@Test
 	public void testCheckIdleSlot() throws Exception {
 		final ManualClock clock = new ManualClock();
-		final SlotPool slotPool = new SlotPool(
-			rpcService,
+
+		try (SlotPoolImpl slotPool = new SlotPoolImpl(
 			jobId,
-			LocationPreferenceSchedulingStrategy.getInstance(),
 			clock,
 			TestingUtils.infiniteTime(),
-			timeout);
-
-		try {
+			timeout)) {
 			final BlockingQueue<AllocationID> freedSlots = new ArrayBlockingQueue<>(1);
 			taskManagerGateway.setFreeSlotFunction(
 				(AllocationID allocationId, Throwable cause) ->
@@ -616,25 +568,23 @@ public class SlotPoolTest extends TestLogger {
 					}
 				});
 
-			final SlotPoolGateway slotPoolGateway = setupSlotPool(slotPool, resourceManagerGateway);
+			setupSlotPool(slotPool, resourceManagerGateway, mainThreadExecutor);
 
 			final AllocationID expiredSlotID = new AllocationID();
 			final AllocationID freshSlotID = new AllocationID();
 			final SlotOffer slotToExpire = new SlotOffer(expiredSlotID, 0, ResourceProfile.UNKNOWN);
 			final SlotOffer slotToNotExpire = new SlotOffer(freshSlotID, 1, ResourceProfile.UNKNOWN);
 
-			assertThat(
-				slotPoolGateway.registerTaskManager(taskManagerLocation.getResourceID()).get(),
-				Matchers.is(Acknowledge.get()));
+			assertThat(slotPool.registerTaskManager(taskManagerLocation.getResourceID()),
+				Matchers.is(true));
 
 			assertThat(
-				slotPoolGateway.offerSlot(taskManagerLocation, taskManagerGateway, slotToExpire).get(),
+				slotPool.offerSlot(taskManagerLocation, taskManagerGateway, slotToExpire),
 				Matchers.is(true));
 
 			clock.advanceTime(timeout.toMilliseconds() - 1L, TimeUnit.MILLISECONDS);
 
-			assertThat(
-				slotPoolGateway.offerSlot(taskManagerLocation, taskManagerGateway, slotToNotExpire).get(),
+			assertThat(slotPool.offerSlot(taskManagerLocation, taskManagerGateway, slotToNotExpire),
 				Matchers.is(true));
 
 			clock.advanceTime(1L, TimeUnit.MILLISECONDS);
@@ -645,28 +595,25 @@ public class SlotPoolTest extends TestLogger {
 
 			assertThat(freedSlot, Matchers.is(expiredSlotID));
 			assertThat(freedSlots.isEmpty(), Matchers.is(true));
-		} finally {
-			RpcUtils.terminateRpcEndpoint(slotPool, timeout);
 		}
 	}
 
 	/**
 	 * Tests that idle slots which cannot be released are only recycled if the owning {@link TaskExecutor}
-	 * is still registered at the {@link SlotPool}. See FLINK-9047.
+	 * is still registered at the {@link SlotPoolImpl}. See FLINK-9047.
 	 */
 	@Test
 	public void testReleasingIdleSlotFailed() throws Exception {
 		final ManualClock clock = new ManualClock();
-		final SlotPool slotPool = new SlotPool(
-			rpcService,
+
+		try (SlotPoolImpl slotPool = new SlotPoolImpl(
 			jobId,
-			LocationPreferenceSchedulingStrategy.getInstance(),
 			clock,
 			TestingUtils.infiniteTime(),
-			timeout);
+			timeout)) {
 
-		try {
-			final SlotPoolGateway slotPoolGateway = setupSlotPool(slotPool, resourceManagerGateway);
+			setupSlotPool(slotPool, resourceManagerGateway, mainThreadExecutor);
+			Scheduler scheduler = setupScheduler(slotPool, mainThreadExecutor);
 
 			final AllocationID expiredAllocationId = new AllocationID();
 			final SlotOffer slotToExpire = new SlotOffer(expiredAllocationId, 0, ResourceProfile.UNKNOWN);
@@ -685,26 +632,22 @@ public class SlotPoolTest extends TestLogger {
 			final CompletableFuture<Acknowledge> responseFuture = new CompletableFuture<>();
 			responseQueue.add(responseFuture);
 
-			assertThat(
-				slotPoolGateway.registerTaskManager(taskManagerLocation.getResourceID()).get(),
-				Matchers.is(Acknowledge.get()));
+			assertThat(slotPool.registerTaskManager(taskManagerLocation.getResourceID()), Matchers.is(true));
 
-			assertThat(
-				slotPoolGateway.offerSlot(taskManagerLocation, taskManagerGateway, slotToExpire).get(),
-				Matchers.is(true));
+			assertThat(slotPool.offerSlot(taskManagerLocation, taskManagerGateway, slotToExpire), Matchers.is(true));
 
 			clock.advanceTime(timeout.toMilliseconds(), TimeUnit.MILLISECONDS);
 
 			slotPool.triggerCheckIdleSlot();
 
-			CompletableFuture<LogicalSlot> allocatedSlotFuture = allocateSlot(slotPoolGateway, new SlotRequestId());
+			CompletableFuture<LogicalSlot> allocatedSlotFuture = allocateSlot(scheduler, new SlotRequestId());
 
 			// wait until the slot has been fulfilled with the previously idling slot
 			final LogicalSlot logicalSlot = allocatedSlotFuture.get();
 			assertThat(logicalSlot.getAllocationId(), Matchers.is(expiredAllocationId));
 
 			// return the slot
-			slotPool.getSlotOwner().returnAllocatedSlot(logicalSlot).get();
+			scheduler.returnLogicalSlot(logicalSlot);
 
 			// advance the time so that the returned slot is now idling
 			clock.advanceTime(timeout.toMilliseconds(), TimeUnit.MILLISECONDS);
@@ -712,10 +655,10 @@ public class SlotPoolTest extends TestLogger {
 			slotPool.triggerCheckIdleSlot();
 
 			// request a new slot after the idling slot has been released
-			allocatedSlotFuture = allocateSlot(slotPoolGateway, new SlotRequestId());
+			allocatedSlotFuture = allocateSlot(scheduler, new SlotRequestId());
 
 			// release the TaskExecutor before we get a response from the slot releasing
-			slotPoolGateway.releaseTaskManager(taskManagerLocation.getResourceID(), null).get();
+			slotPool.releaseTaskManager(taskManagerLocation.getResourceID(), null);
 
 			// let the slot releasing fail --> since the owning TaskExecutor is no longer registered
 			// the slot should be discarded
@@ -729,8 +672,6 @@ public class SlotPoolTest extends TestLogger {
 				// expected
 			}
 
-		} finally {
-			RpcUtils.terminateRpcEndpoint(slotPool, timeout);
 		}
 	}
 
@@ -739,21 +680,21 @@ public class SlotPoolTest extends TestLogger {
 	 */
 	@Test
 	public void testFreeFailedSlots() throws Exception {
-		final SlotPool slotPool = new SlotPool(rpcService, jobId, LocationPreferenceSchedulingStrategy.getInstance());
 
-		try {
+		try (SlotPoolImpl slotPool = new SlotPoolImpl(jobId)) {
 			final int parallelism = 5;
 			final ArrayBlockingQueue<AllocationID> allocationIds = new ArrayBlockingQueue<>(parallelism);
 			resourceManagerGateway.setRequestSlotConsumer(
 				slotRequest -> allocationIds.offer(slotRequest.getAllocationId()));
 
-			final SlotPoolGateway slotPoolGateway = setupSlotPool(slotPool, resourceManagerGateway);
+			setupSlotPool(slotPool, resourceManagerGateway, mainThreadExecutor);
+			Scheduler scheduler = setupScheduler(slotPool, mainThreadExecutor);
 
 			final Map<SlotRequestId, CompletableFuture<LogicalSlot>> slotRequestFutures = new HashMap<>(parallelism);
 
 			for (int i = 0; i < parallelism; i++) {
 				final SlotRequestId slotRequestId = new SlotRequestId();
-				slotRequestFutures.put(slotRequestId, allocateSlot(slotPoolGateway, slotRequestId));
+				slotRequestFutures.put(slotRequestId, allocateSlot(scheduler, slotRequestId));
 			}
 
 			final List<SlotOffer> slotOffers = new ArrayList<>(parallelism);
@@ -762,8 +703,8 @@ public class SlotPoolTest extends TestLogger {
 				slotOffers.add(new SlotOffer(allocationIds.take(), i, ResourceProfile.UNKNOWN));
 			}
 
-			slotPoolGateway.registerTaskManager(taskManagerLocation.getResourceID());
-			slotPoolGateway.offerSlots(taskManagerLocation, taskManagerGateway, slotOffers);
+			slotPool.registerTaskManager(taskManagerLocation.getResourceID());
+			slotPool.offerSlots(taskManagerLocation, taskManagerGateway, slotOffers);
 
 			// wait for the completion of both slot futures
 			FutureUtils.waitForAll(slotRequestFutures.values()).get();
@@ -779,23 +720,20 @@ public class SlotPoolTest extends TestLogger {
 			// fail allocations one by one
 			for (int i = 0; i < parallelism - 1; i++) {
 				final SlotOffer slotOffer = slotOffers.get(i);
-				final CompletableFuture<SerializableOptional<ResourceID>> emptyTaskExecutorFuture = slotPoolGateway.failAllocation(
-					slotOffer.getAllocationId(),
-					failException);
+				Optional<ResourceID> emptyTaskExecutorFuture =
+					slotPool.failAllocation(slotOffer.getAllocationId(), failException);
 
-				assertThat(emptyTaskExecutorFuture.get().isPresent(), is(false));
+				assertThat(emptyTaskExecutorFuture.isPresent(), is(false));
 				assertThat(freedSlots.take(), is(equalTo(slotOffer.getAllocationId())));
 			}
 
 			final SlotOffer slotOffer = slotOffers.get(parallelism - 1);
-			final CompletableFuture<SerializableOptional<ResourceID>> emptyTaskExecutorFuture = slotPoolGateway.failAllocation(
+			final Optional<ResourceID> emptyTaskExecutorFuture = slotPool.failAllocation(
 				slotOffer.getAllocationId(),
 				failException);
-			assertThat(emptyTaskExecutorFuture.get().get(), is(equalTo(taskManagerLocation.getResourceID())));
+			assertThat(emptyTaskExecutorFuture.get(), is(equalTo(taskManagerLocation.getResourceID())));
 			assertThat(freedSlots.take(), is(equalTo(slotOffer.getAllocationId())));
 
-		} finally {
-			RpcUtils.terminateRpcEndpoint(slotPool, timeout);
 		}
 	}
 
@@ -804,23 +742,24 @@ public class SlotPoolTest extends TestLogger {
 	 */
 	@Test
 	public void testFailingAllocationFailsPendingSlotRequests() throws Exception {
-		final SlotPool slotPool = new SlotPool(rpcService, jobId, LocationPreferenceSchedulingStrategy.getInstance());
 
-		try {
+		try (SlotPoolImpl slotPool = new SlotPoolImpl(jobId)) {
 			final CompletableFuture<AllocationID> allocationIdFuture = new CompletableFuture<>();
 			resourceManagerGateway.setRequestSlotConsumer(slotRequest -> allocationIdFuture.complete(slotRequest.getAllocationId()));
-			final SlotPoolGateway slotPoolGateway = setupSlotPool(slotPool, resourceManagerGateway);
 
-			final CompletableFuture<LogicalSlot> slotFuture = allocateSlot(slotPoolGateway, new SlotRequestId());
+			setupSlotPool(slotPool, resourceManagerGateway, mainThreadExecutor);
+			Scheduler scheduler = setupScheduler(slotPool, mainThreadExecutor);
+
+			final CompletableFuture<LogicalSlot> slotFuture = allocateSlot(scheduler, new SlotRequestId());
 
 			final AllocationID allocationId = allocationIdFuture.get();
 
 			assertThat(slotFuture.isDone(), is(false));
 
 			final FlinkException cause = new FlinkException("Fail pending slot request failure.");
-			final CompletableFuture<SerializableOptional<ResourceID>> responseFuture = slotPoolGateway.failAllocation(allocationId, cause);
+			final Optional<ResourceID> responseFuture = slotPool.failAllocation(allocationId, cause);
 
-			assertThat(responseFuture.get().isPresent(), is(false));
+			assertThat(responseFuture.isPresent(), is(false));
 
 			try {
 				slotFuture.get();
@@ -828,13 +767,11 @@ public class SlotPoolTest extends TestLogger {
 			} catch (ExecutionException ee) {
 				assertThat(ExceptionUtils.stripExecutionException(ee), equalTo(cause));
 			}
-		} finally {
-			RpcUtils.terminateRpcEndpoint(slotPool, timeout);
 		}
 	}
 
-	private CompletableFuture<LogicalSlot> allocateSlot(SlotPoolGateway slotPoolGateway, SlotRequestId slotRequestId) {
-		return slotPoolGateway.allocateSlot(
+	private CompletableFuture<LogicalSlot> allocateSlot(Scheduler scheduler, SlotRequestId slotRequestId) {
+		return scheduler.allocateSlot(
 			slotRequestId,
 			new DummyScheduledUnit(),
 			SlotProfile.noRequirements(),
@@ -842,15 +779,22 @@ public class SlotPoolTest extends TestLogger {
 			timeout);
 	}
 
-	private static SlotPoolGateway setupSlotPool(
-			SlotPool slotPool,
-			ResourceManagerGateway resourceManagerGateway) throws Exception {
+	private static void setupSlotPool(
+		SlotPoolImpl slotPool,
+		ResourceManagerGateway resourceManagerGateway,
+		ComponentMainThreadExecutor mainThreadExecutable) throws Exception {
 		final String jobManagerAddress = "foobar";
 
-		slotPool.start(JobMasterId.generate(), jobManagerAddress);
+		slotPool.start(JobMasterId.generate(), jobManagerAddress, mainThreadExecutable);
 
 		slotPool.connectToResourceManager(resourceManagerGateway);
+	}
 
-		return slotPool.getSelfGateway(SlotPoolGateway.class);
+	private static Scheduler setupScheduler(
+		SlotPool slotPool,
+		ComponentMainThreadExecutor mainThreadExecutable) {
+		Scheduler scheduler = new SchedulerImpl(LocationPreferenceSlotSelectionStrategy.INSTANCE, slotPool);
+		scheduler.start(mainThreadExecutable);
+		return scheduler;
 	}
 }
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotSharingManagerTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotSharingManagerTest.java
index d4ab867..8e8db1a 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotSharingManagerTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotSharingManagerTest.java
@@ -28,14 +28,17 @@ import org.apache.flink.runtime.jobmanager.scheduler.Locality;
 import org.apache.flink.runtime.jobmanager.slots.DummySlotOwner;
 import org.apache.flink.runtime.jobmaster.LogicalSlot;
 import org.apache.flink.runtime.jobmaster.SlotContext;
+import org.apache.flink.runtime.jobmaster.SlotInfo;
 import org.apache.flink.runtime.jobmaster.SlotRequestId;
 import org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation;
 import org.apache.flink.util.AbstractID;
 import org.apache.flink.util.FlinkException;
 import org.apache.flink.util.TestLogger;
 
+import org.junit.Assert;
 import org.junit.Test;
 
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Objects;
 import java.util.concurrent.CompletableFuture;
@@ -414,27 +417,29 @@ public class SlotSharingManagerTest extends TestLogger {
 			new SlotRequestId());
 
 		AbstractID groupId = new AbstractID();
-		SlotSharingManager.MultiTaskSlotLocality resolvedRootSlotLocality =
-			slotSharingManager.getResolvedRootSlot(groupId, LocationPreferenceSchedulingStrategy.getInstance(), SlotProfile.noRequirements());
 
-		assertNotNull(resolvedRootSlotLocality);
-		assertEquals(Locality.UNCONSTRAINED, resolvedRootSlotLocality.getLocality());
-		assertEquals(rootSlot.getSlotRequestId(), resolvedRootSlotLocality.getMultiTaskSlot().getSlotRequestId());
+		Collection<SlotInfo> slotInfos = slotSharingManager.listResolvedRootSlotInfo(groupId);
+		Assert.assertEquals(1, slotInfos.size());
 
-		SlotSharingManager.MultiTaskSlot resolvedRootSlot = resolvedRootSlotLocality.getMultiTaskSlot();
+		SlotInfo slotInfo = slotInfos.iterator().next();
+		SlotSharingManager.MultiTaskSlot resolvedMultiTaskSlot =
+			slotSharingManager.getResolvedRootSlot(slotInfo);
+
+		SlotSelectionStrategy.SlotInfoAndLocality slotInfoAndLocality =
+			LocationPreferenceSlotSelectionStrategy.INSTANCE.selectBestSlotForProfile(slotInfos, SlotProfile.noRequirements()).get();
+
+		assertNotNull(resolvedMultiTaskSlot);
+		assertEquals(Locality.UNCONSTRAINED, slotInfoAndLocality.getLocality());
+		assertEquals(rootSlot.getSlotRequestId(), resolvedMultiTaskSlot.getSlotRequestId());
 
 		// occupy the resolved root slot
-		resolvedRootSlot.allocateSingleTaskSlot(
+		resolvedMultiTaskSlot.allocateSingleTaskSlot(
 			new SlotRequestId(),
 			groupId,
-			resolvedRootSlotLocality.getLocality());
+			Locality.UNCONSTRAINED);
 
-		SlotSharingManager.MultiTaskSlotLocality resolvedRootSlot1 = slotSharingManager.getResolvedRootSlot(
-			groupId,
-			LocationPreferenceSchedulingStrategy.getInstance(),
-			SlotProfile.noRequirements());
-
-		assertNull(resolvedRootSlot1);
+		slotInfos = slotSharingManager.listResolvedRootSlotInfo(groupId);
+		assertTrue(slotInfos.isEmpty());
 	}
 
 	/**
@@ -473,28 +478,28 @@ public class SlotSharingManagerTest extends TestLogger {
 		AbstractID groupId = new AbstractID();
 
 		SlotProfile slotProfile = SlotProfile.preferredLocality(ResourceProfile.UNKNOWN, Collections.singleton(taskManagerLocation));
-		SlotSharingManager.MultiTaskSlotLocality resolvedRootSlot1 = slotSharingManager.getResolvedRootSlot(
-			groupId,
-			LocationPreferenceSchedulingStrategy.getInstance(),
-			slotProfile);
-		assertNotNull(resolvedRootSlot1);
-		assertEquals(Locality.LOCAL, resolvedRootSlot1.getLocality());
-		assertEquals(rootSlot2.getSlotRequestId(), resolvedRootSlot1.getMultiTaskSlot().getSlotRequestId());
+
+		Collection<SlotInfo> slotInfos = slotSharingManager.listResolvedRootSlotInfo(groupId);
+		SlotSelectionStrategy.SlotInfoAndLocality slotInfoAndLocality =
+			LocationPreferenceSlotSelectionStrategy.INSTANCE.selectBestSlotForProfile(slotInfos, slotProfile).get();
+		SlotSharingManager.MultiTaskSlot resolvedRootSlot = slotSharingManager.getResolvedRootSlot(slotInfoAndLocality.getSlotInfo());
+
+		assertNotNull(resolvedRootSlot);
+		assertEquals(Locality.LOCAL, slotInfoAndLocality.getLocality());
+		assertEquals(rootSlot2.getSlotRequestId(), resolvedRootSlot.getSlotRequestId());
 
 		// occupy the slot
-		resolvedRootSlot1.getMultiTaskSlot().allocateSingleTaskSlot(
+		resolvedRootSlot.allocateSingleTaskSlot(
 			new SlotRequestId(),
 			groupId,
-			resolvedRootSlot1.getLocality());
-
-		SlotSharingManager.MultiTaskSlotLocality resolvedRootSlot2 = slotSharingManager.getResolvedRootSlot(
-			groupId,
-			LocationPreferenceSchedulingStrategy.getInstance(),
-			slotProfile);
-
-		assertNotNull(resolvedRootSlot2);
-		assertNotSame(Locality.LOCAL, (resolvedRootSlot2.getLocality()));
-		assertEquals(rootSlot1.getSlotRequestId(), resolvedRootSlot2.getMultiTaskSlot().getSlotRequestId());
+			slotInfoAndLocality.getLocality());
+
+		slotInfos = slotSharingManager.listResolvedRootSlotInfo(groupId);
+		slotInfoAndLocality = LocationPreferenceSlotSelectionStrategy.INSTANCE.selectBestSlotForProfile(slotInfos, slotProfile).get();
+		resolvedRootSlot = slotSharingManager.getResolvedRootSlot(slotInfoAndLocality.getSlotInfo());
+		assertNotNull(resolvedRootSlot);
+		assertNotSame(Locality.LOCAL, (slotInfoAndLocality.getLocality()));
+		assertEquals(rootSlot1.getSlotRequestId(), resolvedRootSlot.getSlotRequestId());
 	}
 
 	@Test
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/TestingAllocatedSlotActions.java b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/TestingAllocatedSlotActions.java
index 159d076..85d9a15 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/TestingAllocatedSlotActions.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/TestingAllocatedSlotActions.java
@@ -18,14 +18,12 @@
 
 package org.apache.flink.runtime.jobmaster.slotpool;
 
-import org.apache.flink.api.java.tuple.Tuple3;
-import org.apache.flink.runtime.instance.SlotSharingGroupId;
+import org.apache.flink.api.java.tuple.Tuple2;
 import org.apache.flink.runtime.jobmaster.SlotRequestId;
-import org.apache.flink.runtime.messages.Acknowledge;
 
+import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
-import java.util.concurrent.CompletableFuture;
 import java.util.function.Consumer;
 
 /**
@@ -33,20 +31,18 @@ import java.util.function.Consumer;
  */
 public class TestingAllocatedSlotActions implements AllocatedSlotActions {
 
-	private volatile Consumer<Tuple3<SlotRequestId, SlotSharingGroupId, Throwable>> releaseSlotConsumer;
+	private volatile Consumer<Tuple2<SlotRequestId, Throwable>> releaseSlotConsumer;
 
-	public void setReleaseSlotConsumer(@Nullable Consumer<Tuple3<SlotRequestId, SlotSharingGroupId, Throwable>> releaseSlotConsumer) {
+	public void setReleaseSlotConsumer(@Nullable Consumer<Tuple2<SlotRequestId, Throwable>> releaseSlotConsumer) {
 		this.releaseSlotConsumer = releaseSlotConsumer;
 	}
 
 	@Override
-	public CompletableFuture<Acknowledge> releaseSlot(SlotRequestId slotRequestId, @Nullable SlotSharingGroupId slotSharingGroupId, @Nullable Throwable cause) {
-		Consumer<Tuple3<SlotRequestId, SlotSharingGroupId, Throwable>> currentReleaseSlotConsumer = this.releaseSlotConsumer;
+	public void releaseSlot(@Nonnull SlotRequestId slotRequestId, @Nullable Throwable cause) {
+		Consumer<Tuple2<SlotRequestId, Throwable>> currentReleaseSlotConsumer = this.releaseSlotConsumer;
 
 		if (currentReleaseSlotConsumer != null) {
-			currentReleaseSlotConsumer.accept(Tuple3.of(slotRequestId, slotSharingGroupId, cause));
+			currentReleaseSlotConsumer.accept(Tuple2.of(slotRequestId, cause));
 		}
-
-		return CompletableFuture.completedFuture(Acknowledge.get());
 	}
 }