当前位置: 首页>>代码示例>>Java>>正文


Java JobGraph.setSavepointRestoreSettings方法代码示例

本文整理汇总了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;
}
 
开发者ID:datafibers-community,项目名称:df_data_service,代码行数:23,代码来源:DFCusterClient.java

示例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);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:26,代码来源:AbstractOperatorRestoreTestBase.java

示例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);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:36,代码来源:JarActionHandler.java

示例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());
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:13,代码来源:JobSubmitTest.java

示例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();
		}
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:62,代码来源:SavepointITCase.java


注:本文中的org.apache.flink.runtime.jobgraph.JobGraph.setSavepointRestoreSettings方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。