org.apache.flink.runtime.checkpoint.CheckpointMetaData Java Examples

The following examples show how to use org.apache.flink.runtime.checkpoint.CheckpointMetaData. 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: JobMasterStopWithSavepointIT.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public boolean triggerCheckpoint(CheckpointMetaData checkpointMetaData, CheckpointOptions checkpointOptions, boolean advanceToEndOfEventTime) throws Exception {
	final long checkpointId = checkpointMetaData.getCheckpointId();
	final CheckpointType checkpointType = checkpointOptions.getCheckpointType();

	if (checkpointType == CheckpointType.SYNC_SAVEPOINT) {
		synchronousSavepointId = checkpointId;
		syncSavepointId.compareAndSet(-1, synchronousSavepointId);
	}

	final long taskIndex = getEnvironment().getTaskInfo().getIndexOfThisSubtask();
	if (taskIndex == 0) {
		checkpointsToWaitFor.countDown();
	}
	return super.triggerCheckpoint(checkpointMetaData, checkpointOptions, advanceToEndOfEventTime);
}
 
Example #2
Source File: TaskStateManagerImpl.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void reportTaskStateSnapshots(
	@Nonnull CheckpointMetaData checkpointMetaData,
	@Nonnull CheckpointMetrics checkpointMetrics,
	@Nullable TaskStateSnapshot acknowledgedState,
	@Nullable TaskStateSnapshot localState) {

	long checkpointId = checkpointMetaData.getCheckpointId();

	localStateStore.storeLocalState(checkpointId, localState);

	checkpointResponder.acknowledgeCheckpoint(
		jobId,
		executionAttemptID,
		checkpointId,
		checkpointMetrics,
		acknowledgedState);
}
 
Example #3
Source File: TaskAsyncCallTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public Future<Boolean> triggerCheckpointAsync(CheckpointMetaData checkpointMetaData, CheckpointOptions checkpointOptions, boolean advanceToEndOfEventTime) {
	lastCheckpointId++;
	if (checkpointMetaData.getCheckpointId() == lastCheckpointId) {
		if (lastCheckpointId == numCalls) {
			triggerLatch.trigger();
		}
	}
	else if (this.error == null) {
		this.error = new Exception("calls out of order");
		synchronized (this) {
			notifyAll();
		}
	}
	return CompletableFuture.completedFuture(true);
}
 
Example #4
Source File: CheckpointBarrierUnalignerTest.java    From flink with Apache License 2.0 6 votes vote down vote up
public void triggerCheckpointOnBarrier(
		CheckpointMetaData checkpointMetaData,
		CheckpointOptions checkpointOptions,
		CheckpointMetrics checkpointMetrics) throws IOException {
	if (nextExpectedCheckpointId != -1L) {
		assertEquals("wrong checkpoint id", nextExpectedCheckpointId, checkpointMetaData.getCheckpointId());
	}

	assertTrue(checkpointMetaData.getTimestamp() > 0);
	assertTrue(checkpointMetrics.getAlignmentDurationNanos() >= 0);

	nextExpectedCheckpointId = checkpointMetaData.getCheckpointId() + 1;

	for (int index = 0; index < inputGate.getNumberOfInputChannels(); index++) {
		inputGate.getChannel(index).spillInflightBuffers(checkpointMetaData.getCheckpointId(), NO_OP);
	}
}
 
Example #5
Source File: StreamTask.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public Future<Boolean> triggerCheckpointAsync(
		CheckpointMetaData checkpointMetaData,
		CheckpointOptions checkpointOptions,
		boolean advanceToEndOfEventTime) {

	CompletableFuture<Boolean> result = new CompletableFuture<>();
	mainMailboxExecutor.execute(
			() -> {
				try {
					result.complete(triggerCheckpoint(checkpointMetaData, checkpointOptions, advanceToEndOfEventTime));
				}
				catch (Exception ex) {
					// Report the failure both via the Future result but also to the mailbox
					result.completeExceptionally(ex);
					throw ex;
				}
			},
			"checkpoint %s with %s",
		checkpointMetaData,
		checkpointOptions);
	return result;
}
 
