org.apache.flink.runtime.executiongraph.restart.RestartStrategy Java Examples

The following examples show how to use org.apache.flink.runtime.executiongraph.restart.RestartStrategy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExecutionGraphTestUtils.java    From flink with Apache License 2.0 6 votes vote down vote up
public static ExecutionGraph createExecutionGraph(
		SlotProvider slotProvider,
		RestartStrategy restartStrategy,
		ScheduledExecutorService executor,
		Time timeout,
		JobVertex... vertices) throws Exception {

	checkNotNull(restartStrategy);
	checkNotNull(vertices);
	checkNotNull(timeout);

	return TestingExecutionGraphBuilder
		.newBuilder()
		.setJobGraph(new JobGraph(vertices))
		.setFutureExecutor(executor)
		.setIoExecutor(executor)
		.setSlotProvider(slotProvider)
		.setAllocationTimeout(timeout)
		.setRpcTimeout(timeout)
		.setRestartStrategy(restartStrategy)
		.build();
}
 
Example #2
Source File: ExecutionGraphRestartTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Test
public void testNoRestartOnSuppressException() throws Exception {
	try (SlotPool slotPool = createSlotPoolImpl()) {
		ExecutionGraph eg = TestingExecutionGraphBuilder.newBuilder()
			.setRestartStrategy(new FixedDelayRestartStrategy(Integer.MAX_VALUE, 0))
			.buildAndScheduleForExecution(slotPool);

		// Fail with unrecoverable Exception
		eg.getAllExecutionVertices().iterator().next().fail(
			new SuppressRestartsException(new Exception("Test Exception")));

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

		completeCanceling(eg);

		eg.waitUntilTerminal();
		assertEquals(JobStatus.FAILED, eg.getState());

		RestartStrategy restartStrategy = eg.getRestartStrategy();
		assertTrue(restartStrategy instanceof FixedDelayRestartStrategy);

		assertEquals(0, ((FixedDelayRestartStrategy) restartStrategy).getCurrentRestartAttempt());
	}

}
 
Example #3
Source File: ExecutionGraph.java    From flink with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
ExecutionGraph(
		JobInformation jobInformation,
		ScheduledExecutorService futureExecutor,
		Executor ioExecutor,
		Time timeout,
		RestartStrategy restartStrategy,
		FailoverStrategy.Factory failoverStrategy,
		SlotProvider slotProvider) throws IOException {
	this(
		jobInformation,
		futureExecutor,
		ioExecutor,
		timeout,
		restartStrategy,
		failoverStrategy,
		slotProvider,
		ExecutionGraph.class.getClassLoader(),
		VoidBlobWriter.getInstance(),
		timeout);
}
 
Example #4
Source File: ExecutionGraph.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * This constructor is for tests only, because it does not include class loading information.
 */
@VisibleForTesting
ExecutionGraph(
		JobInformation jobInformation,
		ScheduledExecutorService futureExecutor,
		Executor ioExecutor,
		Time timeout,
		RestartStrategy restartStrategy,
		SlotProvider slotProvider) throws IOException {
	this(
		jobInformation,
		futureExecutor,
		ioExecutor,
		timeout,
		restartStrategy,
		new RestartAllStrategy.Factory(),
		slotProvider);
}
 
Example #5
Source File: ExecutionGraphRestartTest.java    From flink with Apache License 2.0 6 votes vote down vote up
private static ExecutionGraph createSimpleExecutionGraph(
	final RestartStrategy restartStrategy,
	final FailoverStrategy.Factory failoverStrategyFactory,
	final SlotProvider slotProvider,
	final JobGraph jobGraph) throws IOException, JobException {

	final ExecutionGraph executionGraph = new ExecutionGraph(
		new JobInformation(
			TEST_JOB_ID,
			"Test job",
			new SerializedValue<>(new ExecutionConfig()),
			new Configuration(),
			Collections.emptyList(),
			Collections.emptyList()),
		TestingUtils.defaultExecutor(),
		TestingUtils.defaultExecutor(),
		AkkaUtils.getDefaultTimeout(),
		restartStrategy,
		failoverStrategyFactory,
		slotProvider);

	executionGraph.start(mainThreadExecutor);
	executionGraph.attachJobGraph(jobGraph.getVerticesSortedTopologicallyFromSources());

	return executionGraph;
}
 
