Search in sources :

Example 86 with AllocationID

use of org.apache.flink.runtime.clusterframework.types.AllocationID in project flink by apache.

the class TaskSlotTableImplTest method testSlotAllocationWithDynamicSlotId.

@Test
public void testSlotAllocationWithDynamicSlotId() throws Exception {
    try (final TaskSlotTable<TaskSlotPayload> taskSlotTable = createTaskSlotTableAndStart(2)) {
        final JobID jobId = new JobID();
        final AllocationID allocationId = new AllocationID();
        assertThat(taskSlotTable.allocateSlot(-1, jobId, allocationId, SLOT_TIMEOUT), is(true));
        Iterator<TaskSlot<TaskSlotPayload>> allocatedSlots = taskSlotTable.getAllocatedSlots(jobId);
        assertThat(allocatedSlots.next().getIndex(), is(2));
        assertThat(allocatedSlots.hasNext(), is(false));
        assertThat(taskSlotTable.isAllocated(2, jobId, allocationId), is(true));
    }
}
Also used : AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 87 with AllocationID

use of org.apache.flink.runtime.clusterframework.types.AllocationID in project flink by apache.

the class TaskSlotTableImplTest method testDuplicateDynamicSlotAllocation.

@Test
public void testDuplicateDynamicSlotAllocation() throws Exception {
    try (final TaskSlotTable<TaskSlotPayload> taskSlotTable = createTaskSlotTableAndStart(1)) {
        final JobID jobId = new JobID();
        final AllocationID allocationId = new AllocationID();
        assertThat(taskSlotTable.allocateSlot(-1, jobId, allocationId, SLOT_TIMEOUT), is(true));
        Iterator<TaskSlot<TaskSlotPayload>> allocatedSlots = taskSlotTable.getAllocatedSlots(jobId);
        TaskSlot<TaskSlotPayload> taskSlot1 = allocatedSlots.next();
        assertThat(taskSlotTable.allocateSlot(-1, jobId, allocationId, SLOT_TIMEOUT), is(true));
        allocatedSlots = taskSlotTable.getAllocatedSlots(jobId);
        TaskSlot<TaskSlotPayload> taskSlot2 = allocatedSlots.next();
        assertThat(taskSlotTable.isAllocated(1, jobId, allocationId), is(true));
        assertEquals(taskSlot1, taskSlot2);
        assertThat(allocatedSlots.hasNext(), is(false));
    }
}
Also used : AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 88 with AllocationID

use of org.apache.flink.runtime.clusterframework.types.AllocationID in project flink by apache.

the class TaskSlotTableImplTest method testInconsistentDynamicSlotAllocation.

/**
 * Tests that inconsistent dynamic slot allocation with the same AllocationID to a different
 * slot is rejected.
 */
@Test
public void testInconsistentDynamicSlotAllocation() throws Exception {
    try (final TaskSlotTable<TaskSlotPayload> taskSlotTable = createTaskSlotTableAndStart(1)) {
        final JobID jobId1 = new JobID();
        final JobID jobId2 = new JobID();
        final AllocationID allocationId = new AllocationID();
        assertThat(taskSlotTable.allocateSlot(-1, jobId1, allocationId, SLOT_TIMEOUT), is(true));
        assertThat(taskSlotTable.allocateSlot(-1, jobId2, allocationId, SLOT_TIMEOUT), is(false));
        assertThat(taskSlotTable.isAllocated(1, jobId1, allocationId), is(true));
        Iterator<TaskSlot<TaskSlotPayload>> allocatedSlots = taskSlotTable.getAllocatedSlots(jobId1);
        assertThat(allocatedSlots.next().getAllocationId(), is(allocationId));
        assertThat(allocatedSlots.hasNext(), is(false));
    }
}
Also used : AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 89 with AllocationID

use of org.apache.flink.runtime.clusterframework.types.AllocationID in project flink by apache.

the class TaskSlotTableImplTest method testAllocateSlot.

@Test
public void testAllocateSlot() throws Exception {
    final JobID jobId = new JobID();
    final AllocationID allocationId = new AllocationID();
    try (final TaskSlotTable<TaskSlotPayload> taskSlotTable = createTaskSlotTableWithAllocatedSlot(jobId, allocationId, new TestingSlotActionsBuilder().build())) {
        Iterator<TaskSlot<TaskSlotPayload>> allocatedSlots = taskSlotTable.getAllocatedSlots(jobId);
        TaskSlot<TaskSlotPayload> nextSlot = allocatedSlots.next();
        assertThat(nextSlot.getIndex(), is(0));
        assertThat(nextSlot.getAllocationId(), is(allocationId));
        assertThat(nextSlot.getJobId(), is(jobId));
        assertThat(allocatedSlots.hasNext(), is(false));
    }
}
Also used : AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 90 with AllocationID

use of org.apache.flink.runtime.clusterframework.types.AllocationID in project flink by apache.

the class TaskSlotTableImplTest method testSlotAllocationWithResourceProfileFailure.

@Test
public void testSlotAllocationWithResourceProfileFailure() throws Exception {
    try (final TaskSlotTable<TaskSlotPayload> taskSlotTable = createTaskSlotTableAndStart(2)) {
        final JobID jobId = new JobID();
        final AllocationID allocationId = new AllocationID();
        ResourceProfile resourceProfile = TaskSlotUtils.DEFAULT_RESOURCE_PROFILE;
        resourceProfile = resourceProfile.merge(resourceProfile).merge(resourceProfile);
        assertThat(taskSlotTable.allocateSlot(-1, jobId, allocationId, resourceProfile, SLOT_TIMEOUT), is(false));
        Iterator<TaskSlot<TaskSlotPayload>> allocatedSlots = taskSlotTable.getAllocatedSlots(jobId);
        assertThat(allocatedSlots.hasNext(), is(false));
    }
}
Also used : ResourceProfile(org.apache.flink.runtime.clusterframework.types.ResourceProfile) AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Aggregations

AllocationID (org.apache.flink.runtime.clusterframework.types.AllocationID)194 Test (org.junit.Test)137 JobID (org.apache.flink.api.common.JobID)106 ResourceProfile (org.apache.flink.runtime.clusterframework.types.ResourceProfile)60 CompletableFuture (java.util.concurrent.CompletableFuture)56 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)56 SlotID (org.apache.flink.runtime.clusterframework.types.SlotID)53 ArrayList (java.util.ArrayList)39 ExecutionAttemptID (org.apache.flink.runtime.executiongraph.ExecutionAttemptID)36 Collection (java.util.Collection)35 Time (org.apache.flink.api.common.time.Time)35 Configuration (org.apache.flink.configuration.Configuration)34 Acknowledge (org.apache.flink.runtime.messages.Acknowledge)34 SlotOffer (org.apache.flink.runtime.taskexecutor.slot.SlotOffer)34 List (java.util.List)32 TestLogger (org.apache.flink.util.TestLogger)32 FlinkException (org.apache.flink.util.FlinkException)31 Matchers.is (org.hamcrest.Matchers.is)31 Assert.assertThat (org.junit.Assert.assertThat)31 Arrays (java.util.Arrays)30