Example #6
Source File: CheckpointExceptionHandlerTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testDecliningHandler() {
	DeclineDummyEnvironment environment = new DeclineDummyEnvironment();
	CheckpointExceptionHandlerFactory checkpointExceptionHandlerFactory = new CheckpointExceptionHandlerFactory();
	CheckpointExceptionHandler exceptionHandler =
		checkpointExceptionHandlerFactory.createCheckpointExceptionHandler(false, environment);

	CheckpointMetaData failedCheckpointMetaData = new CheckpointMetaData(42L, 4711L);
	Exception testException = new Exception("test");
	try {
		exceptionHandler.tryHandleCheckpointException(failedCheckpointMetaData, testException);
	} catch (Exception e) {
		Assert.fail("Exception not handled, but rethrown.");
	}

	Assert.assertEquals(failedCheckpointMetaData.getCheckpointId(), environment.getLastDeclinedCheckpointId());
	Assert.assertEquals(testException, environment.getLastDeclinedCheckpointCause());
}
 
Example #7
Source File: AbstractUdfStreamOperatorLifecycleTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public void setup(StreamTask<?, ?> containingTask, StreamConfig config, Output<StreamRecord<OUT>> output) {
	ACTUAL_ORDER_TRACKING.add("OPERATOR::setup");
	super.setup(containingTask, config, output);
	if (simulateCheckpointing) {
		testCheckpointer = new Thread() {
			@Override
			public void run() {
				try {
					runStarted.await();
					if (getContainingTask().isCanceled() || getContainingTask().triggerCheckpointAsync(
							new CheckpointMetaData(0, System.currentTimeMillis()),
							CheckpointOptions.forCheckpointWithDefaultLocation(),
							false).get()) {
						LifecycleTrackingStreamSource.runFinish.trigger();
					}
				} catch (Exception e) {
					e.printStackTrace();
					Assert.fail();
				}
			}
		};
		testCheckpointer.start();
	}
}
 
Example #8
Source File: JobMasterTriggerSavepointIT.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public boolean triggerCheckpoint(final CheckpointMetaData checkpointMetaData, final CheckpointOptions checkpointOptions) {
	final TaskStateSnapshot checkpointStateHandles = new TaskStateSnapshot();
	checkpointStateHandles.putSubtaskStateByOperatorID(
		OperatorID.fromJobVertexID(getEnvironment().getJobVertexId()),
		new OperatorSubtaskState());

	getEnvironment().acknowledgeCheckpoint(
		checkpointMetaData.getCheckpointId(),
		new CheckpointMetrics(),
		checkpointStateHandles);

	triggerCheckpointLatch.countDown();

	return true;
}
 
Example #9
Source File: SourceStreamTaskTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public Boolean call() throws Exception {
	for (int i = 0; i < numCheckpoints; i++) {
		long currentCheckpointId = checkpointId.getAndIncrement();
		try {
			sourceTask.triggerCheckpointAsync(
				new CheckpointMetaData(currentCheckpointId, 0L),
				CheckpointOptions.forCheckpointWithDefaultLocation(),
				false);
		} catch (RejectedExecutionException e) {
			// We are late with a checkpoint, the mailbox is already closed.
			return false;
		}
		Thread.sleep(checkpointInterval);
	}
	return true;
}
 
Example #10
Source File: BarrierBuffer.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private void notifyCheckpoint(CheckpointBarrier checkpointBarrier) throws Exception {
	if (toNotifyOnCheckpoint != null) {
		CheckpointMetaData checkpointMetaData =
				new CheckpointMetaData(checkpointBarrier.getId(), checkpointBarrier.getTimestamp());

		long bytesBuffered = currentBuffered != null ? currentBuffered.size() : 0L;

		CheckpointMetrics checkpointMetrics = new CheckpointMetrics()
				.setBytesBufferedInAlignment(bytesBuffered)
				.setAlignmentDurationNanos(latestAlignmentDurationNanos);

		toNotifyOnCheckpoint.triggerCheckpointOnBarrier(
			checkpointMetaData,
			checkpointBarrier.getCheckpointOptions(),
			checkpointMetrics);
	}
}
 
