Java Code Examples for org.apache.flink.client.program.ClusterClient#getOptimizedPlan()
The following examples show how to use
org.apache.flink.client.program.ClusterClient#getOptimizedPlan() .
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: ExecutionContext.java From flink with Apache License 2.0 | 6 votes |
private FlinkPlan createPlan(String name, Configuration flinkConfig) { if (streamExecEnv != null) { // special case for Blink planner to apply batch optimizations // note: it also modifies the ExecutionConfig! if (executor instanceof ExecutorBase) { return ((ExecutorBase) executor).generateStreamGraph(name); } return streamExecEnv.getStreamGraph(name); } else { final int parallelism = execEnv.getParallelism(); final Plan unoptimizedPlan = execEnv.createProgramPlan(); unoptimizedPlan.setJobName(name); final Optimizer compiler = new Optimizer(new DataStatistics(), new DefaultCostEstimator(), flinkConfig); return ClusterClient.getOptimizedPlan(compiler, unoptimizedPlan, parallelism); } }
Example 2
Source File: ExecutionContext.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private FlinkPlan createPlan(String name, Configuration flinkConfig) { if (streamExecEnv != null) { final StreamGraph graph = streamExecEnv.getStreamGraph(); graph.setJobName(name); return graph; } else { final int parallelism = execEnv.getParallelism(); final Plan unoptimizedPlan = execEnv.createProgramPlan(); unoptimizedPlan.setJobName(name); final Optimizer compiler = new Optimizer(new DataStatistics(), new DefaultCostEstimator(), flinkConfig); return ClusterClient.getOptimizedPlan(compiler, unoptimizedPlan, parallelism); } }
Example 3
Source File: CliFrontend.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
/** * Executes the info action. * * @param args Command line arguments for the info action. */ protected void info(String[] args) throws CliArgsException, FileNotFoundException, ProgramInvocationException { LOG.info("Running 'info' command."); final Options commandOptions = CliFrontendParser.getInfoCommandOptions(); final CommandLine commandLine = CliFrontendParser.parse(commandOptions, args, true); InfoOptions infoOptions = new InfoOptions(commandLine); // evaluate help flag if (infoOptions.isPrintHelp()) { CliFrontendParser.printHelpForInfo(); return; } if (infoOptions.getJarFilePath() == null) { throw new CliArgsException("The program JAR file was not specified."); } // -------- build the packaged program ------------- LOG.info("Building program from JAR file"); final PackagedProgram program = buildProgram(infoOptions); try { int parallelism = infoOptions.getParallelism(); if (ExecutionConfig.PARALLELISM_DEFAULT == parallelism) { parallelism = defaultParallelism; } LOG.info("Creating program plan dump"); Optimizer compiler = new Optimizer(new DataStatistics(), new DefaultCostEstimator(), configuration); FlinkPlan flinkPlan = ClusterClient.getOptimizedPlan(compiler, program, parallelism); String jsonPlan = null; if (flinkPlan instanceof OptimizedPlan) { jsonPlan = new PlanJSONDumpGenerator().getOptimizerPlanAsJSON((OptimizedPlan) flinkPlan); } else if (flinkPlan instanceof StreamingPlan) { jsonPlan = ((StreamingPlan) flinkPlan).getStreamingPlanAsJSON(); } if (jsonPlan != null) { System.out.println("----------------------- Execution Plan -----------------------"); System.out.println(jsonPlan); System.out.println("--------------------------------------------------------------"); } else { System.out.println("JSON plan could not be generated."); } String description = program.getDescription(); if (description != null) { System.out.println(); System.out.println(description); } else { System.out.println(); System.out.println("No description provided."); } } finally { program.deleteExtractedLibraries(); } }
Example 4
Source File: CliFrontend.java From flink with Apache License 2.0 | 4 votes |
/** * Executes the info action. * * @param args Command line arguments for the info action. */ protected void info(String[] args) throws CliArgsException, FileNotFoundException, ProgramInvocationException { LOG.info("Running 'info' command."); final Options commandOptions = CliFrontendParser.getInfoCommandOptions(); final CommandLine commandLine = CliFrontendParser.parse(commandOptions, args, true); InfoOptions infoOptions = new InfoOptions(commandLine); // evaluate help flag if (infoOptions.isPrintHelp()) { CliFrontendParser.printHelpForInfo(); return; } if (infoOptions.getJarFilePath() == null) { throw new CliArgsException("The program JAR file was not specified."); } // -------- build the packaged program ------------- LOG.info("Building program from JAR file"); final PackagedProgram program = buildProgram(infoOptions); try { int parallelism = infoOptions.getParallelism(); if (ExecutionConfig.PARALLELISM_DEFAULT == parallelism) { parallelism = defaultParallelism; } LOG.info("Creating program plan dump"); Optimizer compiler = new Optimizer(new DataStatistics(), new DefaultCostEstimator(), configuration); FlinkPlan flinkPlan = ClusterClient.getOptimizedPlan(compiler, program, parallelism); String jsonPlan = null; if (flinkPlan instanceof OptimizedPlan) { jsonPlan = new PlanJSONDumpGenerator().getOptimizerPlanAsJSON((OptimizedPlan) flinkPlan); } else if (flinkPlan instanceof StreamingPlan) { jsonPlan = ((StreamingPlan) flinkPlan).getStreamingPlanAsJSON(); } if (jsonPlan != null) { System.out.println("----------------------- Execution Plan -----------------------"); System.out.println(jsonPlan); System.out.println("--------------------------------------------------------------"); } else { System.out.println("JSON plan could not be generated."); } String description = program.getDescription(); if (description != null) { System.out.println(); System.out.println(description); } else { System.out.println(); System.out.println("No description provided."); } } finally { program.deleteExtractedLibraries(); } }