Search in sources :

Example 11 with SlotRequestId

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

the class DeclarativeSlotPoolBridgeResourceDeclarationTest method testRequirementsDecreasedOnSlotFreeing.

@Test
public void testRequirementsDecreasedOnSlotFreeing() throws Exception {
    declarativeSlotPoolBridge.start(jobMasterId, "localhost", mainThreadExecutor);
    final PhysicalSlot newSlot = createAllocatedSlot(new AllocationID());
    declarativeSlotPoolBridge.newSlotsAreAvailable(Collections.singleton(newSlot));
    final SlotRequestId slotRequestId = new SlotRequestId();
    declarativeSlotPoolBridge.allocateAvailableSlot(slotRequestId, newSlot.getAllocationId(), ResourceProfile.UNKNOWN);
    // releasing (==freeing) a [reserved] slot should decrease the requirements
    declarativeSlotPoolBridge.releaseSlot(slotRequestId, new RuntimeException("Test exception"));
    assertThat(requirementListener.getRequirements().getResourceCount(ResourceProfile.UNKNOWN), is(0));
}
Also used : SlotRequestId(org.apache.flink.runtime.jobmaster.SlotRequestId) AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) Test(org.junit.Test)

Example 12 with SlotRequestId

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

the class DeclarativeSlotPoolBridgeResourceDeclarationTest method testRequirementsDecreasedOnSlotAllocationFailure.

@Test
public void testRequirementsDecreasedOnSlotAllocationFailure() throws Exception {
    declarativeSlotPoolBridge.start(jobMasterId, "localhost", mainThreadExecutor);
    final PhysicalSlot newSlot = createAllocatedSlot(new AllocationID());
    declarativeSlotPoolBridge.newSlotsAreAvailable(Collections.singleton(newSlot));
    declarativeSlotPoolBridge.allocateAvailableSlot(new SlotRequestId(), newSlot.getAllocationId(), ResourceProfile.UNKNOWN);
    // releasing (==freeing) a [reserved] slot should decrease the requirements
    declarativeSlotPoolBridge.failAllocation(newSlot.getTaskManagerLocation().getResourceID(), newSlot.getAllocationId(), new RuntimeException("Test exception"));
    assertThat(requirementListener.getRequirements().getResourceCount(ResourceProfile.UNKNOWN), is(0));
}
Also used : SlotRequestId(org.apache.flink.runtime.jobmaster.SlotRequestId) AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) Test(org.junit.Test)

Example 13 with SlotRequestId

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

the class PhysicalSlotProviderImplWithSpreadOutStrategyTest method testSlotAllocationFulfilledWithPreferredInputOverwrittingSpreadOut.

@Test
public void testSlotAllocationFulfilledWithPreferredInputOverwrittingSpreadOut() throws ExecutionException, InterruptedException {
    physicalSlotProviderResource.registerSlotOffersFromNewTaskExecutor(ResourceProfile.ANY, ResourceProfile.ANY);
    physicalSlotProviderResource.registerSlotOffersFromNewTaskExecutor(ResourceProfile.ANY, ResourceProfile.ANY);
    PhysicalSlotRequest request0 = physicalSlotProviderResource.createSimpleRequest();
    PhysicalSlotRequest.Result result0 = physicalSlotProviderResource.allocateSlot(request0).get();
    TaskManagerLocation preferredTaskManagerLocation = result0.getPhysicalSlot().getTaskManagerLocation();
    PhysicalSlotRequest request1 = new PhysicalSlotRequest(new SlotRequestId(), SlotProfileTestingUtils.preferredLocality(ResourceProfile.ANY, Collections.singleton(preferredTaskManagerLocation)), false);
    PhysicalSlotRequest.Result result1 = physicalSlotProviderResource.allocateSlot(request1).get();
    assertThat(result1.getPhysicalSlot().getTaskManagerLocation(), is(preferredTaskManagerLocation));
}
Also used : SlotRequestId(org.apache.flink.runtime.jobmaster.SlotRequestId) TaskManagerLocation(org.apache.flink.runtime.taskmanager.TaskManagerLocation) Test(org.junit.Test)

Example 14 with SlotRequestId

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

the class PhysicalSlotRequestBulkCheckerImplTest method testBulkUnfulfillableWithSlotAlreadyAssignedToBulk.

@Test
public void testBulkUnfulfillableWithSlotAlreadyAssignedToBulk() {
    final SlotRequestId slotRequestId = new SlotRequestId();
    final PhysicalSlotRequestBulkImpl bulk = createPhysicalSlotRequestBulk(slotRequestId, new SlotRequestId());
    final PhysicalSlot slot = addOneSlot();
    bulk.markRequestFulfilled(slotRequestId, slot.getAllocationId());
    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 15 with SlotRequestId

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

the class PhysicalSlotRequestBulkCheckerImplTest method testBulkUnfulfillableWithInsufficientSlots.

@Test
public void testBulkUnfulfillableWithInsufficientSlots() {
    final PhysicalSlotRequestBulk bulk = createPhysicalSlotRequestBulk(new SlotRequestId(), new SlotRequestId());
    addOneSlot();
    assertThat(isFulfillable(bulk), is(false));
}
Also used : SlotRequestId(org.apache.flink.runtime.jobmaster.SlotRequestId) Test(org.junit.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