use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.
the class ExecutionVertexDeploymentTest method testDeployWithAsynchronousAnswer.
@Test
public void testDeployWithAsynchronousAnswer() {
try {
final ExecutionVertex vertex = getExecutionVertex();
final LogicalSlot slot = new TestingLogicalSlotBuilder().createTestingLogicalSlot();
assertEquals(ExecutionState.CREATED, vertex.getExecutionState());
vertex.getCurrentExecutionAttempt().transitionState(ExecutionState.SCHEDULED);
vertex.deployToSlot(slot);
// no repeated scheduling
try {
vertex.deployToSlot(slot);
fail("Scheduled from wrong state");
} catch (IllegalStateException e) {
// as expected
}
assertEquals(ExecutionState.DEPLOYING, vertex.getExecutionState());
// no repeated scheduling
try {
vertex.deployToSlot(slot);
fail("Scheduled from wrong state");
} catch (IllegalStateException e) {
// as expected
}
assertTrue(vertex.getStateTimestamp(ExecutionState.CREATED) > 0);
assertTrue(vertex.getStateTimestamp(ExecutionState.DEPLOYING) > 0);
assertTrue(vertex.getStateTimestamp(ExecutionState.RUNNING) == 0);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.
the class ExecutionVertexDeploymentTest method testDeployFailedAsynchronously.
@Test
public void testDeployFailedAsynchronously() {
try {
final ExecutionVertex vertex = getExecutionVertex();
final LogicalSlot slot = new TestingLogicalSlotBuilder().setTaskManagerGateway(new SubmitFailingSimpleAckingTaskManagerGateway()).createTestingLogicalSlot();
assertEquals(ExecutionState.CREATED, vertex.getExecutionState());
vertex.getCurrentExecutionAttempt().transitionState(ExecutionState.SCHEDULED);
vertex.deployToSlot(slot);
// wait until the state transition must be done
for (int i = 0; i < 100; i++) {
if (vertex.getExecutionState() == ExecutionState.FAILED && vertex.getFailureInfo().isPresent()) {
break;
} else {
Thread.sleep(10);
}
}
assertEquals(ExecutionState.FAILED, vertex.getExecutionState());
assertTrue(vertex.getFailureInfo().isPresent());
assertThat(vertex.getFailureInfo().map(ErrorInfo::getExceptionAsString).get(), containsString(ERROR_MESSAGE));
assertTrue(vertex.getStateTimestamp(ExecutionState.CREATED) > 0);
assertTrue(vertex.getStateTimestamp(ExecutionState.DEPLOYING) > 0);
assertTrue(vertex.getStateTimestamp(ExecutionState.FAILED) > 0);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.
the class RemoveCachedShuffleDescriptorTest method deployTasks.
private static void deployTasks(ExecutionGraph executionGraph, JobVertexID jobVertexID, TestingLogicalSlotBuilder slotBuilder) throws JobException, ExecutionException, InterruptedException {
for (ExecutionVertex vertex : Objects.requireNonNull(executionGraph.getJobVertex(jobVertexID)).getTaskVertices()) {
LogicalSlot slot = slotBuilder.createTestingLogicalSlot();
Execution execution = vertex.getCurrentExecutionAttempt();
execution.registerProducedPartitions(slot.getTaskManagerLocation(), true).get();
execution.transitionState(ExecutionState.SCHEDULED);
vertex.tryAssignResource(slot);
vertex.deploy();
}
}
use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.
the class SlotSharingSlotAllocatorTest method testReserveAvailableResources.
@Test
public void testReserveAvailableResources() {
final SlotSharingSlotAllocator slotAllocator = SlotSharingSlotAllocator.createSlotSharingSlotAllocator(TEST_RESERVE_SLOT_FUNCTION, TEST_FREE_SLOT_FUNCTION, TEST_IS_SLOT_FREE_FUNCTION);
final JobInformation jobInformation = new TestJobInformation(Arrays.asList(vertex1, vertex2, vertex3));
final VertexParallelismWithSlotSharing slotAssignments = slotAllocator.determineParallelism(jobInformation, getSlots(50)).get();
final ReservedSlots reservedSlots = slotAllocator.tryReserveResources(slotAssignments).orElseThrow(() -> new RuntimeException("Expected that reservation succeeds."));
final Map<ExecutionVertexID, SlotInfo> expectedAssignments = new HashMap<>();
for (SlotSharingSlotAllocator.ExecutionSlotSharingGroupAndSlot assignment : slotAssignments.getAssignments()) {
for (ExecutionVertexID containedExecutionVertex : assignment.getExecutionSlotSharingGroup().getContainedExecutionVertices()) {
expectedAssignments.put(containedExecutionVertex, assignment.getSlotInfo());
}
}
for (Map.Entry<ExecutionVertexID, SlotInfo> expectedAssignment : expectedAssignments.entrySet()) {
final LogicalSlot assignedSlot = reservedSlots.getSlotFor(expectedAssignment.getKey());
final SlotInfo backingSlot = expectedAssignment.getValue();
assertThat(assignedSlot.getAllocationId(), is(backingSlot.getAllocationId()));
}
}
use of org.apache.flink.runtime.jobmaster.LogicalSlot in project flink by apache.
the class DeployingTasksBenchmarkBase method setup.
public void setup(JobConfiguration jobConfiguration) throws Exception {
super.setup();
jobVertices = createDefaultJobVertices(jobConfiguration);
executionGraph = createAndInitExecutionGraph(jobVertices, jobConfiguration, scheduledExecutorService);
final TestingLogicalSlotBuilder slotBuilder = new TestingLogicalSlotBuilder();
for (ExecutionJobVertex ejv : executionGraph.getVerticesTopologically()) {
for (ExecutionVertex ev : ejv.getTaskVertices()) {
final LogicalSlot slot = slotBuilder.createTestingLogicalSlot();
final Execution execution = ev.getCurrentExecutionAttempt();
execution.registerProducedPartitions(slot.getTaskManagerLocation(), true).get();
if (!execution.tryAssignResource(slot)) {
throw new RuntimeException("Error when assigning slot to execution.");
}
}
}
}
Aggregations