@Override public JobSubmissionResult submitJob(JobGraph jobGraph, ClassLoader classLoader) throws ProgramInvocationException { if (isDetached()) { return super.runDetached(jobGraph, classLoader); } else { return super.run(jobGraph, classLoader); } } }
/** * This method assumes that the context environment is prepared, or the execution * will be a local execution by default. */ public void invokeInteractiveModeForExecution() throws ProgramInvocationException{ if (isUsingInteractiveMode()) { callMainMethod(mainClass, args); } else { throw new ProgramInvocationException("Cannot invoke a plan-based program directly."); } }
/** * Creates the optimized plan for a given program, using this client's compiler. * * @param prog The program to be compiled. * @return The compiled and optimized plan, as returned by the compiler. * @throws CompilerException Thrown, if the compiler encounters an illegal situation. * @throws ProgramInvocationException Thrown, if the program could not be instantiated from its jar file. */ private static OptimizedPlan getOptimizedPlan(Optimizer compiler, JobWithJars prog, int parallelism) throws CompilerException, ProgramInvocationException { return getOptimizedPlan(compiler, prog.getPlan(), parallelism); }
@Override public JobExecutionResult execute(String jobName) throws Exception { Plan p = createProgramPlan(jobName); JobWithJars toRun = new JobWithJars(p, this.jarFilesToAttach, this.classpathsToAttach, this.userCodeClassLoader); this.lastJobExecutionResult = client.run(toRun, getParallelism(), savepointSettings).getJobExecutionResult(); return this.lastJobExecutionResult; }
@Override public void stop() throws Exception { synchronized (lock) { if (client != null) { client.shutdown(); client = null; } } }
@Override public JobExecutionResult execute(String jobName) throws Exception { Plan p = createProgramPlan(jobName); setDetachedPlan(ClusterClient.getOptimizedPlan(client.compiler, p, getParallelism())); LOG.warn("Job was executed in detached mode, the results will be available on completion."); this.lastJobExecutionResult = DetachedJobExecutionResult.INSTANCE; return this.lastJobExecutionResult; }
@Override public String getExecutionPlan() throws Exception { Plan plan = createProgramPlan("unnamed job"); OptimizedPlan op = ClusterClient.getOptimizedPlan(client.compiler, plan, getParallelism()); PlanJSONDumpGenerator gen = new PlanJSONDumpGenerator(); return gen.getOptimizerPlanAsJSON(op); }
public JobSubmissionResult run(FlinkPlan compiledPlan, List<URL> libraries, List<URL> classpaths, ClassLoader classLoader, SavepointRestoreSettings savepointSettings) throws ProgramInvocationException { JobGraph job = getJobGraph(flinkConfig, compiledPlan, libraries, classpaths, savepointSettings); return submitJob(job, classLoader); }
/** * Finishes this Context Environment's execution by explicitly running the plan constructed. */ JobSubmissionResult finalizeExecute() throws ProgramInvocationException { return client.run(detachedPlan, jarFilesToAttach, classpathsToAttach, userCodeClassLoader, savepointSettings); }
public static JobGraph getJobGraph(Configuration flinkConfig, PackagedProgram prog, FlinkPlan optPlan, SavepointRestoreSettings savepointSettings) throws ProgramInvocationException { return getJobGraph(flinkConfig, optPlan, prog.getAllLibraries(), prog.getClasspaths(), savepointSettings); }
@Override public void run() { try { program.invokeInteractiveModeForExecution(); } catch (ProgramInvocationException ignored) { if (ignored.getCause() == null || !(ignored.getCause() instanceof JobCancellationException)) { ignored.printStackTrace(); } } } });
@Override public JobExecutionResult execute(String jobName) throws Exception { Plan plan = createProgramPlan(jobName); this.optimizerPlan = compiler.compile(plan); // do not go on with anything now! throw new ProgramAbortException(); }
@Override public String getExecutionPlan() throws Exception { Plan plan = createProgramPlan("unused"); this.previewPlan = Optimizer.createPreOptimizedPlan(plan); // do not go on with anything now! throw new OptimizerPlanEnvironment.ProgramAbortException(); }
@Override public String toString() { return "Context Environment (parallelism = " + (getParallelism() == ExecutionConfig.PARALLELISM_DEFAULT ? "default" : getParallelism()) + ") : " + getIdString(); }
public void setAsContext() { ExecutionEnvironmentFactory factory = new ExecutionEnvironmentFactory() { @Override public ExecutionEnvironment createExecutionEnvironment() { return PreviewPlanEnvironment.this; } }; initializeContextEnvironment(factory); }
private void setAsContext() { ExecutionEnvironmentFactory factory = new ExecutionEnvironmentFactory() { @Override public ExecutionEnvironment createExecutionEnvironment() { return OptimizerPlanEnvironment.this; } }; initializeContextEnvironment(factory); }
static void unsetContext() { resetContextEnvironment(); } }
@Override public void shutdown() throws Exception { super.shutdown(); }
@Override public String getExecutionPlan() throws Exception { Plan plan = createProgramPlan(null, false); this.optimizerPlan = compiler.compile(plan); // do not go on with anything now! throw new ProgramAbortException(); }
@Override public JobExecutionResult execute(String jobName) throws Exception { this.plan = createProgramPlan(jobName); this.previewPlan = Optimizer.createPreOptimizedPlan(plan); // do not go on with anything now! throw new OptimizerPlanEnvironment.ProgramAbortException(); }