Search in sources :

Example 1 with PreviewPlanEnvironment

use of org.apache.flink.client.program.PreviewPlanEnvironment 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 PreviewPlanEnvironment

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

the class DumpCompiledPlanTest method dumpIterativeKMeans.

@Test
public void dumpIterativeKMeans() {
    // prepare the test environment
    PreviewPlanEnvironment env = new PreviewPlanEnvironment();
    env.setAsContext();
    try {
        KMeans.main(new String[] { "--points ", IN_FILE, "--centroids ", IN_FILE, "--output ", OUT_FILE, "--iterations", "123" });
    } catch (OptimizerPlanEnvironment.ProgramAbortException pae) {
    // all good.
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail("KMeans failed with an exception");
    }
    dump(env.getPlan());
}
Also used : OptimizerPlanEnvironment(org.apache.flink.client.program.OptimizerPlanEnvironment) PreviewPlanEnvironment(org.apache.flink.client.program.PreviewPlanEnvironment) JsonParseException(org.codehaus.jackson.JsonParseException) Test(org.junit.Test)

Example 3 with PreviewPlanEnvironment

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

the class PreviewPlanDumpTest method dumpBulkIterationKMeans.

@Test
public void dumpBulkIterationKMeans() {
    // prepare the test environment
    PreviewPlanEnvironment env = new PreviewPlanEnvironment();
    env.setAsContext();
    try {
        ConnectedComponents.main(new String[] { "--vertices", IN_FILE, "--edges", IN_FILE, "--output", OUT_FILE, "--iterations", "123" });
    } catch (OptimizerPlanEnvironment.ProgramAbortException pae) {
    // all good.
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail("ConnectedComponents failed with an exception");
    }
    dump(env.getPlan());
}
Also used : OptimizerPlanEnvironment(org.apache.flink.client.program.OptimizerPlanEnvironment) PreviewPlanEnvironment(org.apache.flink.client.program.PreviewPlanEnvironment) JsonParseException(org.codehaus.jackson.JsonParseException) Test(org.junit.Test)

Example 4 with PreviewPlanEnvironment

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

the class PreviewPlanDumpTest method dumpIterativeKMeans.

@Test
public void dumpIterativeKMeans() {
    // prepare the test environment
    PreviewPlanEnvironment env = new PreviewPlanEnvironment();
    env.setAsContext();
    try {
        KMeans.main(new String[] { "--points ", IN_FILE, "--centroids ", IN_FILE, "--output ", OUT_FILE, "--iterations", "123" });
    } catch (OptimizerPlanEnvironment.ProgramAbortException pae) {
    // all good.
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail("KMeans failed with an exception");
    }
    dump(env.getPlan());
}
Also used : OptimizerPlanEnvironment(org.apache.flink.client.program.OptimizerPlanEnvironment) PreviewPlanEnvironment(org.apache.flink.client.program.PreviewPlanEnvironment) JsonParseException(org.codehaus.jackson.JsonParseException) Test(org.junit.Test)

Example 5 with PreviewPlanEnvironment

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

the class PreviewPlanDumpTest method dumpWordCount.

@Test
public void dumpWordCount() {
    // prepare the test environment
    PreviewPlanEnvironment env = new PreviewPlanEnvironment();
    env.setAsContext();
    try {
        WordCount.main(new String[] { "--input", IN_FILE, "--output", OUT_FILE });
    } catch (OptimizerPlanEnvironment.ProgramAbortException pae) {
    // all good.
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail("WordCount failed with an exception");
    }
    dump(env.getPlan());
}
Also used : OptimizerPlanEnvironment(org.apache.flink.client.program.OptimizerPlanEnvironment) PreviewPlanEnvironment(org.apache.flink.client.program.PreviewPlanEnvironment) JsonParseException(org.codehaus.jackson.JsonParseException) Test(org.junit.Test)

Aggregations

PreviewPlanEnvironment (org.apache.flink.client.program.PreviewPlanEnvironment)16 OptimizerPlanEnvironment (org.apache.flink.client.program.OptimizerPlanEnvironment)15 JsonParseException (org.codehaus.jackson.JsonParseException)12 Test (org.junit.Test)12 ProgramAbortException (org.apache.flink.client.program.OptimizerPlanEnvironment.ProgramAbortException)1 StreamGraph (org.apache.flink.streaming.api.graph.StreamGraph)1