Search in sources :

Example 1 with TestingPhysicalSlot

use of org.apache.flink.runtime.scheduler.TestingPhysicalSlot in project flink by apache.

the class ExecutionVertexTest method testFindLatestAllocationIgnoresFailedAttempts.

@Test
public void testFindLatestAllocationIgnoresFailedAttempts() throws Exception {
    final JobVertex source = ExecutionGraphTestUtils.createNoOpVertex(1);
    final JobGraph jobGraph = JobGraphTestUtils.streamingJobGraph(source);
    final TestingPhysicalSlotProvider withLimitedAmountOfPhysicalSlots = TestingPhysicalSlotProvider.createWithLimitedAmountOfPhysicalSlots(1);
    final SchedulerBase scheduler = SchedulerTestingUtils.newSchedulerBuilder(jobGraph, ComponentMainThreadExecutorServiceAdapter.forMainThread()).setExecutionSlotAllocatorFactory(SchedulerTestingUtils.newSlotSharingExecutionSlotAllocatorFactory(withLimitedAmountOfPhysicalSlots)).build();
    scheduler.startScheduling();
    final ExecutionJobVertex sourceExecutionJobVertex = scheduler.getExecutionJobVertex(source.getID());
    final ExecutionVertex sourceExecutionVertex = sourceExecutionJobVertex.getTaskVertices()[0];
    final Execution firstExecution = sourceExecutionVertex.getCurrentExecutionAttempt();
    final TestingPhysicalSlot physicalSlot = withLimitedAmountOfPhysicalSlots.getFirstResponseOrFail().join();
    final AllocationID allocationId = physicalSlot.getAllocationId();
    final TaskManagerLocation taskManagerLocation = physicalSlot.getTaskManagerLocation();
    cancelExecution(firstExecution);
    sourceExecutionVertex.resetForNewExecution();
    assertThat(sourceExecutionVertex.findLatestPriorAllocation()).hasValue(allocationId);
    assertThat(sourceExecutionVertex.findLatestPriorLocation()).hasValue(taskManagerLocation);
    final Execution secondExecution = sourceExecutionVertex.getCurrentExecutionAttempt();
    cancelExecution(secondExecution);
    sourceExecutionVertex.resetForNewExecution();
    assertThat(sourceExecutionVertex.findLatestPriorAllocation()).hasValue(allocationId);
    assertThat(sourceExecutionVertex.findLatestPriorLocation()).hasValue(taskManagerLocation);
}
Also used : TestingPhysicalSlot(org.apache.flink.runtime.scheduler.TestingPhysicalSlot) JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) TaskManagerLocation(org.apache.flink.runtime.taskmanager.TaskManagerLocation) AllocationID(org.apache.flink.runtime.clusterframework.types.AllocationID) TestingPhysicalSlotProvider(org.apache.flink.runtime.scheduler.TestingPhysicalSlotProvider) SchedulerBase(org.apache.flink.runtime.scheduler.SchedulerBase) Test(org.junit.Test)

Example 2 with TestingPhysicalSlot

use of org.apache.flink.runtime.scheduler.TestingPhysicalSlot in project flink by apache.

the class SharedSlotTest method testConstructorFailsIfSlotAlreadyHasAssignedPayload.

@Test(expected = IllegalStateException.class)
public void testConstructorFailsIfSlotAlreadyHasAssignedPayload() {
    final TestingPhysicalSlot physicalSlot = TestingPhysicalSlot.builder().build();
    physicalSlot.tryAssignPayload(new TestingPhysicalSlotPayload());
    new SharedSlot(new SlotRequestId(), physicalSlot, false, () -> {
    });
}
Also used : SlotRequestId(org.apache.flink.runtime.jobmaster.SlotRequestId) TestingPhysicalSlot(org.apache.flink.runtime.scheduler.TestingPhysicalSlot) TestingPhysicalSlotPayload(org.apache.flink.runtime.jobmaster.slotpool.TestingPhysicalSlotPayload) Test(org.junit.Test)

Example 3 with TestingPhysicalSlot

use of org.apache.flink.runtime.scheduler.TestingPhysicalSlot in project flink by apache.

the class SharedSlotTest method testReleaseAlsoReleasesLogicalSlots.