Example #6
Source File: FailoverRegionTest.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that a new failure comes while the failover region is in CANCELLING.
 * @throws Exception if fail to create the single region execution graph.
 */
@Test
public void testFailWhileCancelling() throws Exception {
	RestartStrategy restartStrategy = new InfiniteDelayRestartStrategy();
	ExecutionGraph eg = createSingleRegionExecutionGraph(restartStrategy);
	RestartPipelinedRegionStrategy strategy = (RestartPipelinedRegionStrategy)eg.getFailoverStrategy();

	Iterator<ExecutionVertex> iter = eg.getAllExecutionVertices().iterator();
	ExecutionVertex ev1 = iter.next();
	ev1.getCurrentExecutionAttempt().switchToRunning();
	assertEquals(JobStatus.RUNNING, strategy.getFailoverRegion(ev1).getState());

	ev1.getCurrentExecutionAttempt().fail(new Exception("new fail"));
	assertEquals(JobStatus.CANCELLING, strategy.getFailoverRegion(ev1).getState());

	ExecutionVertex ev2 = iter.next();
	ev2.getCurrentExecutionAttempt().fail(new Exception("new fail"));
	assertEquals(JobStatus.RUNNING, eg.getState());
	assertEquals(JobStatus.CANCELLING, strategy.getFailoverRegion(ev1).getState());
}
 
Example #7
Source File: ExecutionGraphTestUtils.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Creates an execution graph containing the given vertices and the given restart strategy.
 */
public static ExecutionGraph createSimpleTestGraph(
		JobID jid,
		TaskManagerGateway taskManagerGateway,
		RestartStrategy restartStrategy,
		JobVertex... vertices) throws Exception {

	int numSlotsNeeded = 0;
	for (JobVertex vertex : vertices) {
		numSlotsNeeded += vertex.getParallelism();
	}

	SlotProvider slotProvider = new SimpleSlotProvider(jid, numSlotsNeeded, taskManagerGateway);

	return createSimpleTestGraph(jid, slotProvider, restartStrategy, vertices);
}
 
Example #8
Source File: FailoverRegionTest.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that a new failure comes while the failover region is restarting.
 * @throws Exception if fail to create the single region execution graph.
 */
@Test
public void testFailWhileRestarting() throws Exception {
	RestartStrategy restartStrategy = new InfiniteDelayRestartStrategy();
	ExecutionGraph eg = createSingleRegionExecutionGraph(restartStrategy);
	RestartPipelinedRegionStrategy strategy = (RestartPipelinedRegionStrategy)eg.getFailoverStrategy();

	Iterator<ExecutionVertex> iter = eg.getAllExecutionVertices().iterator();
	ExecutionVertex ev1 = iter.next();
	assertEquals(JobStatus.RUNNING, strategy.getFailoverRegion(ev1).getState());

	ev1.getCurrentExecutionAttempt().fail(new Exception("new fail"));
	assertEquals(JobStatus.CANCELLING, strategy.getFailoverRegion(ev1).getState());

	for (ExecutionVertex evs : eg.getAllExecutionVertices()) {
		evs.getCurrentExecutionAttempt().completeCancelling();
	}
	assertEquals(JobStatus.RUNNING, strategy.getFailoverRegion(ev1).getState());

	ev1.getCurrentExecutionAttempt().fail(new Exception("new fail"));
	assertEquals(JobStatus.CANCELLING, strategy.getFailoverRegion(ev1).getState());
}
 