Example #11
Source File: SubtaskCheckpointCoordinatorImpl.java    From flink with Apache License 2.0 6 votes vote down vote up
private void cleanup(
		Map<OperatorID, OperatorSnapshotFutures> operatorSnapshotsInProgress,
		CheckpointMetaData metadata,
		CheckpointMetrics metrics,
		Exception ex) {

	channelStateWriter.abort(metadata.getCheckpointId(), ex, true);
	for (OperatorSnapshotFutures operatorSnapshotResult : operatorSnapshotsInProgress.values()) {
		if (operatorSnapshotResult != null) {
			try {
				operatorSnapshotResult.cancel();
			} catch (Exception e) {
				LOG.warn("Could not properly cancel an operator snapshot result.", e);
			}
		}
	}

	if (LOG.isDebugEnabled()) {
		LOG.debug(
			"{} - did NOT finish synchronous part of checkpoint {}. Alignment duration: {} ms, snapshot duration {} ms",
			taskName, metadata.getCheckpointId(),
			metrics.getAlignmentDurationNanos() / 1_000_000,
			metrics.getSyncDurationMillis());
	}
}
 
Example #12
Source File: JobMasterTriggerSavepointITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public Future<Boolean> triggerCheckpointAsync(final CheckpointMetaData checkpointMetaData, final CheckpointOptions checkpointOptions, final boolean advanceToEndOfEventTime) {
	final TaskStateSnapshot checkpointStateHandles = new TaskStateSnapshot();
	checkpointStateHandles.putSubtaskStateByOperatorID(
		OperatorID.fromJobVertexID(getEnvironment().getJobVertexId()),
		new OperatorSubtaskState());

	getEnvironment().acknowledgeCheckpoint(
		checkpointMetaData.getCheckpointId(),
		new CheckpointMetrics(),
		checkpointStateHandles);

	triggerCheckpointLatch.countDown();

	return CompletableFuture.completedFuture(true);
}
 
Example #13
Source File: CheckpointBarrierUnalignerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
public void triggerCheckpointOnBarrier(
		CheckpointMetaData checkpointMetaData,
		CheckpointOptions checkpointOptions,
		CheckpointMetrics checkpointMetrics) {
	expectedCheckpointId = checkpointMetaData.getCheckpointId();
	totalNumCheckpoints++;
}
 
Example #14
Source File: SubtaskCheckpointCoordinatorImpl.java    From flink with Apache License 2.0 5 votes vote down vote up
private void finishAndReportAsync(Map<OperatorID, OperatorSnapshotFutures> snapshotFutures, CheckpointMetaData metadata, CheckpointMetrics metrics, CheckpointOptions options) {
	// we are transferring ownership over snapshotInProgressList for cleanup to the thread, active on submit
	executorService.execute(new AsyncCheckpointRunnable(
		snapshotFutures,
		metadata,
		metrics,
		System.nanoTime(),
		taskName,
		registerConsumer(),
		unregisterConsumer(),
		env,
		asyncExceptionHandler));
}
 
Example #15
Source File: JobMasterStopWithSavepointIT.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public Future<Boolean> triggerCheckpointAsync(CheckpointMetaData checkpointMetaData, CheckpointOptions checkpointOptions, boolean advanceToEndOfEventTime) {
	final long checkpointId = checkpointMetaData.getCheckpointId();
	final CheckpointType checkpointType = checkpointOptions.getCheckpointType();

	if (checkpointType == CheckpointType.SYNC_SAVEPOINT) {
		synchronousSavepointId = checkpointId;
		syncSavepointId.compareAndSet(-1, synchronousSavepointId);
	}

	return super.triggerCheckpointAsync(checkpointMetaData, checkpointOptions, advanceToEndOfEventTime);
}
 
Example #16
Source File: StreamMockEnvironment.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public void acknowledgeCheckpoint(long checkpointId, CheckpointMetrics checkpointMetrics, TaskStateSnapshot subtaskState) {
	taskStateManager.reportTaskStateSnapshots(
		new CheckpointMetaData(checkpointId, 0L),
		checkpointMetrics,
		subtaskState,
		null);
}
 
Example #17
Source File: StreamTaskTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testDecliningCheckpointStreamOperator() throws Exception {
	DeclineDummyEnvironment declineDummyEnvironment = new DeclineDummyEnvironment();

	// mock the returned snapshots
	OperatorSnapshotFutures operatorSnapshotResult1 = mock(OperatorSnapshotFutures.class);
	OperatorSnapshotFutures operatorSnapshotResult2 = mock(OperatorSnapshotFutures.class);

	final Exception testException = new ExpectedTestException();

	RunningTask<MockStreamTask> task = runTask(() -> createMockStreamTask(
		declineDummyEnvironment,
		operatorChain(
			streamOperatorWithSnapshotException(testException),
			streamOperatorWithSnapshot(operatorSnapshotResult1),
			streamOperatorWithSnapshot(operatorSnapshotResult2)
			)));
	MockStreamTask streamTask = task.streamTask;

	waitTaskIsRunning(streamTask, task.invocationFuture);

	streamTask.triggerCheckpointAsync(
		new CheckpointMetaData(42L, 1L),
		CheckpointOptions.forCheckpointWithDefaultLocation(),
		false);

	try {
		task.waitForTaskCompletion(false);
	}
	catch (Exception ex) {
		if (!ExceptionUtils.findThrowable(ex, ExpectedTestException.class).isPresent()) {
			throw ex;
		}
	}

	verify(operatorSnapshotResult1).cancel();
	verify(operatorSnapshotResult2).cancel();
}
 
