Search in sources :

Example 1 with PlanGenerator

use of org.apache.flink.api.java.utils.PlanGenerator in project flink by apache.

the class ExecutionEnvironment method createProgramPlan.

/**
 * Creates the program's {@link Plan}. The plan is a description of all data sources, data
 * sinks, and operations and how they interact, as an isolated unit that can be executed with an
 * {@link PipelineExecutor}. Obtaining a plan and starting it with an executor is an alternative
 * way to run a program and is only possible if the program consists only of distributed
 * operations.
 *
 * @param jobName The name attached to the plan (displayed in logs and monitoring).
 * @param clearSinks Whether or not to start a new stage of execution.
 * @return The program's plan.
 */
@Internal
public Plan createProgramPlan(String jobName, boolean clearSinks) {
    checkNotNull(jobName);
    if (this.sinks.isEmpty()) {
        if (wasExecuted) {
            throw new RuntimeException("No new data sinks have been defined since the " + "last execution. The last execution refers to the latest call to " + "'execute()', 'count()', 'collect()', or 'print()'.");
        } else {
            throw new RuntimeException("No data sinks have been created yet. " + "A program needs at least one sink that consumes data. " + "Examples are writing the data set or printing it.");
        }
    }
    final PlanGenerator generator = new PlanGenerator(sinks, config, getParallelism(), cacheFile, jobName);
    final Plan plan = generator.generate();
    // clear all the sinks such that the next execution does not redo everything
    if (clearSinks) {
        this.sinks.clear();
        wasExecuted = true;
    }
    return plan;
}
Also used : WrappingRuntimeException(org.apache.flink.util.WrappingRuntimeException) PlanGenerator(org.apache.flink.api.java.utils.PlanGenerator) Plan(org.apache.flink.api.common.Plan) Internal(org.apache.flink.annotation.Internal)

Aggregations

Internal (org.apache.flink.annotation.Internal)1 Plan (org.apache.flink.api.common.Plan)1 PlanGenerator (org.apache.flink.api.java.utils.PlanGenerator)1 WrappingRuntimeException (org.apache.flink.util.WrappingRuntimeException)1