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


Java ExecutionConfig.setRestartStrategy方法代码示例

本文整理汇总了Java中org.apache.flink.api.common.ExecutionConfig.setRestartStrategy方法的典型用法代码示例。如果您正苦于以下问题:Java ExecutionConfig.setRestartStrategy方法的具体用法?Java ExecutionConfig.setRestartStrategy怎么用?Java ExecutionConfig.setRestartStrategy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.flink.api.common.ExecutionConfig的用法示例。


在下文中一共展示了ExecutionConfig.setRestartStrategy方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSimpleJob

import org.apache.flink.api.common.ExecutionConfig; //导入方法依赖的package包/类
private static JobGraph getSimpleJob() throws IOException {
	JobVertex task = new JobVertex("Test task");
	task.setParallelism(1);
	task.setMaxParallelism(1);
	task.setInvokableClass(NoOpInvokable.class);

	JobGraph jg = new JobGraph(new JobID(), "Test Job", task);
	jg.setAllowQueuedScheduling(true);
	jg.setScheduleMode(ScheduleMode.EAGER);

	ExecutionConfig executionConfig = new ExecutionConfig();
	executionConfig.setRestartStrategy(RestartStrategies.fixedDelayRestart(Integer.MAX_VALUE, 1000));
	jg.setExecutionConfig(executionConfig);

	return jg;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:17,代码来源:MiniClusterITCase.java

示例2: testFailExecutionGraphAfterCancel

import org.apache.flink.api.common.ExecutionConfig; //导入方法依赖的package包/类
/**
 * Tests that it is possible to fail a graph via a call to
 * {@link ExecutionGraph#failGlobal(Throwable)} after cancellation.
 */
@Test
public void testFailExecutionGraphAfterCancel() throws Exception {
	Instance instance = ExecutionGraphTestUtils.getInstance(
		new ActorTaskManagerGateway(
			new SimpleActorGateway(TestingUtils.directExecutionContext())),
		2);

	Scheduler scheduler = new Scheduler(TestingUtils.defaultExecutionContext());
	scheduler.newInstanceAvailable(instance);

	JobVertex vertex = newJobVertex("Test Vertex", 1, NoOpInvokable.class);

	ExecutionConfig executionConfig = new ExecutionConfig();
	executionConfig.setRestartStrategy(RestartStrategies.fixedDelayRestart(
		Integer.MAX_VALUE, Integer.MAX_VALUE));
	JobGraph jobGraph = new JobGraph("Test Job", vertex);
	jobGraph.setExecutionConfig(executionConfig);

	ExecutionGraph eg = newExecutionGraph(new InfiniteDelayRestartStrategy(), scheduler);

	eg.attachJobGraph(jobGraph.getVerticesSortedTopologicallyFromSources());

	assertEquals(JobStatus.CREATED, eg.getState());

	eg.scheduleForExecution();
	assertEquals(JobStatus.RUNNING, eg.getState());

	// Fail right after cancel (for example with concurrent slot release)
	eg.cancel();
	assertEquals(JobStatus.CANCELLING, eg.getState());

	eg.failGlobal(new Exception("Test Exception"));
	assertEquals(JobStatus.FAILING, eg.getState());

	Execution execution = eg.getAllExecutionVertices().iterator().next().getCurrentExecutionAttempt();

	execution.cancelingComplete();
	assertEquals(JobStatus.RESTARTING, eg.getState());
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:44,代码来源:ExecutionGraphRestartTest.java

示例3: testJobPersistencyWhenJobManagerShutdown

import org.apache.flink.api.common.ExecutionConfig; //导入方法依赖的package包/类
/**
 * Tests that the HA job is not cleaned up when the jobmanager is stopped.
 */
@Test
public void testJobPersistencyWhenJobManagerShutdown() throws Exception {
	Configuration config = ZooKeeperTestUtils.createZooKeeperHAConfig(
			ZooKeeper.getConnectString(), tempFolder.getRoot().getPath());

	// Configure the cluster
	config.setInteger(ConfigConstants.LOCAL_NUMBER_JOB_MANAGER, 1);
	config.setInteger(ConfigConstants.LOCAL_NUMBER_TASK_MANAGER, 1);

	TestingCluster flink = new TestingCluster(config, false, false);

	try {
		final Deadline deadline = TestTimeOut.fromNow();

		// Start the JobManager and TaskManager
		flink.start(true);

		JobGraph jobGraph = createBlockingJobGraph();

		// Set restart strategy to guard against shut down races.
		// If the TM fails before the JM, it might happen that the
		// Job is failed, leading to state removal.
		ExecutionConfig ec = new ExecutionConfig();
		ec.setRestartStrategy(RestartStrategies.fixedDelayRestart(Integer.MAX_VALUE, 100));
		jobGraph.setExecutionConfig(ec);

		ActorGateway jobManager = flink.getLeaderGateway(deadline.timeLeft());

		// Submit the job
		jobManager.tell(new SubmitJob(jobGraph, ListeningBehaviour.DETACHED));

		// Wait for the job to start
		JobManagerActorTestUtils.waitForJobStatus(jobGraph.getJobID(), JobStatus.RUNNING,
				jobManager, deadline.timeLeft());
	}
	finally {
		flink.stop();
	}

	// verify that the persisted job data has not been removed from ZooKeeper when the JM has
	// been shutdown
	verifyRecoveryState(config);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:47,代码来源:JobManagerHAJobGraphRecoveryITCase.java

示例4: testFailExecutionAfterCancel

import org.apache.flink.api.common.ExecutionConfig; //导入方法依赖的package包/类
/**
 * Tests that a graph is not restarted after cancellation via a call to
 * {@link ExecutionGraph#failGlobal(Throwable)}. This can happen when a slot is
 * released concurrently with cancellation.
 */
@Test
public void testFailExecutionAfterCancel() throws Exception {
	Instance instance = ExecutionGraphTestUtils.getInstance(
		new ActorTaskManagerGateway(
			new SimpleActorGateway(TestingUtils.directExecutionContext())),
		2);

	Scheduler scheduler = new Scheduler(TestingUtils.defaultExecutionContext());
	scheduler.newInstanceAvailable(instance);

	JobVertex vertex = newJobVertex("Test Vertex", 1, NoOpInvokable.class);

	ExecutionConfig executionConfig = new ExecutionConfig();
	executionConfig.setRestartStrategy(RestartStrategies.fixedDelayRestart(
		Integer.MAX_VALUE, Integer.MAX_VALUE));
	JobGraph jobGraph = new JobGraph("Test Job", vertex);
	jobGraph.setExecutionConfig(executionConfig);

	ExecutionGraph eg = newExecutionGraph(new InfiniteDelayRestartStrategy(), scheduler);

	eg.attachJobGraph(jobGraph.getVerticesSortedTopologicallyFromSources());

	assertEquals(JobStatus.CREATED, eg.getState());

	eg.scheduleForExecution();
	assertEquals(JobStatus.RUNNING, eg.getState());

	// Fail right after cancel (for example with concurrent slot release)
	eg.cancel();

	for (ExecutionVertex v : eg.getAllExecutionVertices()) {
		v.getCurrentExecutionAttempt().fail(new Exception("Test Exception"));
	}

	assertEquals(JobStatus.CANCELED, eg.getTerminationFuture().get());

	Execution execution = eg.getAllExecutionVertices().iterator().next().getCurrentExecutionAttempt();

	execution.cancelingComplete();
	assertEquals(JobStatus.CANCELED, eg.getState());
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:47,代码来源:ExecutionGraphRestartTest.java

示例5: setupExecutionGraph

import org.apache.flink.api.common.ExecutionConfig; //导入方法依赖的package包/类
@BeforeClass
public static void setupExecutionGraph() throws Exception {
	// -------------------------------------------------------------------------------------------------------------
	// Setup
	// -------------------------------------------------------------------------------------------------------------

	JobVertexID v1ID = new JobVertexID();
	JobVertexID v2ID = new JobVertexID();

	JobVertex v1 = new JobVertex("v1", v1ID);
	JobVertex v2 = new JobVertex("v2", v2ID);

	v1.setParallelism(1);
	v2.setParallelism(2);

	v1.setInvokableClass(AbstractInvokable.class);
	v2.setInvokableClass(AbstractInvokable.class);

	List<JobVertex> vertices = new ArrayList<>(Arrays.asList(v1, v2));

	ExecutionConfig config = new ExecutionConfig();

	config.setExecutionMode(ExecutionMode.BATCH_FORCED);
	config.setRestartStrategy(new RestartStrategies.NoRestartStrategyConfiguration());
	config.setParallelism(4);
	config.enableObjectReuse();
	config.setGlobalJobParameters(new TestJobParameters());

	runtimeGraph = new ExecutionGraph(
		TestingUtils.defaultExecutor(),
		TestingUtils.defaultExecutor(),
		new JobID(),
		"test job",
		new Configuration(),
		new SerializedValue<>(config),
		AkkaUtils.getDefaultTimeout(),
		new NoRestartStrategy(),
		mock(SlotProvider.class));

	runtimeGraph.attachJobGraph(vertices);

	List<ExecutionJobVertex> jobVertices = new ArrayList<>();
	jobVertices.add(runtimeGraph.getJobVertex(v1ID));
	jobVertices.add(runtimeGraph.getJobVertex(v2ID));
	
	CheckpointStatsTracker statsTracker = new CheckpointStatsTracker(
			0,
			jobVertices,
			mock(CheckpointCoordinatorConfiguration.class),
			new UnregisteredMetricsGroup());

	runtimeGraph.enableCheckpointing(
		100,
		100,
		100,
		1,
		CheckpointRetentionPolicy.NEVER_RETAIN_AFTER_TERMINATION,
		Collections.<ExecutionJobVertex>emptyList(),
		Collections.<ExecutionJobVertex>emptyList(),
		Collections.<ExecutionJobVertex>emptyList(),
		Collections.<MasterTriggerRestoreHook<?>>emptyList(),
		new StandaloneCheckpointIDCounter(),
		new StandaloneCompletedCheckpointStore(1),
		new MemoryStateBackend(),
		statsTracker);

	runtimeGraph.setJsonPlan("{}");

	runtimeGraph.getJobVertex(v2ID).getTaskVertices()[0].getCurrentExecutionAttempt().fail(new RuntimeException("This exception was thrown on purpose."));
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:71,代码来源:ArchivedExecutionGraphTest.java


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