Example #9
Source File: AdaptedRestartPipelinedRegionStrategyNGFailoverTest.java    From flink with Apache License 2.0 6 votes vote down vote up
private ExecutionGraph createExecutionGraph(
		final JobGraph jobGraph,
		final RestartStrategy restartStrategy) throws Exception {

	final PartitionTracker partitionTracker = new PartitionTrackerImpl(
		jobGraph.getJobID(),
		NettyShuffleMaster.INSTANCE,
		ignored -> Optional.empty());

	final ExecutionGraph eg = new ExecutionGraphTestUtils.TestingExecutionGraphBuilder(jobGraph)
		.setRestartStrategy(restartStrategy)
		.setFailoverStrategyFactory(TestAdaptedRestartPipelinedRegionStrategyNG::new)
		.setPartitionTracker(partitionTracker)
		.build();

	eg.start(componentMainThreadExecutor);
	eg.scheduleForExecution();
	manualMainThreadExecutor.triggerAll();

	return eg;
}
 
Example #10
Source File: FailoverRegionTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that a new failure comes while the failover region is restarting
 * @throws Exception
 */
@Test
public void testFailWhileRestarting() throws Exception {
	RestartStrategy restartStrategy = new InfiniteDelayRestartStrategy();
	ExecutionGraph eg = createSingleRegionExecutionGraph(restartStrategy);
	RestartPipelinedRegionStrategy strategy = (RestartPipelinedRegionStrategy)eg.getFailoverStrategy();

	Iterator<ExecutionVertex> iter = eg.getAllExecutionVertices().iterator();
	ExecutionVertex ev1 = iter.next();
	assertEquals(JobStatus.RUNNING, strategy.getFailoverRegion(ev1).getState());

	ev1.getCurrentExecutionAttempt().fail(new Exception("new fail"));
	assertEquals(JobStatus.CANCELLING, strategy.getFailoverRegion(ev1).getState());

	for (ExecutionVertex evs : eg.getAllExecutionVertices()) {
		evs.getCurrentExecutionAttempt().completeCancelling();
	}
	assertEquals(JobStatus.RUNNING, strategy.getFailoverRegion(ev1).getState());

	ev1.getCurrentExecutionAttempt().fail(new Exception("new fail"));
	assertEquals(JobStatus.CANCELLING, strategy.getFailoverRegion(ev1).getState());
}
 
Example #11
Source File: FailoverRegionTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that a new failure comes while the failover region is in CANCELLING
 * @throws Exception
 */
@Test
public void testFailWhileCancelling() throws Exception {
	RestartStrategy restartStrategy = new InfiniteDelayRestartStrategy();
	ExecutionGraph eg = createSingleRegionExecutionGraph(restartStrategy);
	RestartPipelinedRegionStrategy strategy = (RestartPipelinedRegionStrategy)eg.getFailoverStrategy();

	Iterator<ExecutionVertex> iter = eg.getAllExecutionVertices().iterator();
	ExecutionVertex ev1 = iter.next();
	ev1.getCurrentExecutionAttempt().switchToRunning();
	assertEquals(JobStatus.RUNNING, strategy.getFailoverRegion(ev1).getState());

	ev1.getCurrentExecutionAttempt().fail(new Exception("new fail"));
	assertEquals(JobStatus.CANCELLING, strategy.getFailoverRegion(ev1).getState());

	ExecutionVertex ev2 = iter.next();
	ev2.getCurrentExecutionAttempt().fail(new Exception("new fail"));
	assertEquals(JobStatus.RUNNING, eg.getState());
	assertEquals(JobStatus.CANCELLING, strategy.getFailoverRegion(ev1).getState());
}
 
Example #12
Source File: FailoverRegionTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Tests that a job only has one failover region and can recover from task failure successfully
 * @throws Exception
 */