Example #18
Source File: SubtaskCheckpointCoordinatorImpl.java    From flink with Apache License 2.0 5 votes vote down vote up
private OperatorSnapshotFutures buildOperatorSnapshotFutures(
		CheckpointMetaData checkpointMetaData,
		CheckpointOptions checkpointOptions,
		OperatorChain<?, ?> operatorChain,
		StreamOperator<?> op,
		Supplier<Boolean> isCanceled,
		ChannelStateWriteResult channelStateWriteResult,
		CheckpointStreamFactory storage) throws Exception {
	OperatorSnapshotFutures snapshotInProgress = checkpointStreamOperator(
		op,
		checkpointMetaData,
		checkpointOptions,
		storage,
		isCanceled);
	if (op == operatorChain.getHeadOperator()) {
		snapshotInProgress.setInputChannelStateFuture(
			channelStateWriteResult
				.getInputChannelStateHandles()
				.thenApply(StateObjectCollection::new)
				.thenApply(SnapshotResult::of));
	}
	if (op == operatorChain.getTailOperator()) {
		snapshotInProgress.setResultSubpartitionStateFuture(
			channelStateWriteResult
				.getResultSubpartitionStateHandles()
				.thenApply(StateObjectCollection::new)
				.thenApply(SnapshotResult::of));
	}
	return snapshotInProgress;
}
 
Example #19
Source File: SubtaskCheckpointCoordinatorTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testNotifyCheckpointAbortedDuringAsyncPhase() throws Exception {
	MockEnvironment mockEnvironment = MockEnvironment.builder().build();
	SubtaskCheckpointCoordinatorImpl subtaskCheckpointCoordinator = (SubtaskCheckpointCoordinatorImpl) new MockSubtaskCheckpointCoordinatorBuilder()
		.setEnvironment(mockEnvironment)
		.setExecutor(Executors.newSingleThreadExecutor())
		.setUnalignedCheckpointEnabled(true)
		.build();

	final BlockingRunnableFuture rawKeyedStateHandleFuture = new BlockingRunnableFuture();
	OperatorSnapshotFutures operatorSnapshotResult = new OperatorSnapshotFutures(
		DoneFuture.of(SnapshotResult.empty()),
		rawKeyedStateHandleFuture,
		DoneFuture.of(SnapshotResult.empty()),
		DoneFuture.of(SnapshotResult.empty()),
		DoneFuture.of(SnapshotResult.empty()),
		DoneFuture.of(SnapshotResult.empty()));

	final OperatorChain<String, AbstractStreamOperator<String>> operatorChain = operatorChain(new CheckpointOperator(operatorSnapshotResult));

	long checkpointId = 42L;
	subtaskCheckpointCoordinator.getChannelStateWriter().start(checkpointId, CheckpointOptions.forCheckpointWithDefaultLocation());
	subtaskCheckpointCoordinator.checkpointState(
		new CheckpointMetaData(checkpointId, System.currentTimeMillis()),
		CheckpointOptions.forCheckpointWithDefaultLocation(),
		new CheckpointMetrics(),
		operatorChain,
		() -> true);
	rawKeyedStateHandleFuture.awaitRun();
	assertEquals(1, subtaskCheckpointCoordinator.getAsyncCheckpointRunnableSize());
	assertFalse(rawKeyedStateHandleFuture.isCancelled());

	subtaskCheckpointCoordinator.notifyCheckpointAborted(checkpointId, operatorChain, () -> true);
	assertTrue(rawKeyedStateHandleFuture.isCancelled());
	assertEquals(0, subtaskCheckpointCoordinator.getAsyncCheckpointRunnableSize());
}
 
