本文整理汇总了Java中org.apache.flink.runtime.jobgraph.JobGraph.addJar方法的典型用法代码示例。如果您正苦于以下问题:Java JobGraph.addJar方法的具体用法?Java JobGraph.addJar怎么用?Java JobGraph.addJar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.flink.runtime.jobgraph.JobGraph
的用法示例。
在下文中一共展示了JobGraph.addJar方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getJobGraph
import org.apache.flink.runtime.jobgraph.JobGraph; //导入方法依赖的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: execute
import org.apache.flink.runtime.jobgraph.JobGraph; //导入方法依赖的package包/类
@Override
public JobExecutionResult execute(String jobName) throws Exception {
OptimizedPlan op = compileProgram(jobName);
JobGraphGenerator jgg = new JobGraphGenerator();
JobGraph jobGraph = jgg.compileJobGraph(op);
for (Path jarFile: jarFiles) {
jobGraph.addJar(jarFile);
}
jobGraph.setClasspaths(new ArrayList<>(classPaths));
this.lastJobExecutionResult = jobExecutor.executeJobBlocking(jobGraph);
return this.lastJobExecutionResult;
}
示例3: execute
import org.apache.flink.runtime.jobgraph.JobGraph; //导入方法依赖的package包/类
@Override
public JobExecutionResult execute(String jobName) throws Exception {
final StreamGraph streamGraph = getStreamGraph();
streamGraph.setJobName(jobName);
final JobGraph jobGraph = streamGraph.getJobGraph();
for (Path jarFile: jarFiles) {
jobGraph.addJar(jarFile);
}
jobGraph.setClasspaths(new ArrayList<>(classPaths));
return jobExecutor.executeJobBlocking(jobGraph);
}
示例4: getJobGraphAndClassLoader
import org.apache.flink.runtime.jobgraph.JobGraph; //导入方法依赖的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: testPerJobMode
import org.apache.flink.runtime.jobgraph.JobGraph; //导入方法依赖的package包/类
@Ignore("The cluster cannot be stopped yet.")
@Test
public void testPerJobMode() throws Exception {
Configuration configuration = new Configuration();
configuration.setString(AkkaOptions.ASK_TIMEOUT, "30 s");
final YarnClient yarnClient = YarnClient.createYarnClient();
try (final Flip6YarnClusterDescriptor flip6YarnClusterDescriptor = new Flip6YarnClusterDescriptor(
configuration,
System.getenv(ConfigConstants.ENV_FLINK_CONF_DIR),
yarnClient)) {
flip6YarnClusterDescriptor.setLocalJarPath(new Path(flinkUberjar.getAbsolutePath()));
flip6YarnClusterDescriptor.addShipFiles(Arrays.asList(flinkLibFolder.listFiles()));
final ClusterSpecification clusterSpecification = new ClusterSpecification.ClusterSpecificationBuilder()
.setMasterMemoryMB(768)
.setTaskManagerMemoryMB(1024)
.setSlotsPerTaskManager(1)
.setNumberTaskManagers(1)
.createClusterSpecification();
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setParallelism(2);
env.addSource(new InfiniteSource())
.shuffle()
.addSink(new DiscardingSink<Integer>());
final JobGraph jobGraph = env.getStreamGraph().getJobGraph();
File testingJar = YarnTestBase.findFile("..", new TestingYarnClusterDescriptor.TestJarFinder("flink-yarn-tests"));
jobGraph.addJar(new org.apache.flink.core.fs.Path(testingJar.toURI()));
ClusterClient<ApplicationId> clusterClient = flip6YarnClusterDescriptor.deployJobCluster(clusterSpecification, jobGraph);
clusterClient.shutdown();
}
}