@Test
public void testSingleRegionFailover() throws Exception {
	RestartStrategy restartStrategy = new InfiniteDelayRestartStrategy(10);
	ExecutionGraph eg = createSingleRegionExecutionGraph(restartStrategy);
	RestartPipelinedRegionStrategy strategy = (RestartPipelinedRegionStrategy)eg.getFailoverStrategy();

	ExecutionVertex ev = eg.getAllExecutionVertices().iterator().next();

	assertEquals(JobStatus.RUNNING, strategy.getFailoverRegion(ev).getState());

	ev.getCurrentExecutionAttempt().fail(new Exception("Test Exception"));
	assertEquals(JobStatus.CANCELLING, strategy.getFailoverRegion(ev).getState());

	for (ExecutionVertex evs : eg.getAllExecutionVertices()) {
		evs.getCurrentExecutionAttempt().completeCancelling();
	}
	assertEquals(JobStatus.RUNNING, strategy.getFailoverRegion(ev).getState());
}
 
Example #13
Source File: ExecutionGraphRestartTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private static ExecutionGraph newExecutionGraph(RestartStrategy restartStrategy, SlotProvider slotProvider) throws IOException {
	final ExecutionGraph executionGraph = new ExecutionGraph(
		TestingUtils.defaultExecutor(),
		TestingUtils.defaultExecutor(),
		new JobID(),
		"Test job",
		new Configuration(),
		new SerializedValue<>(new ExecutionConfig()),
		AkkaUtils.getDefaultTimeout(),
		restartStrategy,
		slotProvider);

	executionGraph.start(TestingComponentMainThreadExecutorServiceAdapter.forMainThread());

	return executionGraph;
}
 
Example #14
Source File: ExecutionGraphTestUtils.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Creates an execution graph containing the given vertices and the given restart strategy.
 */
public static ExecutionGraph createSimpleTestGraph(
		JobID jid,
		TaskManagerGateway taskManagerGateway,
		RestartStrategy restartStrategy,
		JobVertex... vertices) throws Exception {

	int numSlotsNeeded = 0;
	for (JobVertex vertex : vertices) {
		numSlotsNeeded += vertex.getParallelism();
	}

	SlotProvider slotProvider = new SimpleSlotProvider(jid, numSlotsNeeded, taskManagerGateway);

	return createSimpleTestGraph(jid, slotProvider, restartStrategy, vertices);
}
 
Example #15
Source File: ExecutionGraphRestartTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testNoRestartOnSuppressException() throws Exception {
	final ExecutionGraph eg = createExecutionGraph(new FixedDelayRestartStrategy(Integer.MAX_VALUE, 0)).f0;

	// Fail with unrecoverable Exception
	eg.getAllExecutionVertices().iterator().next().fail(
		new SuppressRestartsException(new Exception("Test Exception")));

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

	completeCanceling(eg);

	eg.waitUntilTerminal();
	assertEquals(JobStatus.FAILED, eg.getState());

	RestartStrategy restartStrategy = eg.getRestartStrategy();
	assertTrue(restartStrategy instanceof FixedDelayRestartStrategy);

	assertEquals(0, ((FixedDelayRestartStrategy) restartStrategy).getCurrentRestartAttempt());
}
 
Example #16
Source File: ExecutionGraphRestartTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private Tuple2<ExecutionGraph, Instance> createExecutionGraph(RestartStrategy restartStrategy) throws Exception {
	Instance instance = ExecutionGraphTestUtils.getInstance(
		new ActorTaskManagerGateway(
			new SimpleActorGateway(TestingUtils.directExecutionContext())),
		NUM_TASKS);

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

	ExecutionGraph eg = createSimpleExecutionGraph(restartStrategy, scheduler);

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

	eg.scheduleForExecution();
	assertEquals(JobStatus.RUNNING, eg.getState());
	return new Tuple2<>(eg, instance);
}
 
