Java Code Examples for org.apache.flink.optimizer.Optimizer#createPreOptimizedPlan()
The following examples show how to use
org.apache.flink.optimizer.Optimizer#createPreOptimizedPlan() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PreviewPlanDumpTest.java From flink with Apache License 2.0 | 6 votes |
private static void verifyPlanDump(Class<?> entrypoint, String... args) throws Exception { final PackagedProgram program = PackagedProgram .newBuilder() .setEntryPointClassName(entrypoint.getName()) .setArguments(args) .build(); final Pipeline pipeline = PackagedProgramUtils.getPipelineFromProgram(program, new Configuration(), 1, true); assertTrue(pipeline instanceof Plan); final Plan plan = (Plan) pipeline; final List<DataSinkNode> sinks = Optimizer.createPreOptimizedPlan(plan); final PlanJSONDumpGenerator dumper = new PlanJSONDumpGenerator(); final String json = dumper.getPactPlanAsJSON(sinks); try (JsonParser parser = new JsonFactory().createParser(json)) { while (parser.nextToken() != null) { } } }
Example 2
Source File: PreviewPlanEnvironment.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@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(); }
Example 3
Source File: PreviewPlanEnvironment.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@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(); }
Example 4
Source File: PreviewPlanEnvironment.java From flink with Apache License 2.0 | 5 votes |
@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(); }
Example 5
Source File: PreviewPlanEnvironment.java From flink with Apache License 2.0 | 5 votes |
@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(); }
Example 6
Source File: PackagedProgram.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
/** * Returns the analyzed plan without any optimizations. * * @return * the analyzed plan without any optimizations. * @throws ProgramInvocationException Thrown if an error occurred in the * user-provided pact assembler. This may indicate * missing parameters for generation. */ public String getPreviewPlan() throws ProgramInvocationException { Thread.currentThread().setContextClassLoader(this.getUserCodeClassLoader()); List<DataSinkNode> previewPlan; if (isUsingProgramEntryPoint()) { previewPlan = Optimizer.createPreOptimizedPlan(getPlan()); } else if (isUsingInteractiveMode()) { // temporary hack to support the web client PreviewPlanEnvironment env = new PreviewPlanEnvironment(); env.setAsContext(); try { invokeInteractiveModeForExecution(); } catch (ProgramInvocationException e) { throw e; } catch (Throwable t) { // the invocation gets aborted with the preview plan if (env.previewPlan == null) { if (env.preview != null) { return env.preview; } else { throw new ProgramInvocationException("The program caused an error: ", getPlan().getJobId(), t); } } } finally { env.unsetAsContext(); } if (env.previewPlan != null) { previewPlan = env.previewPlan; } else { throw new ProgramInvocationException( "The program plan could not be fetched. The program silently swallowed the control flow exceptions.", getPlan().getJobId()); } } else { throw new RuntimeException(); } PlanJSONDumpGenerator jsonGen = new PlanJSONDumpGenerator(); StringWriter string = new StringWriter(1024); try (PrintWriter pw = new PrintWriter(string)) { jsonGen.dumpPactPlanAsJSON(previewPlan, pw); } return string.toString(); }
Example 7
Source File: PackagedProgram.java From flink with Apache License 2.0 | 4 votes |
/** * Returns the analyzed plan without any optimizations. * * @return * the analyzed plan without any optimizations. * @throws ProgramInvocationException Thrown if an error occurred in the * user-provided pact assembler. This may indicate * missing parameters for generation. */ public String getPreviewPlan() throws ProgramInvocationException { Thread.currentThread().setContextClassLoader(this.getUserCodeClassLoader()); List<DataSinkNode> previewPlan; if (isUsingProgramEntryPoint()) { previewPlan = Optimizer.createPreOptimizedPlan(getPlan()); } else if (isUsingInteractiveMode()) { // temporary hack to support the web client PreviewPlanEnvironment env = new PreviewPlanEnvironment(); env.setAsContext(); try { invokeInteractiveModeForExecution(); } catch (ProgramInvocationException e) { throw e; } catch (Throwable t) { // the invocation gets aborted with the preview plan if (env.previewPlan == null) { if (env.preview != null) { return env.preview; } else { throw new ProgramInvocationException("The program caused an error: ", getPlan().getJobId(), t); } } } finally { env.unsetAsContext(); } if (env.previewPlan != null) { previewPlan = env.previewPlan; } else { throw new ProgramInvocationException( "The program plan could not be fetched. The program silently swallowed the control flow exceptions.", getPlan().getJobId()); } } else { throw new RuntimeException(); } PlanJSONDumpGenerator jsonGen = new PlanJSONDumpGenerator(); StringWriter string = new StringWriter(1024); try (PrintWriter pw = new PrintWriter(string)) { jsonGen.dumpPactPlanAsJSON(previewPlan, pw); } return string.toString(); }
Example 8
Source File: LocalExecutor.java From Flink-CEPplus with Apache License 2.0 | 2 votes |
/** * Creates a JSON representation of the given dataflow plan. * * @param plan The dataflow plan. * @return The dataflow plan (prior to optimization) as a JSON string. */ public static String getPlanAsJSON(Plan plan) { List<DataSinkNode> sinks = Optimizer.createPreOptimizedPlan(plan); return new PlanJSONDumpGenerator().getPactPlanAsJSON(sinks); }
Example 9
Source File: LocalExecutor.java From flink with Apache License 2.0 | 2 votes |
/** * Creates a JSON representation of the given dataflow plan. * * @param plan The dataflow plan. * @return The dataflow plan (prior to optimization) as a JSON string. */ public static String getPlanAsJSON(Plan plan) { List<DataSinkNode> sinks = Optimizer.createPreOptimizedPlan(plan); return new PlanJSONDumpGenerator().getPactPlanAsJSON(sinks); }