Search in sources :

Example 21 with NoRestartStrategy

use of org.apache.flink.runtime.executiongraph.restart.NoRestartStrategy in project flink by apache.

the class ExecutionGraphTestUtils method getExecutionVertex.

public static ExecutionJobVertex getExecutionVertex(JobVertexID id, ScheduledExecutorService executor) throws Exception {
    JobVertex ajv = new JobVertex("TestVertex", id);
    ajv.setInvokableClass(mock(AbstractInvokable.class).getClass());
    ExecutionGraph graph = new ExecutionGraph(executor, executor, new JobID(), "test job", new Configuration(), new SerializedValue<>(new ExecutionConfig()), AkkaUtils.getDefaultTimeout(), new NoRestartStrategy(), new Scheduler(ExecutionContext$.MODULE$.fromExecutor(executor)));
    ExecutionJobVertex ejv = spy(new ExecutionJobVertex(graph, ajv, 1, AkkaUtils.getDefaultTimeout()));
    Answer<Void> noop = new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock invocation) {
            return null;
        }
    };
    doAnswer(noop).when(ejv).vertexCancelled(Matchers.anyInt());
    doAnswer(noop).when(ejv).vertexFailed(Matchers.anyInt(), Matchers.any(Throwable.class));
    doAnswer(noop).when(ejv).vertexFinished(Matchers.anyInt());
    return ejv;
}
Also used : Configuration(org.apache.flink.configuration.Configuration) Scheduler(org.apache.flink.runtime.jobmanager.scheduler.Scheduler) ExecutionConfig(org.apache.flink.api.common.ExecutionConfig) NoRestartStrategy(org.apache.flink.runtime.executiongraph.restart.NoRestartStrategy) Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) InvocationOnMock(org.mockito.invocation.InvocationOnMock) JobID(org.apache.flink.api.common.JobID)

Example 22 with NoRestartStrategy

use of org.apache.flink.runtime.executiongraph.restart.NoRestartStrategy in project flink by apache.

the class ExecutionGraphConstructionTest method testAttachViaDataSets.

@Test
public void testAttachViaDataSets() throws Exception {
    final JobID jobId = new JobID();
    final String jobName = "Test Job Sample Name";
    final Configuration cfg = new Configuration();
    // construct part one of the execution graph
    JobVertex v1 = new JobVertex("vertex1");
    JobVertex v2 = new JobVertex("vertex2");
    JobVertex v3 = new JobVertex("vertex3");
    v1.setParallelism(5);
    v2.setParallelism(7);
    v3.setParallelism(2);
    v1.setInvokableClass(AbstractInvokable.class);
    v2.setInvokableClass(AbstractInvokable.class);
    v3.setInvokableClass(AbstractInvokable.class);
    // this creates an intermediate result for v1
    v2.connectNewDataSetAsInput(v1, DistributionPattern.ALL_TO_ALL, ResultPartitionType.PIPELINED);
    // create results for v2 and v3
    IntermediateDataSet v2result = v2.createAndAddResultDataSet(ResultPartitionType.PIPELINED);
    IntermediateDataSet v3result_1 = v3.createAndAddResultDataSet(ResultPartitionType.PIPELINED);
    IntermediateDataSet v3result_2 = v3.createAndAddResultDataSet(ResultPartitionType.PIPELINED);
    List<JobVertex> ordered = new ArrayList<JobVertex>(Arrays.asList(v1, v2, v3));
    ExecutionGraph eg = new ExecutionGraph(TestingUtils.defaultExecutor(), TestingUtils.defaultExecutor(), jobId, jobName, cfg, new SerializedValue<>(new ExecutionConfig()), AkkaUtils.getDefaultTimeout(), new NoRestartStrategy(), new Scheduler(TestingUtils.defaultExecutionContext()));
    try {
        eg.attachJobGraph(ordered);
    } catch (JobException e) {
        e.printStackTrace();
        fail("Job failed with exception: " + e.getMessage());
    }
    // attach the second part of the graph
    JobVertex v4 = new JobVertex("vertex4");
    JobVertex v5 = new JobVertex("vertex5");
    v4.setParallelism(11);
    v5.setParallelism(4);
    v4.setInvokableClass(AbstractInvokable.class);
    v5.setInvokableClass(AbstractInvokable.class);
    v4.connectDataSetAsInput(v2result, DistributionPattern.ALL_TO_ALL);
    v4.connectDataSetAsInput(v3result_1, DistributionPattern.ALL_TO_ALL);
    v5.connectNewDataSetAsInput(v4, DistributionPattern.ALL_TO_ALL, ResultPartitionType.PIPELINED);
    v5.connectDataSetAsInput(v3result_2, DistributionPattern.ALL_TO_ALL);
    List<JobVertex> ordered2 = new ArrayList<JobVertex>(Arrays.asList(v4, v5));
    try {
        eg.attachJobGraph(ordered2);
    } catch (JobException e) {
        e.printStackTrace();
        fail("Job failed with exception: " + e.getMessage());
    }
    // verify
    verifyTestGraph(eg, jobId, v1, v2, v3, v4, v5);
}
Also used : IntermediateDataSet(org.apache.flink.runtime.jobgraph.IntermediateDataSet) Configuration(org.apache.flink.configuration.Configuration) Scheduler(org.apache.flink.runtime.jobmanager.scheduler.Scheduler) ArrayList(java.util.ArrayList) ExecutionConfig(org.apache.flink.api.common.ExecutionConfig) NoRestartStrategy(org.apache.flink.runtime.executiongraph.restart.NoRestartStrategy) JobException(org.apache.flink.runtime.JobException) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 23 with NoRestartStrategy

