use of org.apache.flink.runtime.jobmaster.TestingPayload in project flink by apache.
the class SlotSharingExecutionSlotAllocatorTest method testPhysicalSlotReleaseLogicalSlots.
@Test
public void testPhysicalSlotReleaseLogicalSlots() throws ExecutionException, InterruptedException {
AllocationContext context = AllocationContext.newBuilder().addGroup(EV1, EV2).build();
List<SlotExecutionVertexAssignment> assignments = context.allocateSlotsFor(EV1, EV2);
List<TestingPayload> payloads = assignments.stream().map(assignment -> {
TestingPayload payload = new TestingPayload();
assignment.getLogicalSlotFuture().thenAccept(logicalSlot -> logicalSlot.tryAssignPayload(payload));
return payload;
}).collect(Collectors.toList());
SlotRequestId slotRequestId = context.getSlotProvider().getFirstRequestOrFail().getSlotRequestId();
TestingPhysicalSlot physicalSlot = context.getSlotProvider().getFirstResponseOrFail().get();
assertThat(payloads.stream().allMatch(payload -> payload.getTerminalStateFuture().isDone()), is(false));
assertThat(physicalSlot.getPayload(), notNullValue());
physicalSlot.getPayload().release(new Throwable());
assertThat(payloads.stream().allMatch(payload -> payload.getTerminalStateFuture().isDone()), is(true));
assertThat(context.getSlotProvider().getCancellations().containsKey(slotRequestId), is(true));
context.allocateSlotsFor(EV1, EV2);
// there should be one more physical slot allocation, as the first allocation should be
// removed after releasing all logical slots
assertThat(context.getSlotProvider().getRequests().keySet(), hasSize(2));
}
Aggregations