Search in sources :

Example 1 with PhysicalSlotRequestBulk

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));
}
Also used : PhysicalSlotRequestBulk(org.apache.flink.runtime.jobmaster.slotpool.PhysicalSlotRequestBulk) Test(org.junit.Test)

Example 2 with PhysicalSlotRequestBulk

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));
}
Also used : ResourceProfile(org.apache.flink.runtime.clusterframework.types.ResourceProfile) PhysicalSlotRequestBulk(org.apache.flink.runtime.jobmaster.slotpool.PhysicalSlotRequestBulk) AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) Test(org.junit.Test)

Example 3 with PhysicalSlotRequestBulk

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));
}
Also used : PhysicalSlotRequestBulk(org.apache.flink.runtime.jobmaster.slotpool.PhysicalSlotRequestBulk) AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) LogicalSlot(org.apache.flink.runtime.jobmaster.LogicalSlot) Test(org.junit.Test)

Example 4 with PhysicalSlotRequestBulk

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));
}
Also used : SlotRequestId(org.apache.flink.runtime.jobmaster.SlotRequestId) PhysicalSlotRequestBulk(org.apache.flink.runtime.jobmaster.slotpool.PhysicalSlotRequestBulk) Test(org.junit.Test)

Aggregations

PhysicalSlotRequestBulk (org.apache.flink.runtime.jobmaster.slotpool.PhysicalSlotRequestBulk)4 Test (org.junit.Test)4 AllocationID (org.apache.flink.runtime.clusterframework.types.AllocationID)2 ResourceProfile (org.apache.flink.runtime.clusterframework.types.ResourceProfile)1 LogicalSlot (org.apache.flink.runtime.jobmaster.LogicalSlot)1 SlotRequestId (org.apache.flink.runtime.jobmaster.SlotRequestId)1