use of org.apache.flink.runtime.jobmaster.slotpool.PhysicalSlot in project flink by apache.
the class SharedSlotTest method tesDuplicatedReturnLogicalSlotFails.
@Test
public void tesDuplicatedReturnLogicalSlotFails() {
CompletableFuture<PhysicalSlot> slotContextFuture = CompletableFuture.completedFuture(new TestingPhysicalSlot(RP, new AllocationID()));
AtomicInteger released = new AtomicInteger(0);
SharedSlot sharedSlot = SharedSlotBuilder.newBuilder().withSlotContextFuture(slotContextFuture).withExternalReleaseCallback(g -> released.incrementAndGet()).build();
LogicalSlot logicalSlot = sharedSlot.allocateLogicalSlot(EV1).join();
sharedSlot.returnLogicalSlot(logicalSlot);
try {
sharedSlot.returnLogicalSlot(logicalSlot);
fail("Duplicated 'returnLogicalSlot' call should fail with IllegalStateException");
} catch (IllegalStateException e) {
// expected
}
}
use of org.apache.flink.runtime.jobmaster.slotpool.PhysicalSlot in project flink by apache.
the class SharedSlotTest method testAssignAsPayloadToPhysicalSlot.
@Test
public void testAssignAsPayloadToPhysicalSlot() {
CompletableFuture<PhysicalSlot> slotContextFuture = new CompletableFuture<>();
SharedSlot sharedSlot = SharedSlotBuilder.newBuilder().withSlotContextFuture(slotContextFuture).build();
TestingPhysicalSlot physicalSlot = new TestingPhysicalSlot(RP, new AllocationID());
slotContextFuture.complete(physicalSlot);
assertThat(physicalSlot.getPayload(), is(sharedSlot));
}
use of org.apache.flink.runtime.jobmaster.slotpool.PhysicalSlot in project flink by apache.
the class SharedSlot method allocateNonExistentLogicalSlot.
private CompletableFuture<SingleLogicalSlot> allocateNonExistentLogicalSlot(ExecutionVertexID executionVertexId) {
CompletableFuture<SingleLogicalSlot> logicalSlotFuture;
SlotRequestId logicalSlotRequestId = new SlotRequestId();
String logMessageBase = getLogicalSlotString(logicalSlotRequestId, executionVertexId);
LOG.debug("Request a {}", logMessageBase);
logicalSlotFuture = slotContextFuture.thenApply(physicalSlot -> {
LOG.debug("Allocated {}", logMessageBase);
return createLogicalSlot(physicalSlot, logicalSlotRequestId);
});
requestedLogicalSlots.put(executionVertexId, logicalSlotRequestId, logicalSlotFuture);
// If the physical slot request fails (slotContextFuture), it will also fail the
// logicalSlotFuture.
// Therefore, the next `exceptionally` callback will call removeLogicalSlotRequest and do
// the cleanup
// in requestedLogicalSlots and eventually in sharedSlots
logicalSlotFuture.exceptionally(cause -> {
LOG.debug("Failed {}", logMessageBase, cause);
removeLogicalSlotRequest(logicalSlotRequestId);
return null;
});
return logicalSlotFuture;
}
Aggregations