本文整理汇总了Java中org.apache.flink.optimizer.plan.FlinkPlan类的典型用法代码示例。如果您正苦于以下问题:Java FlinkPlan类的具体用法?Java FlinkPlan怎么用?Java FlinkPlan使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FlinkPlan类属于org.apache.flink.optimizer.plan包,在下文中一共展示了FlinkPlan类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getJobGraph
import org.apache.flink.optimizer.plan.FlinkPlan; //导入依赖的package包/类
private JobGraph getJobGraph(FlinkPlan optPlan, List<URL> jarFiles, List<URL> classpaths, SavepointRestoreSettings savepointSettings) {
JobGraph job;
if (optPlan instanceof StreamingPlan) {
job = ((StreamingPlan) optPlan).getJobGraph();
job.setSavepointRestoreSettings(savepointSettings);
} else {
JobGraphGenerator gen = new JobGraphGenerator(this.flinkConfig);
job = gen.compileJobGraph((OptimizedPlan) optPlan);
}
for (URL jar : jarFiles) {
try {
job.addJar(new Path(jar.toURI()));
} catch (URISyntaxException e) {
throw new RuntimeException("URL is invalid. This should not happen.", e);
}
}
job.setClasspaths(classpaths);
return job;
}
示例2: getOptimizedPlan
import org.apache.flink.optimizer.plan.FlinkPlan; //导入依赖的package包/类
public static FlinkPlan getOptimizedPlan(Optimizer compiler, PackagedProgram prog, int parallelism)
throws CompilerException, ProgramInvocationException {
Thread.currentThread().setContextClassLoader(prog.getUserCodeClassLoader());
if (prog.isUsingProgramEntryPoint()) {
return getOptimizedPlan(compiler, prog.getPlanWithJars(), parallelism);
} else if (prog.isUsingInteractiveMode()) {
// temporary hack to support the optimizer plan preview
OptimizerPlanEnvironment env = new OptimizerPlanEnvironment(compiler);
if (parallelism > 0) {
env.setParallelism(parallelism);
}
return env.getOptimizedPlan(prog);
} else {
throw new RuntimeException("Couldn't determine program mode.");
}
}
示例3: runWithDFObj
import org.apache.flink.optimizer.plan.FlinkPlan; //导入依赖的package包/类
public JobSubmissionResult runWithDFObj(FlinkPlan compiledPlan,
List<URL> libraries, List<URL> classpaths, ClassLoader classLoader, SavepointRestoreSettings savepointSettings, DFJobPOPJ dfJobPOPJ)
throws ProgramInvocationException {
JobGraph job = getJobGraph(compiledPlan, libraries, classpaths, savepointSettings);
// Keep the jobID to DFPOPJ
dfJobPOPJ.setFlinkIDToJobConfig(job.getJobID().toString());
return submitJob(job, classLoader);
}
示例4: getJobGraphAndClassLoader
import org.apache.flink.optimizer.plan.FlinkPlan; //导入依赖的package包/类
protected Tuple2<JobGraph, ClassLoader> getJobGraphAndClassLoader(JarActionHandlerConfig config) throws Exception {
// generate the graph
JobGraph graph = null;
PackagedProgram program = new PackagedProgram(
new File(jarDir, config.getJarFile()),
config.getEntryClass(),
config.getProgramArgs());
ClassLoader classLoader = program.getUserCodeClassLoader();
Optimizer optimizer = new Optimizer(new DataStatistics(), new DefaultCostEstimator(), new Configuration());
FlinkPlan plan = ClusterClient.getOptimizedPlan(optimizer, program, config.getParallelism());
if (plan instanceof StreamingPlan) {
graph = ((StreamingPlan) plan).getJobGraph();
} else if (plan instanceof OptimizedPlan) {
graph = new JobGraphGenerator().compileJobGraph((OptimizedPlan) plan);
}
if (graph == null) {
throw new CompilerException("A valid job graph couldn't be generated for the jar.");
}
// Set the savepoint settings
graph.setSavepointRestoreSettings(config.getSavepointRestoreSettings());
for (URL jar : program.getAllLibraries()) {
try {
graph.addJar(new Path(jar.toURI()));
}
catch (URISyntaxException e) {
throw new ProgramInvocationException("Invalid jar path. Unexpected error. :(");
}
}
return Tuple2.of(graph, classLoader);
}
示例5: getOptimizedPlan
import org.apache.flink.optimizer.plan.FlinkPlan; //导入依赖的package包/类
public FlinkPlan getOptimizedPlan(PackagedProgram prog) throws ProgramInvocationException {
// temporarily write syserr and sysout to a byte array.
PrintStream originalOut = System.out;
PrintStream originalErr = System.err;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
System.setOut(new PrintStream(baos));
ByteArrayOutputStream baes = new ByteArrayOutputStream();
System.setErr(new PrintStream(baes));
setAsContext();
try {
prog.invokeInteractiveModeForExecution();
}
catch (ProgramInvocationException e) {
throw e;
}
catch (Throwable t) {
// the invocation gets aborted with the preview plan
if (optimizerPlan != null) {
return optimizerPlan;
} else {
throw new ProgramInvocationException("The program caused an error: ", t);
}
}
finally {
unsetAsContext();
System.setOut(originalOut);
System.setErr(originalErr);
}
String stdout = baos.toString();
String stderr = baes.toString();
throw new ProgramInvocationException(
"The program plan could not be fetched - the program aborted pre-maturely."
+ "\n\nSystem.err: " + (stdout.length() == 0 ? "(none)" : stdout)
+ "\n\nSystem.out: " + (stderr.length() == 0 ? "(none)" : stderr));
}
示例6: setDetachedPlan
import org.apache.flink.optimizer.plan.FlinkPlan; //导入依赖的package包/类
public void setDetachedPlan(FlinkPlan plan) {
if (detachedPlan == null) {
detachedPlan = plan;
} else {
throw new InvalidProgramException(DetachedJobExecutionResult.DETACHED_MESSAGE +
DetachedJobExecutionResult.EXECUTE_TWICE_MESSAGE);
}
}
示例7: run
import org.apache.flink.optimizer.plan.FlinkPlan; //导入依赖的package包/类
public JobSubmissionResult run(
FlinkPlan compiledPlan, List<URL> libraries, List<URL> classpaths, ClassLoader classLoader) throws ProgramInvocationException {
return run(compiledPlan, libraries, classpaths, classLoader, SavepointRestoreSettings.none());
}
示例8: setPlan
import org.apache.flink.optimizer.plan.FlinkPlan; //导入依赖的package包/类
public void setPlan(FlinkPlan plan){
this.optimizerPlan = plan;
}
示例9: info
import org.apache.flink.optimizer.plan.FlinkPlan; //导入依赖的package包/类
/**
* 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();
}
}