Search in sources :

Example 1 with TestingUncaughtExceptionHandler

use of org.apache.flink.util.concurrent.TestingUncaughtExceptionHandler in project flink by apache.

the class RobustActorSystemTest method setup.

@Before
public void setup() {
    testingUncaughtExceptionHandler = new TestingUncaughtExceptionHandler();
    robustActorSystem = RobustActorSystem.create("testSystem", AkkaUtils.getForkJoinExecutorConfig(RpcUtils.getTestForkJoinExecutorConfiguration()), testingUncaughtExceptionHandler);
}
Also used : TestingUncaughtExceptionHandler(org.apache.flink.util.concurrent.TestingUncaughtExceptionHandler) Before(org.junit.Before)

Example 2 with TestingUncaughtExceptionHandler

use of org.apache.flink.util.concurrent.TestingUncaughtExceptionHandler in project flink by apache.

the class StreamTaskTest method testUncaughtExceptionInAsynchronousCheckpointingOperation.

/**
 * 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()), 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.triggerCheckpointAsync(new CheckpointMetaData(42L, 1L), CheckpointOptions.forCheckpointWithDefaultLocation());
    final Throwable uncaughtException = uncaughtExceptionHandler.waitForUncaughtException();
    assertThat(uncaughtException, is(failingCause));
    streamTask.finishInput();
    task.waitForTaskCompletion(false);
}
Also used : OperatorSnapshotFutures(org.apache.flink.streaming.api.operators.OperatorSnapshotFutures) FlinkRuntimeException(org.apache.flink.util.FlinkRuntimeException) TestingUncaughtExceptionHandler(org.apache.flink.util.concurrent.TestingUncaughtExceptionHandler) CheckpointMetaData(org.apache.flink.runtime.checkpoint.CheckpointMetaData) Test(org.junit.Test)

Aggregations

TestingUncaughtExceptionHandler (org.apache.flink.util.concurrent.TestingUncaughtExceptionHandler)2 CheckpointMetaData (org.apache.flink.runtime.checkpoint.CheckpointMetaData)1 OperatorSnapshotFutures (org.apache.flink.streaming.api.operators.OperatorSnapshotFutures)1 FlinkRuntimeException (org.apache.flink.util.FlinkRuntimeException)1 Before (org.junit.Before)1 Test (org.junit.Test)1