@Test
public void testReleaseAlsoReleasesLogicalSlots() {
    final TestingPhysicalSlot physicalSlot = TestingPhysicalSlot.builder().build();
    final SharedSlot sharedSlot = new SharedSlot(new SlotRequestId(), physicalSlot, false, () -> {
    });
    final LogicalSlot logicalSlot = sharedSlot.allocateLogicalSlot();
    sharedSlot.release(new Exception("test"));
    assertThat(logicalSlot.isAlive(), is(false));
}
Also used : SlotRequestId(org.apache.flink.runtime.jobmaster.SlotRequestId) TestingPhysicalSlot(org.apache.flink.runtime.scheduler.TestingPhysicalSlot) LogicalSlot(org.apache.flink.runtime.jobmaster.LogicalSlot) Test(org.junit.Test)

Example 4 with TestingPhysicalSlot

use of org.apache.flink.runtime.scheduler.TestingPhysicalSlot in project flink by apache.

the class SharedSlotTest method testReturnLogicalSlotRejectsUnknownSlot.

@Test(expected = IllegalStateException.class)
public void testReturnLogicalSlotRejectsUnknownSlot() {
    final TestingPhysicalSlot physicalSlot = TestingPhysicalSlot.builder().build();
    final SharedSlot sharedSlot = new SharedSlot(new SlotRequestId(), physicalSlot, false, () -> {
    });
    final LogicalSlot logicalSlot = new TestingLogicalSlotBuilder().createTestingLogicalSlot();
    logicalSlot.releaseSlot(new Exception("test"));
    sharedSlot.returnLogicalSlot(logicalSlot);
}
Also used : SlotRequestId(org.apache.flink.runtime.jobmaster.SlotRequestId) TestingPhysicalSlot(org.apache.flink.runtime.scheduler.TestingPhysicalSlot) TestingLogicalSlotBuilder(org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder) LogicalSlot(org.apache.flink.runtime.jobmaster.LogicalSlot) Test(org.junit.Test)

Example 5 with TestingPhysicalSlot

use of org.apache.flink.runtime.scheduler.TestingPhysicalSlot in project flink by apache.

the class SharedSlotTest method testAllocateLogicalSlotIssuesUniqueSlotRequestIds.

@Test
public void testAllocateLogicalSlotIssuesUniqueSlotRequestIds() {
    final TestingPhysicalSlot physicalSlot = TestingPhysicalSlot.builder().build();
    final SharedSlot sharedSlot = new SharedSlot(new SlotRequestId(), physicalSlot, false, () -> {
    });
    final LogicalSlot logicalSlot1 = sharedSlot.allocateLogicalSlot();
    final LogicalSlot logicalSlot2 = sharedSlot.allocateLogicalSlot();
    assertThat(logicalSlot1.getSlotRequestId(), not(equalTo(logicalSlot2.getSlotRequestId())));
}
Also used : SlotRequestId(org.apache.flink.runtime.jobmaster.SlotRequestId) TestingPhysicalSlot(org.apache.flink.runtime.scheduler.TestingPhysicalSlot) LogicalSlot(org.apache.flink.runtime.jobmaster.LogicalSlot) Test(org.junit.Test)

Aggregations

TestingPhysicalSlot (org.apache.flink.runtime.scheduler.TestingPhysicalSlot)16 Test (org.junit.Test)15 SlotRequestId (org.apache.flink.runtime.jobmaster.SlotRequestId)13 LogicalSlot (org.apache.flink.runtime.jobmaster.LogicalSlot)8 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)4 CompletableFuture (java.util.concurrent.CompletableFuture)3 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)3 TestingLogicalSlotBuilder (org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder)3 TestingPhysicalSlotPayload (org.apache.flink.runtime.jobmaster.slotpool.TestingPhysicalSlotPayload)3 SchedulerBase (org.apache.flink.runtime.scheduler.SchedulerBase)3 TestingPhysicalSlotProvider (org.apache.flink.runtime.scheduler.TestingPhysicalSlotProvider)3 Consumer (java.util.function.Consumer)2 AllocationID (org.apache.flink.runtime.clusterframework.types.AllocationID)2 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)2 Locality (org.apache.flink.runtime.jobmanager.scheduler.Locality)2 TaskManagerLocation (org.apache.flink.runtime.taskmanager.TaskManagerLocation)2 TestLogger (org.apache.flink.util.TestLogger)2 CoreMatchers.equalTo (org.hamcrest.CoreMatchers.equalTo)2 CoreMatchers.is (org.hamcrest.CoreMatchers.is)2 CoreMatchers.not (org.hamcrest.CoreMatchers.not)2