本文整理汇总了Java中org.apache.flink.runtime.jobgraph.JobGraph.setSavepointRestoreSettings方法的典型用法代码示例。如果您正苦于以下问题:Java JobGraph.setSavepointRestoreSettings方法的具体用法?Java JobGraph.setSavepointRestoreSettings怎么用?Java JobGraph.setSavepointRestoreSettings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.flink.runtime.jobgraph.JobGraph
的用法示例。
在下文中一共展示了JobGraph.setSavepointRestoreSettings方法的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: restoreJob
import org.apache.flink.runtime.jobgraph.JobGraph; //导入方法依赖的package包/类
private void restoreJob(String savepointPath) throws Exception {
JobGraph jobToRestore = createJobGraph(ExecutionMode.RESTORE);
jobToRestore.setSavepointRestoreSettings(SavepointRestoreSettings.forPath(savepointPath, allowNonRestoredState));
Object msg;
Object result;
// Submit job graph
msg = new JobManagerMessages.SubmitJob(jobToRestore, ListeningBehaviour.DETACHED);
result = Await.result(jobManager.ask(msg, timeout), timeout);
if (result instanceof JobManagerMessages.JobResultFailure) {
JobManagerMessages.JobResultFailure failure = (JobManagerMessages.JobResultFailure) result;
throw new Exception(failure.cause());
}
Assert.assertSame(JobManagerMessages.JobSubmitSuccess.class, result.getClass());
msg = new JobManagerMessages.RequestJobStatus(jobToRestore.getJobID());
JobStatus status = ((JobManagerMessages.CurrentJobStatus) Await.result(jobManager.ask(msg, timeout), timeout)).status();
while (!status.isTerminalState()) {
status = ((JobManagerMessages.CurrentJobStatus) Await.result(jobManager.ask(msg, timeout), timeout)).status();
}
Assert.assertEquals(JobStatus.FINISHED, status);
}
示例3: 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);
}
示例4: testAnswerFailureWhenSavepointReadFails
import org.apache.flink.runtime.jobgraph.JobGraph; //导入方法依赖的package包/类
@Test
public void testAnswerFailureWhenSavepointReadFails() throws Exception {
// create a simple job graph
JobGraph jg = createSimpleJobGraph();
jg.setSavepointRestoreSettings(SavepointRestoreSettings.forPath("pathThatReallyDoesNotExist..."));
// submit the job
Future<Object> submitFuture = jmGateway.ask(
new JobManagerMessages.SubmitJob(jg, ListeningBehaviour.DETACHED), timeout);
Object result = Await.result(submitFuture, timeout);
assertEquals(JobManagerMessages.JobResultFailure.class, result.getClass());
}
示例5: testSubmitWithUnknownSavepointPath
import org.apache.flink.runtime.jobgraph.JobGraph; //导入方法依赖的package包/类
@Test
public void testSubmitWithUnknownSavepointPath() throws Exception {
// Config
int numTaskManagers = 1;
int numSlotsPerTaskManager = 1;
int parallelism = numTaskManagers * numSlotsPerTaskManager;
// Test deadline
final Deadline deadline = new FiniteDuration(5, TimeUnit.MINUTES).fromNow();
final File tmpDir = folder.getRoot();
final File savepointDir = new File(tmpDir, "savepoints");
TestingCluster flink = null;
try {
// Flink configuration
final Configuration config = new Configuration();
config.setInteger(ConfigConstants.LOCAL_NUMBER_TASK_MANAGER, numTaskManagers);
config.setInteger(ConfigConstants.TASK_MANAGER_NUM_TASK_SLOTS, numSlotsPerTaskManager);
config.setString(CheckpointingOptions.SAVEPOINT_DIRECTORY, savepointDir.toURI().toString());
LOG.info("Flink configuration: " + config + ".");
// Start Flink
flink = new TestingCluster(config);
LOG.info("Starting Flink cluster.");
flink.start();
// Retrieve the job manager
LOG.info("Retrieving JobManager.");
ActorGateway jobManager = Await.result(
flink.leaderGateway().future(),
deadline.timeLeft());
LOG.info("JobManager: " + jobManager + ".");
// High value to ensure timeouts if restarted.
int numberOfRetries = 1000;
// Submit the job
// Long delay to ensure that the test times out if the job
// manager tries to restart the job.
final JobGraph jobGraph = createJobGraph(parallelism, numberOfRetries, 3600000);
// Set non-existing savepoint path
jobGraph.setSavepointRestoreSettings(SavepointRestoreSettings.forPath("unknown path"));
assertEquals("unknown path", jobGraph.getSavepointRestoreSettings().getRestorePath());
LOG.info("Submitting job " + jobGraph.getJobID() + " in detached mode.");
try {
flink.submitJobAndWait(jobGraph, false);
} catch (Exception e) {
assertEquals(JobExecutionException.class, e.getClass());
assertEquals(FileNotFoundException.class, e.getCause().getClass());
}
} finally {
if (flink != null) {
flink.stop();
}
}
}