use of org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder in project flink-mirror by flink-ci.
the class ExecutionVertexCancelTest method testCancelFromRunningDidNotFindTask.
@Test
public void testCancelFromRunningDidNotFindTask() {
// this may happen when the task finished or failed while the call was in progress
try {
final ExecutionVertex vertex = getExecutionVertex();
LogicalSlot slot = new TestingLogicalSlotBuilder().setTaskManagerGateway(new CancelSequenceSimpleAckingTaskManagerGateway(1)).createTestingLogicalSlot();
setVertexResource(vertex, slot);
setVertexState(vertex, ExecutionState.RUNNING);
assertEquals(ExecutionState.RUNNING, vertex.getExecutionState());
vertex.cancel();
assertEquals(ExecutionState.CANCELING, vertex.getExecutionState());
assertFalse(vertex.getFailureInfo().isPresent());
assertTrue(vertex.getStateTimestamp(ExecutionState.CREATED) > 0);
assertTrue(vertex.getStateTimestamp(ExecutionState.CANCELING) > 0);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder in project flink-mirror by flink-ci.
the class RemoveCachedShuffleDescriptorTest method createSchedulerAndDeploy.
private DefaultScheduler createSchedulerAndDeploy(JobID jobId, JobVertex v1, JobVertex v2, DistributionPattern distributionPattern, BlobWriter blobWriter) throws Exception {
v2.connectNewDataSetAsInput(v1, distributionPattern, ResultPartitionType.BLOCKING);
final List<JobVertex> ordered = new ArrayList<>(Arrays.asList(v1, v2));
final DefaultScheduler scheduler = createScheduler(jobId, ordered, blobWriter, mainThreadExecutor, ioExecutor);
final ExecutionGraph executionGraph = scheduler.getExecutionGraph();
final TestingLogicalSlotBuilder slotBuilder = new TestingLogicalSlotBuilder();
CompletableFuture.runAsync(() -> {
try {
// Deploy upstream source vertices
deployTasks(executionGraph, v1.getID(), slotBuilder);
// Transition upstream vertices into FINISHED
transitionTasksToFinished(executionGraph, v1.getID());
// Deploy downstream sink vertices
deployTasks(executionGraph, v2.getID(), slotBuilder);
} catch (Exception e) {
throw new RuntimeException("Exceptions shouldn't happen here.", e);
}
}, mainThreadExecutor).join();
return scheduler;
}
use of org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder in project flink-mirror by flink-ci.
the class DeploymentHandleTest method getLogicalSlotReturnsSlotIfFutureCompletedNormally.
@Test
public void getLogicalSlotReturnsSlotIfFutureCompletedNormally() {
final LogicalSlot logicalSlot = new TestingLogicalSlotBuilder().createTestingLogicalSlot();
logicalSlotFuture.complete(logicalSlot);
assertTrue(deploymentHandle.getLogicalSlot().isPresent());
assertSame(logicalSlot, deploymentHandle.getLogicalSlot().get());
}
use of org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder in project flink-mirror by flink-ci.
the class ExecutionGraphToInputsLocationsRetrieverAdapterTest method testGetTaskManagerLocationWhenScheduled.
/**
* Tests that it can get the task manager location in an Execution.
*/
@Test
public void testGetTaskManagerLocationWhenScheduled() throws Exception {
final JobVertex jobVertex = ExecutionGraphTestUtils.createNoOpVertex(1);
final TestingLogicalSlot testingLogicalSlot = new TestingLogicalSlotBuilder().createTestingLogicalSlot();
final ExecutionGraph eg = ExecutionGraphTestUtils.createSimpleTestGraph(jobVertex);
final ExecutionGraphToInputsLocationsRetrieverAdapter inputsLocationsRetriever = new ExecutionGraphToInputsLocationsRetrieverAdapter(eg);
final ExecutionVertex onlyExecutionVertex = eg.getAllExecutionVertices().iterator().next();
onlyExecutionVertex.getCurrentExecutionAttempt().transitionState(ExecutionState.SCHEDULED);
onlyExecutionVertex.deployToSlot(testingLogicalSlot);
ExecutionVertexID executionVertexId = new ExecutionVertexID(jobVertex.getID(), 0);
Optional<CompletableFuture<TaskManagerLocation>> taskManagerLocationOptional = inputsLocationsRetriever.getTaskManagerLocation(executionVertexId);
assertTrue(taskManagerLocationOptional.isPresent());
final CompletableFuture<TaskManagerLocation> taskManagerLocationFuture = taskManagerLocationOptional.get();
assertThat(taskManagerLocationFuture.get(), is(testingLogicalSlot.getTaskManagerLocation()));
}
use of org.apache.flink.runtime.jobmaster.TestingLogicalSlotBuilder in project flink-mirror by flink-ci.
the class FailureHandlingResultSnapshotTest method extractExecutionVertex.
private ExecutionVertex extractExecutionVertex(int pos) {
final ExecutionVertex executionVertex = Iterables.get(executionGraph.getAllExecutionVertices(), pos);
executionVertex.tryAssignResource(new TestingLogicalSlotBuilder().createTestingLogicalSlot());
return executionVertex;
}
Aggregations