Example #20
Source File: BarrierTrackerTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public void triggerCheckpointOnBarrier(CheckpointMetaData checkpointMetaData, CheckpointOptions checkpointOptions, CheckpointMetrics checkpointMetrics) throws Exception {
	assertTrue("More checkpoints than expected", i < checkpointIDs.length);

	final long expectedId = checkpointIDs[i++];
	if (expectedId >= 0) {
		assertEquals("wrong checkpoint id", expectedId, checkpointMetaData.getCheckpointId());
		assertTrue(checkpointMetaData.getTimestamp() > 0);
	} else {
		fail("got 'triggerCheckpointOnBarrier()' when expecting an 'abortCheckpointOnBarrier()'");
	}
}
 
Example #21
Source File: StreamMockEnvironment.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void acknowledgeCheckpoint(long checkpointId, CheckpointMetrics checkpointMetrics, TaskStateSnapshot subtaskState) {
	taskStateManager.reportTaskStateSnapshots(
		new CheckpointMetaData(checkpointId, 0L),
		checkpointMetrics,
		subtaskState,
		null);
}
 
Example #22
Source File: TestTaskStateManager.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public void reportTaskStateSnapshots(
	@Nonnull CheckpointMetaData checkpointMetaData,
	@Nonnull CheckpointMetrics checkpointMetrics,
	@Nullable TaskStateSnapshot acknowledgedState,
	@Nullable TaskStateSnapshot localState) {


	jobManagerTaskStateSnapshotsByCheckpointId.put(
		checkpointMetaData.getCheckpointId(),
		acknowledgedState);

	taskManagerTaskStateSnapshotsByCheckpointId.put(
		checkpointMetaData.getCheckpointId(),
		localState);

	if (checkpointResponder != null) {
		checkpointResponder.acknowledgeCheckpoint(
			jobId,
			executionAttemptID,
			checkpointMetaData.getCheckpointId(),
			checkpointMetrics,
			acknowledgedState);
	}

	this.reportedCheckpointId = checkpointMetaData.getCheckpointId();

	if (waitForReportLatch != null) {
		waitForReportLatch.trigger();
	}
}
 
Example #23
Source File: StreamTask.java    From flink with Apache License 2.0 5 votes vote down vote up
AsyncCheckpointRunnable(
	StreamTask<?, ?> owner,
	Map<OperatorID, OperatorSnapshotFutures> operatorSnapshotsInProgress,
	CheckpointMetaData checkpointMetaData,
	CheckpointMetrics checkpointMetrics,
	long asyncStartNanos) {

	this.owner = Preconditions.checkNotNull(owner);
	this.operatorSnapshotsInProgress = Preconditions.checkNotNull(operatorSnapshotsInProgress);
	this.checkpointMetaData = Preconditions.checkNotNull(checkpointMetaData);
	this.checkpointMetrics = Preconditions.checkNotNull(checkpointMetrics);
	this.asyncStartNanos = asyncStartNanos;
}
 
Example #24
Source File: StreamTask.java    From flink with Apache License 2.0 5 votes vote down vote up
public CheckpointingOperation(
		StreamTask<?, ?> owner,
		CheckpointMetaData checkpointMetaData,
		CheckpointOptions checkpointOptions,
		CheckpointStreamFactory checkpointStorageLocation,
		CheckpointMetrics checkpointMetrics) {

	this.owner = Preconditions.checkNotNull(owner);
	this.checkpointMetaData = Preconditions.checkNotNull(checkpointMetaData);
	this.checkpointOptions = Preconditions.checkNotNull(checkpointOptions);
	this.checkpointMetrics = Preconditions.checkNotNull(checkpointMetrics);
	this.storageLocation = Preconditions.checkNotNull(checkpointStorageLocation);
	this.allOperators = owner.operatorChain.getAllOperators();
	this.operatorSnapshotsInProgress = new HashMap<>(allOperators.length);
}
 
Example #25
Source File: SourceStreamTask.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public boolean triggerCheckpoint(CheckpointMetaData checkpointMetaData, CheckpointOptions checkpointOptions, boolean advanceToEndOfEventTime) throws Exception {
	if (!externallyInducedCheckpoints) {
		return super.triggerCheckpoint(checkpointMetaData, checkpointOptions, advanceToEndOfEventTime);
	}
	else {
		// we do not trigger checkpoints here, we simply state whether we can trigger them
		synchronized (getCheckpointLock()) {
			return isRunning();
		}
	}
}
 
