Search in sources :

Example 1 with OptimizerPlanEnvironment

use of org.apache.flink.client.program.OptimizerPlanEnvironment in project flink by apache.

the class StreamPlanEnvironment method execute.

@Override
public JobExecutionResult execute(String jobName) throws Exception {
    StreamGraph streamGraph = getStreamGraph();
    streamGraph.setJobName(jobName);
    transformations.clear();
    if (env instanceof OptimizerPlanEnvironment) {
        ((OptimizerPlanEnvironment) env).setPlan(streamGraph);
    } else if (env instanceof PreviewPlanEnvironment) {
        ((PreviewPlanEnvironment) env).setPreview(streamGraph.getStreamingPlanAsJSON());
    }
    throw new OptimizerPlanEnvironment.ProgramAbortException();
}
Also used : OptimizerPlanEnvironment(org.apache.flink.client.program.OptimizerPlanEnvironment) PreviewPlanEnvironment(org.apache.flink.client.program.PreviewPlanEnvironment) StreamGraph(org.apache.flink.streaming.api.graph.StreamGraph)

Example 2 with OptimizerPlanEnvironment

use of org.apache.flink.client.program.OptimizerPlanEnvironment in project beam by apache.

the class FlinkRunnerTest method testEnsureStdoutStdErrIsRestored.

@Test
public void testEnsureStdoutStdErrIsRestored() throws Exception {
    PackagedProgram packagedProgram = getPackagedProgram();
    OptimizerPlanEnvironment env = getOptimizerPlanEnvironment();
    try {
        // Flink will throw an error because no job graph will be generated by the main method
        getPipeline(env, packagedProgram);
        Assert.fail("This should have failed to create the Flink Plan.");
    } catch (ProgramInvocationException e) {
        // Test that Flink wasn't able to intercept the stdout/stderr and we printed to the regular
        // output instead
        MatcherAssert.assertThat(e.getMessage(), allOf(StringContains.containsString("System.out: (none)"), StringContains.containsString("System.err: (none)")));
    }
}
Also used : PackagedProgram(org.apache.flink.client.program.PackagedProgram) OptimizerPlanEnvironment(org.apache.flink.client.program.OptimizerPlanEnvironment) ProgramInvocationException(org.apache.flink.client.program.ProgramInvocationException) Test(org.junit.Test)

Aggregations

OptimizerPlanEnvironment (org.apache.flink.client.program.OptimizerPlanEnvironment)2 PackagedProgram (org.apache.flink.client.program.PackagedProgram)1 PreviewPlanEnvironment (org.apache.flink.client.program.PreviewPlanEnvironment)1 ProgramInvocationException (org.apache.flink.client.program.ProgramInvocationException)1 StreamGraph (org.apache.flink.streaming.api.graph.StreamGraph)1 Test (org.junit.Test)1