Example #17
Source File: ExecutionGraphRestartTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testCancelWhileRestarting() throws Exception {
	// We want to manually control the restart and delay
	RestartStrategy restartStrategy = new InfiniteDelayRestartStrategy();
	Tuple2<ExecutionGraph, Instance> executionGraphInstanceTuple = createExecutionGraph(restartStrategy);
	ExecutionGraph executionGraph = executionGraphInstanceTuple.f0;
	Instance instance = executionGraphInstanceTuple.f1;

	// Kill the instance and wait for the job to restart
	instance.markDead();
	Assert.assertEquals(JobStatus.RESTARTING, executionGraph.getState());

	assertEquals(JobStatus.RESTARTING, executionGraph.getState());

	// Canceling needs to abort the restart
	executionGraph.cancel();

	assertEquals(JobStatus.CANCELED, executionGraph.getState());

	// The restart has been aborted
	executionGraph.restart(executionGraph.getGlobalModVersion());

	assertEquals(JobStatus.CANCELED, executionGraph.getState());
}
 
Example #18
Source File: ExecutionGraphTestUtils.java    From flink with Apache License 2.0 6 votes vote down vote up
public static ExecutionGraph createExecutionGraph(
		JobID jid,
		SlotProvider slotProvider,
		RestartStrategy restartStrategy,
		ScheduledExecutorService executor,
		Time timeout,
		JobVertex... vertices) throws Exception {

	checkNotNull(jid);
	checkNotNull(restartStrategy);
	checkNotNull(vertices);
	checkNotNull(timeout);

	return new TestingExecutionGraphBuilder(vertices)
		.setFutureExecutor(executor)
		.setIoExecutor(executor)
		.setSlotProvider(slotProvider)
		.setAllocationTimeout(timeout)
		.setRpcTimeout(timeout)
		.setRestartStrategy(restartStrategy)
		.build();
}
 
Example #19
Source File: ExecutionGraph.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * This constructor is for tests only, because it does not include class loading information.
 */
@VisibleForTesting
ExecutionGraph(
		JobInformation jobInformation,
		ScheduledExecutorService futureExecutor,
		Executor ioExecutor,
		Time timeout,
		RestartStrategy restartStrategy,
		SlotProvider slotProvider) throws IOException {
	this(
		jobInformation,
		futureExecutor,
		ioExecutor,
		timeout,
		restartStrategy,
		new RestartAllStrategy.Factory(),
		slotProvider);
}
 
Example #20
Source File: ExecutionGraph.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
ExecutionGraph(
		JobInformation jobInformation,
		ScheduledExecutorService futureExecutor,
		Executor ioExecutor,
		Time timeout,
		RestartStrategy restartStrategy,
		FailoverStrategy.Factory failoverStrategy,
		SlotProvider slotProvider) throws IOException {
	this(
		jobInformation,
		futureExecutor,
		ioExecutor,
		timeout,
		restartStrategy,
		failoverStrategy,
		slotProvider,
		ExecutionGraph.class.getClassLoader(),
		VoidBlobWriter.getInstance(),
		timeout);
}
 
Example #21
Source File: AdaptedRestartPipelinedRegionStrategyNG.java    From flink with Apache License 2.0 5 votes vote down vote up
private Function<Object, CompletableFuture<Void>> resetAndRescheduleTasks(final long globalModVersion, final Set<ExecutionVertexVersion> vertexVersions) {
	return (ignored) -> {
		final RestartStrategy restartStrategy = executionGraph.getRestartStrategy();
		return restartStrategy.restart(
			createResetAndRescheduleTasksCallback(globalModVersion, vertexVersions),
			executionGraph.getJobMasterMainThreadExecutor()
		);
	};
}
 
Example #22
Source File: ConcurrentFailoverStrategyExecutionGraphTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private ExecutionGraph createSampleGraph(
	JobID jid,
	Factory failoverStrategy,
	RestartStrategy restartStrategy,
	SlotProvider slotProvider,
	int parallelism) throws Exception {

	final JobInformation jobInformation = new DummyJobInformation(
		jid,
		"test job");

	// build a simple execution graph with on job vertex, parallelism 2
	final Time timeout = Time.seconds(10L);
	final ExecutionGraph graph = new ExecutionGraph(
		jobInformation,
		TestingUtils.defaultExecutor(),
		TestingUtils.defaultExecutor(),
		timeout,
		restartStrategy,
		failoverStrategy,
		slotProvider,
		getClass().getClassLoader(),
		VoidBlobWriter.getInstance(),
		timeout);

	JobVertex jv = new JobVertex("test vertex");
	jv.setInvokableClass(NoOpInvokable.class);
	jv.setParallelism(parallelism);

	JobGraph jg = new JobGraph(jid, "testjob", jv);
	graph.attachJobGraph(jg.getVerticesSortedTopologicallyFromSources());

	return graph;
}
 
