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);
}
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, () -> {
});
}
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));
}
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);
}
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())));
}
Aggregations