use of org.apache.flink.runtime.executiongraph.restart.NoRestartStrategy in project flink by apache.

the class ExecutionGraphConstructionTest method testCannotConnectMissingId.

@Test
public void testCannotConnectMissingId() throws Exception {
    final JobID jobId = new JobID();
    final String jobName = "Test Job Sample Name";
    final Configuration cfg = new Configuration();
    // construct part one of the execution graph
    JobVertex v1 = new JobVertex("vertex1");
    v1.setParallelism(7);
    v1.setInvokableClass(AbstractInvokable.class);
    List<JobVertex> ordered = new ArrayList<JobVertex>(Arrays.asList(v1));
    ExecutionGraph eg = new ExecutionGraph(TestingUtils.defaultExecutor(), TestingUtils.defaultExecutor(), jobId, jobName, cfg, new SerializedValue<>(new ExecutionConfig()), AkkaUtils.getDefaultTimeout(), new NoRestartStrategy(), new Scheduler(TestingUtils.defaultExecutionContext()));
    try {
        eg.attachJobGraph(ordered);
    } catch (JobException e) {
        e.printStackTrace();
        fail("Job failed with exception: " + e.getMessage());
    }
    // attach the second part of the graph
    JobVertex v2 = new JobVertex("vertex2");
    v2.setInvokableClass(AbstractInvokable.class);
    v2.connectIdInput(new IntermediateDataSetID(), DistributionPattern.ALL_TO_ALL);
    List<JobVertex> ordered2 = new ArrayList<JobVertex>(Arrays.asList(v2));
    try {
        eg.attachJobGraph(ordered2);
        fail("Attached wrong jobgraph");
    } catch (JobException e) {
    // expected
    }
}
Also used : Configuration(org.apache.flink.configuration.Configuration) Scheduler(org.apache.flink.runtime.jobmanager.scheduler.Scheduler) ArrayList(java.util.ArrayList) ExecutionConfig(org.apache.flink.api.common.ExecutionConfig) NoRestartStrategy(org.apache.flink.runtime.executiongraph.restart.NoRestartStrategy) JobException(org.apache.flink.runtime.JobException) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) IntermediateDataSetID(org.apache.flink.runtime.jobgraph.IntermediateDataSetID) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 24 with NoRestartStrategy

use of org.apache.flink.runtime.executiongraph.restart.NoRestartStrategy in project flink by apache.

the class ExecutionGraphDeploymentTest method createExecutionGraph.