Example #23
Source File: ExecutionGraph.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
/**
 * This constructor is for tests only, because it sets default values for many fields.
 */
@VisibleForTesting
ExecutionGraph(
		ScheduledExecutorService futureExecutor,
		Executor ioExecutor,
		JobID jobId,
		String jobName,
		Configuration jobConfig,
		SerializedValue<ExecutionConfig> serializedConfig,
		Time timeout,
		RestartStrategy restartStrategy,
		SlotProvider slotProvider) throws IOException {

	this(
		new JobInformation(
			jobId,
			jobName,
			serializedConfig,
			jobConfig,
			Collections.emptyList(),
			Collections.emptyList()),
		futureExecutor,
		ioExecutor,
		timeout,
		restartStrategy,
		slotProvider);
}
 
Example #24
Source File: ExecutionGraphRestartTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private static ExecutionGraph createSimpleExecutionGraph(
	final RestartStrategy restartStrategy,
	final SlotProvider slotProvider,
	final JobGraph jobGraph) throws IOException, JobException {

	return createSimpleExecutionGraph(restartStrategy, new RestartAllStrategy.Factory(), slotProvider, jobGraph);
}
 
Example #25
Source File: ExecutionGraphTestUtils.java    From flink with Apache License 2.0 5 votes vote down vote up
public static ExecutionGraph createExecutionGraph(
		SlotProvider slotProvider,
		RestartStrategy restartStrategy,
		ScheduledExecutorService executor,
		JobVertex... vertices) throws Exception {

		return createExecutionGraph(slotProvider, restartStrategy, executor, Time.seconds(10L), vertices);
}
 
Example #26
Source File: FailoverRegionTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Tests that a job only has one failover region and can recover from task failure successfully with state.
 * @throws Exception if fail to create the single region execution graph or fail to acknowledge all checkpoints.
 */
@Test
public void testSingleRegionFailover() throws Exception {
	RestartStrategy restartStrategy = new InfiniteDelayRestartStrategy(10);
	ExecutionGraph eg = createSingleRegionExecutionGraph(restartStrategy);
	RestartPipelinedRegionStrategy strategy = (RestartPipelinedRegionStrategy) eg.getFailoverStrategy();

	ExecutionVertex ev = eg.getAllExecutionVertices().iterator().next();

	assertNotNull(eg.getCheckpointCoordinator());
	assertFalse(eg.getCheckpointCoordinator().getPendingCheckpoints().isEmpty());

	assertEquals(JobStatus.RUNNING, strategy.getFailoverRegion(ev).getState());

	acknowledgeAllCheckpoints(eg.getCheckpointCoordinator(), eg.getAllExecutionVertices().iterator());

	// verify checkpoint has been completed successfully.
	assertEquals(1, eg.getCheckpointCoordinator().getCheckpointStore().getNumberOfRetainedCheckpoints());
	assertEquals(checkpointId, eg.getCheckpointCoordinator().getCheckpointStore().getLatestCheckpoint(false).getCheckpointID());

	ev.getCurrentExecutionAttempt().fail(new Exception("Test Exception"));
	assertEquals(JobStatus.CANCELLING, strategy.getFailoverRegion(ev).getState());

	for (ExecutionVertex evs : eg.getAllExecutionVertices()) {
		evs.getCurrentExecutionAttempt().completeCancelling();
	}

	verifyCheckpointRestoredAsExpected(eg);

	assertEquals(JobStatus.RUNNING, strategy.getFailoverRegion(ev).getState());
}
 
