use of org.apache.flink.runtime.execution.CancelTaskException in project flink-mirror by flink-ci.
the class BufferManager method shouldContinueRequest.
private boolean shouldContinueRequest(BufferPool bufferPool) {
if (bufferPool.addBufferListener(this)) {
isWaitingForFloatingBuffers = true;
numRequiredBuffers = 1;
return false;
} else if (bufferPool.isDestroyed()) {
throw new CancelTaskException("Local buffer pool has already been released.");
} else {
return true;
}
}
use of org.apache.flink.runtime.execution.CancelTaskException in project flink-mirror by flink-ci.
the class TaskTest method testCancelTaskExceptionAfterTaskMarkedFailed.
@Test
public void testCancelTaskExceptionAfterTaskMarkedFailed() throws Exception {
final Task task = createTaskBuilder().setInvokable(InvokableWithCancelTaskExceptionInInvoke.class).build();
task.startTaskThread();
// Wait till the task is in invoke.
awaitLatch.await();
task.failExternally(new Exception("external"));
assertFalse(triggerLatch.isTriggered());
assertEquals(ExecutionState.FAILED, task.getExecutionState());
// Either we cause the CancelTaskException or the TaskCanceler
// by interrupting the invokable.
triggerLatch.trigger();
task.getExecutingThread().join();
assertEquals(ExecutionState.FAILED, task.getExecutionState());
assertTrue(task.isCanceledOrFailed());
assertTrue(task.getFailureCause().getMessage().contains("external"));
}
use of org.apache.flink.runtime.execution.CancelTaskException in project flink-mirror by flink-ci.
the class CheckpointedInputGateTest method testPriorityBeforeClose.
/**
* Tests a priority notification happening right before cancellation. The mail would be
* processed while draining mailbox but can't pull any data anymore.
*/
@Test
public void testPriorityBeforeClose() throws IOException, InterruptedException {
NetworkBufferPool bufferPool = new NetworkBufferPool(10, 1024);
try (Closer closer = Closer.create()) {
closer.register(bufferPool::destroy);
for (int repeat = 0; repeat < 100; repeat++) {
setUp();
SingleInputGate singleInputGate = new SingleInputGateBuilder().setNumberOfChannels(2).setBufferPoolFactory(bufferPool.createBufferPool(2, Integer.MAX_VALUE)).setSegmentProvider(bufferPool).setChannelFactory(InputChannelBuilder::buildRemoteChannel).build();
singleInputGate.setup();
((RemoteInputChannel) singleInputGate.getChannel(0)).requestSubpartition();
final TaskMailboxImpl mailbox = new TaskMailboxImpl();
MailboxExecutorImpl mailboxExecutor = new MailboxExecutorImpl(mailbox, 0, StreamTaskActionExecutor.IMMEDIATE);
ValidatingCheckpointHandler validatingHandler = new ValidatingCheckpointHandler(1);
SingleCheckpointBarrierHandler barrierHandler = TestBarrierHandlerFactory.forTarget(validatingHandler).create(singleInputGate, new MockChannelStateWriter());
CheckpointedInputGate checkpointedInputGate = new CheckpointedInputGate(singleInputGate, barrierHandler, mailboxExecutor, UpstreamRecoveryTracker.forInputGate(singleInputGate));
final int oldSize = mailbox.size();
enqueue(checkpointedInputGate, 0, barrier(1));
// wait for priority mail to be enqueued
Deadline deadline = Deadline.fromNow(Duration.ofMinutes(1));
while (deadline.hasTimeLeft() && oldSize >= mailbox.size()) {
Thread.sleep(1);
}
// test the race condition
// either priority event could be handled, then we expect a checkpoint to be
// triggered or closing came first in which case we expect a CancelTaskException
CountDownLatch beforeLatch = new CountDownLatch(2);
final CheckedThread canceler = new CheckedThread("Canceler") {
@Override
public void go() throws IOException {
beforeLatch.countDown();
singleInputGate.close();
}
};
canceler.start();
beforeLatch.countDown();
try {
while (mailboxExecutor.tryYield()) {
}
assertEquals(1L, validatingHandler.triggeredCheckpointCounter);
} catch (CancelTaskException e) {
}
canceler.join();
}
}
}
use of org.apache.flink.runtime.execution.CancelTaskException in project flink-mirror by flink-ci.
the class LocalInputChannelTest method testProducerFailedException.
@Test(expected = CancelTaskException.class)
public void testProducerFailedException() throws Exception {
ResultSubpartitionView view = mock(ResultSubpartitionView.class);
when(view.isReleased()).thenReturn(true);
when(view.getFailureCause()).thenReturn(new Exception("Expected test exception"));
ResultPartitionManager partitionManager = mock(ResultPartitionManager.class);
when(partitionManager.createSubpartitionView(any(ResultPartitionID.class), anyInt(), any(BufferAvailabilityListener.class))).thenReturn(view);
SingleInputGate inputGate = mock(SingleInputGate.class);
BufferProvider bufferProvider = mock(BufferProvider.class);
when(inputGate.getBufferProvider()).thenReturn(bufferProvider);
LocalInputChannel ch = createLocalInputChannel(inputGate, partitionManager);
ch.requestSubpartition();
// Should throw an instance of CancelTaskException.
ch.getNextBuffer();
}
use of org.apache.flink.runtime.execution.CancelTaskException in project flink by splunk.
the class TaskTest method testCancelTaskExceptionAfterTaskMarkedFailed.
@Test
public void testCancelTaskExceptionAfterTaskMarkedFailed() throws Exception {
final Task task = createTaskBuilder().setInvokable(InvokableWithCancelTaskExceptionInInvoke.class).build();
task.startTaskThread();
// Wait till the task is in invoke.
awaitLatch.await();
task.failExternally(new Exception("external"));
assertFalse(triggerLatch.isTriggered());
assertEquals(ExecutionState.FAILED, task.getExecutionState());
// Either we cause the CancelTaskException or the TaskCanceler
// by interrupting the invokable.
triggerLatch.trigger();
task.getExecutingThread().join();
assertEquals(ExecutionState.FAILED, task.getExecutionState());
assertTrue(task.isCanceledOrFailed());
assertTrue(task.getFailureCause().getMessage().contains("external"));
}
Aggregations