private ExecutionGraph createExecutionGraph(Configuration configuration) throws Exception {
    final ScheduledExecutorService executor = TestingUtils.defaultExecutor();
    final JobID jobId = new JobID();
    final JobGraph jobGraph = new JobGraph(jobId, "test");
    jobGraph.setSnapshotSettings(new JobSnapshottingSettings(Collections.<JobVertexID>emptyList(), Collections.<JobVertexID>emptyList(), Collections.<JobVertexID>emptyList(), 100, 10 * 60 * 1000, 0, 1, ExternalizedCheckpointSettings.none(), null, false));
    return ExecutionGraphBuilder.buildGraph(null, jobGraph, configuration, executor, executor, new ProgrammedSlotProvider(1), getClass().getClassLoader(), new StandaloneCheckpointRecoveryFactory(), Time.seconds(10), new NoRestartStrategy(), new UnregisteredMetricsGroup(), 1, LoggerFactory.getLogger(getClass()));
}
Also used : DirectScheduledExecutorService(org.apache.flink.runtime.testutils.DirectScheduledExecutorService) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) UnregisteredMetricsGroup(org.apache.flink.metrics.groups.UnregisteredMetricsGroup) StandaloneCheckpointRecoveryFactory(org.apache.flink.runtime.checkpoint.StandaloneCheckpointRecoveryFactory) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) JobSnapshottingSettings(org.apache.flink.runtime.jobgraph.tasks.JobSnapshottingSettings) NoRestartStrategy(org.apache.flink.runtime.executiongraph.restart.NoRestartStrategy) JobID(org.apache.flink.api.common.JobID)

Example 25 with NoRestartStrategy

use of org.apache.flink.runtime.executiongraph.restart.NoRestartStrategy in project flink by apache.

the class PointwisePatternTest method testNToN.

@Test
public void testNToN() throws Exception {
    final int N = 23;
    JobVertex v1 = new JobVertex("vertex1");
    JobVertex v2 = new JobVertex("vertex2");
    v1.setParallelism(N);
    v2.setParallelism(N);
    v1.setInvokableClass(AbstractInvokable.class);
    v2.setInvokableClass(AbstractInvokable.class);
    v2.connectNewDataSetAsInput(v1, DistributionPattern.POINTWISE, ResultPartitionType.PIPELINED);
    List<JobVertex> ordered = new ArrayList<JobVertex>(Arrays.asList(v1, v2));
    ExecutionGraph eg = new ExecutionGraph(TestingUtils.defaultExecutor(), TestingUtils.defaultExecutor(), jobId, jobName, cfg, new SerializedValue<>(new ExecutionConfig()), AkkaUtils.getDefaultTimeout(), new NoRestartStrategy(), new Scheduler(TestingUtils.defaultExecutionContext()));
    try {
        eg.attachJobGraph(ordered);
    } catch (JobException e) {
        e.printStackTrace();
        fail("Job failed with exception: " + e.getMessage());
    }
    ExecutionJobVertex target = eg.getAllVertices().get(v2.getID());
    for (ExecutionVertex ev : target.getTaskVertices()) {
        assertEquals(1, ev.getNumberOfInputs());
        ExecutionEdge[] inEdges = ev.getInputEdges(0);
        assertEquals(1, inEdges.length);
        assertEquals(ev.getParallelSubtaskIndex(), inEdges[0].getSource().getPartitionNumber());
    }
}
Also used : Scheduler(org.apache.flink.runtime.jobmanager.scheduler.Scheduler) ArrayList(java.util.ArrayList) ExecutionConfig(org.apache.flink.api.common.ExecutionConfig) NoRestartStrategy(org.apache.flink.runtime.executiongraph.restart.NoRestartStrategy) JobException(org.apache.flink.runtime.JobException) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) Test(org.junit.Test)

Aggregations

NoRestartStrategy (org.apache.flink.runtime.executiongraph.restart.NoRestartStrategy)27 ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)25 JobVertex (org.apache.flink.runtime.jobgraph.JobVertex)25 Scheduler (org.apache.flink.runtime.jobmanager.scheduler.Scheduler)24 JobID (org.apache.flink.api.common.JobID)19 Test (org.junit.Test)19 Configuration (org.apache.flink.configuration.Configuration)18 ArrayList (java.util.ArrayList)17 JobException (org.apache.flink.runtime.JobException)16 UnregisteredMetricsGroup (org.apache.flink.metrics.groups.UnregisteredMetricsGroup)4 IntermediateDataSet (org.apache.flink.runtime.jobgraph.IntermediateDataSet)4 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)4 ActorTaskManagerGateway (org.apache.flink.runtime.jobmanager.slots.ActorTaskManagerGateway)4 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)3 DirectScheduledExecutorService (org.apache.flink.runtime.testutils.DirectScheduledExecutorService)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)2 ExecutionGraph (org.apache.flink.runtime.executiongraph.ExecutionGraph)2 ExecutionJobVertex (org.apache.flink.runtime.executiongraph.ExecutionJobVertex)2