Example #27
Source File: ExecutionGraphTestUtils.java    From flink with Apache License 2.0 5 votes vote down vote up
public static ExecutionGraph createSimpleTestGraph(
		SlotProvider slotProvider,
		RestartStrategy restartStrategy,
		JobVertex... vertices) throws Exception {

	return createExecutionGraph(slotProvider, restartStrategy, TestingUtils.defaultExecutor(), vertices);
}
 
Example #28
Source File: ExecutionGraphTestUtils.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an execution graph containing the given vertices and the given restart strategy.
 */
public static ExecutionGraph createSimpleTestGraph(
		TaskManagerGateway taskManagerGateway,
		RestartStrategy restartStrategy,
		JobVertex... vertices) throws Exception {

	int numSlotsNeeded = 0;
	for (JobVertex vertex : vertices) {
		numSlotsNeeded += vertex.getParallelism();
	}

	SlotProvider slotProvider = new SimpleSlotProvider(numSlotsNeeded, taskManagerGateway);

	return createSimpleTestGraph(slotProvider, restartStrategy, vertices);
}
 
Example #29
Source File: ExecutionGraphRestartTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testNoRestartOnSuppressException() throws Exception {
	try (SlotPool slotPool = createSlotPoolImpl()) {
		ExecutionGraph eg = TestingExecutionGraphBuilder
			.newBuilder()
			.setJobGraph(createJobGraph())
			.setRestartStrategy(new FixedDelayRestartStrategy(Integer.MAX_VALUE, 0))
			.setSlotProvider(createSchedulerWithSlots(slotPool))
			.build();

		startAndScheduleExecutionGraph(eg);

		// Fail with unrecoverable Exception
		eg.getAllExecutionVertices().iterator().next().fail(
			new SuppressRestartsException(new Exception("Test Exception")));

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

		completeCanceling(eg);

		eg.waitUntilTerminal();
		assertEquals(JobStatus.FAILED, eg.getState());

		RestartStrategy restartStrategy = eg.getRestartStrategy();
		assertTrue(restartStrategy instanceof FixedDelayRestartStrategy);

		assertEquals(0, ((FixedDelayRestartStrategy) restartStrategy).getCurrentRestartAttempt());
	}

}
 
Example #30
Source File: LegacyJobVertexIdTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testIntroduceLegacyJobVertexIds() throws Exception {
	JobVertexID defaultId = new JobVertexID();
	JobVertexID legacyId1 = new JobVertexID();
	JobVertexID legacyId2 = new JobVertexID();

	JobVertex jobVertex = new JobVertex("test", defaultId, Arrays.asList(legacyId1, legacyId2), new ArrayList<OperatorID>(), new ArrayList<OperatorID>());
	jobVertex.setInvokableClass(AbstractInvokable.class);

	ExecutionGraph executionGraph = new ExecutionGraph(
		mock(ScheduledExecutorService.class),
		mock(Executor.class),
		new JobID(),
		"test",
		mock(Configuration.class),
		mock(SerializedValue.class),
		Time.seconds(1),
		mock(RestartStrategy.class),
		mock(SlotProvider.class));

	ExecutionJobVertex executionJobVertex =
			new ExecutionJobVertex(executionGraph, jobVertex, 1, Time.seconds(1));

	Map<JobVertexID, ExecutionJobVertex> idToVertex = new HashMap<>();
	idToVertex.put(executionJobVertex.getJobVertexId(), executionJobVertex);

	Assert.assertEquals(executionJobVertex, idToVertex.get(defaultId));
	Assert.assertNull(idToVertex.get(legacyId1));
	Assert.assertNull(idToVertex.get(legacyId2));

	idToVertex = ExecutionJobVertex.includeLegacyJobVertexIDs(idToVertex);

	Assert.assertEquals(3, idToVertex.size());
	Assert.assertEquals(executionJobVertex, idToVertex.get(defaultId));
	Assert.assertEquals(executionJobVertex, idToVertex.get(legacyId1));
	Assert.assertEquals(executionJobVertex, idToVertex.get(legacyId2));
}