Example #26
Source File: CheckpointBarrierHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
protected void notifyCheckpoint(CheckpointBarrier checkpointBarrier, long bufferedBytes, long alignmentDurationNanos) throws Exception {
	if (toNotifyOnCheckpoint != null) {
		CheckpointMetaData checkpointMetaData =
			new CheckpointMetaData(checkpointBarrier.getId(), checkpointBarrier.getTimestamp());

		CheckpointMetrics checkpointMetrics = new CheckpointMetrics()
			.setBytesBufferedInAlignment(bufferedBytes)
			.setAlignmentDurationNanos(alignmentDurationNanos);

		toNotifyOnCheckpoint.triggerCheckpointOnBarrier(
			checkpointMetaData,
			checkpointBarrier.getCheckpointOptions(),
			checkpointMetrics);
	}
}
 
Example #27
Source File: CheckpointBarrierHandler.java    From flink with Apache License 2.0 5 votes vote down vote up
protected void notifyCheckpoint(CheckpointBarrier checkpointBarrier, long alignmentDurationNanos) throws IOException {
	CheckpointMetaData checkpointMetaData =
		new CheckpointMetaData(checkpointBarrier.getId(), checkpointBarrier.getTimestamp());

	CheckpointMetrics checkpointMetrics = new CheckpointMetrics()
		.setAlignmentDurationNanos(alignmentDurationNanos)
		.setCheckpointStartDelayNanos(latestCheckpointStartDelayNanos);

	toNotifyOnCheckpoint.triggerCheckpointOnBarrier(
		checkpointMetaData,
		checkpointBarrier.getCheckpointOptions(),
		checkpointMetrics);
}
 
Example #28
Source File: SynchronousCheckpointITCase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public boolean triggerCheckpoint(CheckpointMetaData checkpointMetaData, CheckpointOptions checkpointOptions, boolean advanceToEndOfEventTime) throws Exception {
	eventQueue.put(Event.PRE_TRIGGER_CHECKPOINT);
	boolean result = super.triggerCheckpoint(checkpointMetaData, checkpointOptions, advanceToEndOfEventTime);
	eventQueue.put(Event.POST_TRIGGER_CHECKPOINT);
	return result;
}
 
Example #29
Source File: StreamTaskTest.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Tests that uncaught exceptions in the async part of a checkpoint operation are forwarded
 * to the uncaught exception handler. See <a href="https://issues.apache.org/jira/browse/FLINK-12889">FLINK-12889</a>.
 */
@Test
public void testUncaughtExceptionInAsynchronousCheckpointingOperation() throws Exception {
	final RuntimeException failingCause = new RuntimeException("Test exception");
	FailingDummyEnvironment failingDummyEnvironment = new FailingDummyEnvironment(failingCause);

	// mock the returned snapshots
	OperatorSnapshotFutures operatorSnapshotResult = new OperatorSnapshotFutures(
		ExceptionallyDoneFuture.of(failingCause),
		DoneFuture.of(SnapshotResult.empty()),
		DoneFuture.of(SnapshotResult.empty()),
		DoneFuture.of(SnapshotResult.empty()));

	final TestingUncaughtExceptionHandler uncaughtExceptionHandler = new TestingUncaughtExceptionHandler();

	RunningTask<MockStreamTask> task = runTask(() -> new MockStreamTask(
		failingDummyEnvironment,
		operatorChain(streamOperatorWithSnapshot(operatorSnapshotResult)),
		uncaughtExceptionHandler));
	MockStreamTask streamTask = task.streamTask;

	waitTaskIsRunning(streamTask, task.invocationFuture);

	streamTask.triggerCheckpoint(
		new CheckpointMetaData(42L, 1L),
		CheckpointOptions.forCheckpointWithDefaultLocation(),
		false);

	final Throwable uncaughtException = uncaughtExceptionHandler.waitForUncaughtException();
	assertThat(uncaughtException, is(failingCause));

	streamTask.finishInput();
	task.waitForTaskCompletion(false);
}
 
Example #30
Source File: CheckpointBarrierAlignerTestBase.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public Future<Boolean> triggerCheckpointAsync(
		CheckpointMetaData checkpointMetaData,
		CheckpointOptions checkpointOptions,
		boolean advanceToEndOfEventTime) {
	throw new UnsupportedOperationException("should never be called");
}