Search in sources :

Example 1 with TaskManagerMessages

use of org.apache.flink.runtime.messages.TaskManagerMessages in project flink by apache.

the class TaskTest method testWatchDogInterruptsTask.

/**
	 * Tests that interrupt happens via watch dog if canceller is stuck in cancel.
	 * Task cancellation blocks the task canceller. Interrupt after cancel via
	 * cancellation watch dog.
	 */
@Test
public void testWatchDogInterruptsTask() throws Exception {
    Configuration config = new Configuration();
    config.setLong(TaskManagerOptions.TASK_CANCELLATION_INTERVAL.key(), 5);
    config.setLong(TaskManagerOptions.TASK_CANCELLATION_TIMEOUT.key(), 60 * 1000);
    Task task = createTask(InvokableBlockingInCancel.class, config);
    task.startTaskThread();
    awaitLatch.await();
    task.cancelExecution();
    task.getExecutingThread().join();
    // No fatal error
    for (Object msg : taskManagerMessages) {
        assertFalse("Unexpected FatalError message", msg instanceof TaskManagerMessages.FatalError);
    }
}
Also used : Configuration(org.apache.flink.configuration.Configuration) TaskManagerMessages(org.apache.flink.runtime.messages.TaskManagerMessages) Test(org.junit.Test)

Example 2 with TaskManagerMessages

use of org.apache.flink.runtime.messages.TaskManagerMessages in project flink by apache.

the class TaskTest method testInterruptableSharedLockInInvokeAndCancel.

/**
	 * The invoke() method holds a lock (trigger awaitLatch after acquisition)
	 * and cancel cannot complete because it also tries to acquire the same lock.
	 * This is resolved by the watch dog, no fatal error.
	 */
@Test
public void testInterruptableSharedLockInInvokeAndCancel() throws Exception {
    Configuration config = new Configuration();
    config.setLong(TaskManagerOptions.TASK_CANCELLATION_INTERVAL, 5);
    config.setLong(TaskManagerOptions.TASK_CANCELLATION_TIMEOUT, 50);
    Task task = createTask(InvokableInterruptableSharedLockInInvokeAndCancel.class, config);
    task.startTaskThread();
    awaitLatch.await();
    task.cancelExecution();
    task.getExecutingThread().join();
    // No fatal error
    for (Object msg : taskManagerMessages) {
        assertFalse("Unexpected FatalError message", msg instanceof TaskManagerMessages.FatalError);
    }
}
Also used : Configuration(org.apache.flink.configuration.Configuration) TaskManagerMessages(org.apache.flink.runtime.messages.TaskManagerMessages) Test(org.junit.Test)

Aggregations

Configuration (org.apache.flink.configuration.Configuration)2 TaskManagerMessages (org.apache.flink.runtime.messages.TaskManagerMessages)2 Test (org.junit.Test)2