tillrohrmann commented on a change in pull request #7662: [FLINK-10431]
Extraction of scheduling-related code from SlotPool into preliminary Scheduler
(rebased)
URL: https://github.com/apache/flink/pull/7662#discussion_r256864748
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/jobmaster/slotpool/SlotPoolTest.java
##########
@@ -805,53 +750,61 @@ public void testFreeFailedSlots() throws Exception {
*/
@Test
public void testFailingAllocationFailsPendingSlotRequests() throws
Exception {
- final SlotPool slotPool = new SlotPool(rpcService, jobId,
LocationPreferenceSchedulingStrategy.getInstance());
- try {
+ try (SlotPoolImpl newSlotPool = 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());
+ SlotPool slotPool = setupSlotPool(newSlotPool,
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();
fail("Expected a slot allocation failure.");
} 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(),
true,
timeout);
}
- private static SlotPoolGateway setupSlotPool(
- SlotPool slotPool,
- ResourceManagerGateway resourceManagerGateway) throws
Exception {
+ private static SlotPoolImpl setupSlotPool(
Review comment:
Let's change it to `void` in order to solve the aliasing problem in the
tests.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services