use of org.apache.flink.runtime.jobmaster.slotpool.PhysicalSlotRequestBulk in project flink by apache.
the class SlotSharingExecutionSlotAllocatorTest method testSchedulePendingRequestBulkTimeoutCheck.
@Test
public void testSchedulePendingRequestBulkTimeoutCheck() {
TestingPhysicalSlotRequestBulkChecker bulkChecker = new TestingPhysicalSlotRequestBulkChecker();
AllocationContext context = createBulkCheckerContextWithEv12GroupAndEv3Group(bulkChecker);
context.allocateSlotsFor(EV1, EV3);
PhysicalSlotRequestBulk bulk = bulkChecker.getBulk();
assertThat(bulk.getPendingRequests(), hasSize(2));
assertThat(bulk.getPendingRequests(), containsInAnyOrder(RESOURCE_PROFILE.multiply(2), RESOURCE_PROFILE));
assertThat(bulk.getAllocationIdsOfFulfilledRequests(), hasSize(0));
assertThat(bulkChecker.getTimeout(), is(ALLOCATION_TIMEOUT));
}
use of org.apache.flink.runtime.jobmaster.slotpool.PhysicalSlotRequestBulk in project flink by apache.
the class SlotSharingExecutionSlotAllocatorTest method testRequestFulfilledInBulk.
@Test
public void testRequestFulfilledInBulk() {
TestingPhysicalSlotRequestBulkChecker bulkChecker = new TestingPhysicalSlotRequestBulkChecker();
AllocationContext context = createBulkCheckerContextWithEv12GroupAndEv3Group(bulkChecker);
context.allocateSlotsFor(EV1, EV3);
AllocationID allocationId = new AllocationID();
ResourceProfile pendingSlotResourceProfile = fulfilOneOfTwoSlotRequestsAndGetPendingProfile(context, allocationId);
PhysicalSlotRequestBulk bulk = bulkChecker.getBulk();
assertThat(bulk.getPendingRequests(), hasSize(1));
assertThat(bulk.getPendingRequests(), containsInAnyOrder(pendingSlotResourceProfile));
assertThat(bulk.getAllocationIdsOfFulfilledRequests(), hasSize(1));
assertThat(bulk.getAllocationIdsOfFulfilledRequests(), containsInAnyOrder(allocationId));
}
use of org.apache.flink.runtime.jobmaster.slotpool.PhysicalSlotRequestBulk in project flink by apache.
the class SlotSharingExecutionSlotAllocatorTest method testRequestBulkCancel.
@Test
public void testRequestBulkCancel() {
TestingPhysicalSlotRequestBulkChecker bulkChecker = new TestingPhysicalSlotRequestBulkChecker();
AllocationContext context = createBulkCheckerContextWithEv12GroupAndEv3Group(bulkChecker);
// allocate 2 physical slots for 2 groups
List<SlotExecutionVertexAssignment> assignments1 = context.allocateSlotsFor(EV1, EV3);
fulfilOneOfTwoSlotRequestsAndGetPendingProfile(context, new AllocationID());
PhysicalSlotRequestBulk bulk1 = bulkChecker.getBulk();
List<SlotExecutionVertexAssignment> assignments2 = context.allocateSlotsFor(EV2);
// cancelling of (EV1, EV3) releases assignments1 and only one physical slot for EV3
// the second physical slot is held by sharing EV2 from the next bulk
bulk1.cancel(new Throwable());
// return completed logical slot to clear shared slot and release physical slot
CompletableFuture<LogicalSlot> ev1slot = assignments1.get(0).getLogicalSlotFuture();
boolean ev1failed = ev1slot.isCompletedExceptionally();
CompletableFuture<LogicalSlot> ev3slot = assignments1.get(1).getLogicalSlotFuture();
boolean ev3failed = ev3slot.isCompletedExceptionally();
LogicalSlot slot = ev1failed ? ev3slot.join() : ev1slot.join();
releaseLogicalSlot(slot);
// EV3 needs again a physical slot, therefore there are 3 requests overall
context.allocateSlotsFor(EV1, EV3);
assertThat(context.getSlotProvider().getRequests().values(), hasSize(3));
// either EV1 or EV3 logical slot future is fulfilled before cancellation
assertThat(ev1failed != ev3failed, is(true));
assertThat(assignments2.get(0).getLogicalSlotFuture().isCompletedExceptionally(), is(false));
}
use of org.apache.flink.runtime.jobmaster.slotpool.PhysicalSlotRequestBulk in project flink by apache.
the class SlotSharingExecutionSlotAllocatorTest method testBulkClearIfPhysicalSlotRequestFails.
@Test
public void testBulkClearIfPhysicalSlotRequestFails() {
TestingPhysicalSlotRequestBulkChecker bulkChecker = new TestingPhysicalSlotRequestBulkChecker();
AllocationContext context = createBulkCheckerContextWithEv12GroupAndEv3Group(bulkChecker);
context.allocateSlotsFor(EV1, EV3);
SlotRequestId slotRequestId = context.getSlotProvider().getFirstRequestOrFail().getSlotRequestId();
context.getSlotProvider().getResultForRequestId(slotRequestId).completeExceptionally(new Throwable());
PhysicalSlotRequestBulk bulk = bulkChecker.getBulk();
assertThat(bulk.getPendingRequests(), hasSize(0));
}
Aggregations