Search in sources :

Example 16 with SlotRequestId

use of org.apache.flink.runtime.jobmaster.SlotRequestId in project flink by apache.

the class PhysicalSlotRequestBulkCheckerImplTest method testBulkPendingOnCheckIfFulfillable.

@Test
public void testBulkPendingOnCheckIfFulfillable() {
    final PhysicalSlotRequestBulkWithTimestamp bulk = createPhysicalSlotRequestBulkWithTimestamp(new SlotRequestId());
    final PhysicalSlot slot = addOneSlot();
    occupyPhysicalSlot(slot, false);
    assertThat(checkBulkTimeout(bulk), is(PhysicalSlotRequestBulkCheckerImpl.TimeoutCheckResult.PENDING));
}
Also used : SlotRequestId(org.apache.flink.runtime.jobmaster.SlotRequestId) PhysicalSlotTestUtils.occupyPhysicalSlot(org.apache.flink.runtime.jobmaster.slotpool.PhysicalSlotTestUtils.occupyPhysicalSlot) PhysicalSlotTestUtils.createPhysicalSlot(org.apache.flink.runtime.jobmaster.slotpool.PhysicalSlotTestUtils.createPhysicalSlot) Test(org.junit.Test)

Example 17 with SlotRequestId

use of org.apache.flink.runtime.jobmaster.SlotRequestId in project flink by apache.

the class PhysicalSlotRequestBulkCheckerImplTest method testBulkPendingOnCheckIfUnfulfillableButNotTimedOut.

@Test
public void testBulkPendingOnCheckIfUnfulfillableButNotTimedOut() {
    final PhysicalSlotRequestBulkWithTimestamp bulk = createPhysicalSlotRequestBulkWithTimestamp(new SlotRequestId());
    assertThat(checkBulkTimeout(bulk), is(PhysicalSlotRequestBulkCheckerImpl.TimeoutCheckResult.PENDING));
}
Also used : SlotRequestId(org.apache.flink.runtime.jobmaster.SlotRequestId) Test(org.junit.Test)

Example 18 with SlotRequestId

use of org.apache.flink.runtime.jobmaster.SlotRequestId in project flink by apache.

the class PhysicalSlotRequestBulkCheckerImplTest method testBulkUnfulfillableWithSlotOccupiedIndefinitely.

@Test
public void testBulkUnfulfillableWithSlotOccupiedIndefinitely() {
    final PhysicalSlotRequestBulk bulk = createPhysicalSlotRequestBulk(new SlotRequestId(), new SlotRequestId());
    final PhysicalSlot slot1 = addOneSlot();
    addOneSlot();
    occupyPhysicalSlot(slot1, true);
    assertThat(isFulfillable(bulk), is(false));
}
Also used : SlotRequestId(org.apache.flink.runtime.jobmaster.SlotRequestId) PhysicalSlotTestUtils.occupyPhysicalSlot(org.apache.flink.runtime.jobmaster.slotpool.PhysicalSlotTestUtils.occupyPhysicalSlot) PhysicalSlotTestUtils.createPhysicalSlot(org.apache.flink.runtime.jobmaster.slotpool.PhysicalSlotTestUtils.createPhysicalSlot) Test(org.junit.Test)

Example 19 with SlotRequestId

use of org.apache.flink.runtime.jobmaster.SlotRequestId in project flink by apache.

the class PhysicalSlotRequestBulkCheckerImplTest method testBulkFulfilledOnCheck.

@Test
public void testBulkFulfilledOnCheck() {
    final SlotRequestId slotRequestId = new SlotRequestId();
    final PhysicalSlotRequestBulkImpl bulk = createPhysicalSlotRequestBulk(slotRequestId);
    bulk.markRequestFulfilled(slotRequestId, new AllocationID());
    final PhysicalSlotRequestBulkWithTimestamp bulkWithTimestamp = new PhysicalSlotRequestBulkWithTimestamp(bulk);
    assertThat(checkBulkTimeout(bulkWithTimestamp), is(PhysicalSlotRequestBulkCheckerImpl.TimeoutCheckResult.FULFILLED));
}
Also used : SlotRequestId(org.apache.flink.runtime.jobmaster.SlotRequestId) AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) Test(org.junit.Test)

Example 20 with SlotRequestId

use of org.apache.flink.runtime.jobmaster.SlotRequestId in project flink by apache.

the class SimpleRequestSlotMatchingStrategyTest method testSlotRequestsThatCanBeFulfilledAreMatched.

@Test
public void testSlotRequestsThatCanBeFulfilledAreMatched() {
    final SimpleRequestSlotMatchingStrategy simpleRequestSlotMatchingStrategy = SimpleRequestSlotMatchingStrategy.INSTANCE;
    final ResourceProfile small = ResourceProfile.newBuilder().setCpuCores(1.0).build();
    final ResourceProfile large = ResourceProfile.newBuilder().setCpuCores(2.0).build();
    final Collection<PhysicalSlot> slots = Arrays.asList(TestingPhysicalSlot.builder().withResourceProfile(small).build(), TestingPhysicalSlot.builder().withResourceProfile(small).build());
    final PendingRequest pendingRequest1 = PendingRequest.createNormalRequest(new SlotRequestId(), large, Collections.emptyList());
    final PendingRequest pendingRequest2 = PendingRequest.createNormalRequest(new SlotRequestId(), small, Collections.emptyList());
    final Collection<PendingRequest> pendingRequests = Arrays.asList(pendingRequest1, pendingRequest2);
    final Collection<RequestSlotMatchingStrategy.RequestSlotMatch> requestSlotMatches = simpleRequestSlotMatchingStrategy.matchRequestsAndSlots(slots, pendingRequests);
    assertThat(requestSlotMatches).hasSize(1);
    assertThat(Iterators.getOnlyElement(requestSlotMatches.iterator()).getPendingRequest().getSlotRequestId()).isEqualTo(pendingRequest2.getSlotRequestId());
}
Also used : SlotRequestId(org.apache.flink.runtime.jobmaster.SlotRequestId) ResourceProfile(org.apache.flink.runtime.clusterframework.types.ResourceProfile) TestingPhysicalSlot(org.apache.flink.runtime.scheduler.TestingPhysicalSlot) Test(org.junit.jupiter.api.Test)

Aggregations

SlotRequestId (org.apache.flink.runtime.jobmaster.SlotRequestId)51 Test (org.junit.Test)40 TestingPhysicalSlot (org.apache.flink.runtime.scheduler.TestingPhysicalSlot)15 LogicalSlot (org.apache.flink.runtime.jobmaster.LogicalSlot)12 CompletableFuture (java.util.concurrent.CompletableFuture)11 AllocationID (org.apache.flink.runtime.clusterframework.types.AllocationID)11 ResourceProfile (org.apache.flink.runtime.clusterframework.types.ResourceProfile)8 TestLogger (org.apache.flink.util.TestLogger)6 Collectors (java.util.stream.Collectors)5 CoreMatchers.is (org.hamcrest.CoreMatchers.is)5 Assert.fail (org.junit.Assert.fail)5 Collection (java.util.Collection)4 Collections (java.util.Collections)4 List (java.util.List)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)4 Consumer (java.util.function.Consumer)4 Time (org.apache.flink.api.common.time.Time)4 Arrays (java.util.Arrays)3 ExecutionException (java.util.concurrent.ExecutionException)3 SlotProfile (org.apache.flink.runtime.clusterframework.types.SlotProfile)3