/** * This test checks that cancel calls that are issued before the operator is * instantiated still lead to proper canceling. */ @Test public void testEarlyCanceling() throws Exception { final StreamConfig cfg = new StreamConfig(new Configuration()); cfg.setOperatorID(new OperatorID(4711L, 42L)); cfg.setStreamOperator(new SlowlyDeserializingOperator()); cfg.setTimeCharacteristic(TimeCharacteristic.ProcessingTime); final TaskManagerActions taskManagerActions = spy(new NoOpTaskManagerActions()); final Task task = createTask(SourceStreamTask.class, cfg, new Configuration(), taskManagerActions); final TaskExecutionState state = new TaskExecutionState( task.getJobID(), task.getExecutionId(), ExecutionState.RUNNING); task.startTaskThread(); verify(taskManagerActions, timeout(2000L)).updateTaskExecutionState(eq(state)); // send a cancel. because the operator takes a long time to deserialize, this should // hit the task before the operator is deserialized task.cancelExecution(); task.getExecutingThread().join(); assertFalse("Task did not cancel", task.getExecutingThread().isAlive()); assertEquals(ExecutionState.CANCELED, task.getExecutionState()); }
private void notifyFatalError(String message, Throwable cause) { taskManagerActions.notifyFatalError(message, cause); }
private void notifyFinalState() { taskManagerActions.notifyFinalState(executionId); }
@Override public void run() { try { ((StoppableTask) invokable).stop(); } catch (RuntimeException e) { LOG.error("Stopping task {} ({}) failed.", taskNameWithSubtask, executionId, e); taskManagerActions.failTask(executionId, e); } } };
@Override public void run() { try { ((StoppableTask)invokable).stop(); } catch(RuntimeException e) { LOG.error("Stopping task {} ({}) failed.", taskNameWithSubtask, executionId, e); taskManagerActions.failTask(executionId, e); } } };
private void notifyFinalState() { checkState(executionState.isTerminal()); taskManagerActions.updateTaskExecutionState(new TaskExecutionState(jobId, executionId, executionState, failureCause)); }
private void notifyFatalError(String message, Throwable cause) { taskManagerActions.notifyFatalError(message, cause); }
} catch (Throwable t) { LOG.error("Stopping task {} ({}) failed.", taskNameWithSubtask, executionId, t); taskManagerActions.failTask(executionId, t);
private void notifyFinalState() { taskManagerActions.notifyFinalState(executionId); }
private void notifyFinalState() { checkState(executionState.isTerminal()); taskManagerActions.updateTaskExecutionState(new TaskExecutionState(jobId, executionId, executionState, failureCause)); }
private void notifyFatalError(String message, Throwable cause) { taskManagerActions.notifyFatalError(message, cause); }
} catch (Throwable t) { LOG.error("Stopping task {} ({}) failed.", taskNameWithSubtask, executionId, t); taskManagerActions.failTask(executionId, t);
taskManagerActions.updateTaskExecutionState(new TaskExecutionState(jobId, executionId, ExecutionState.RUNNING));
private void notifyFatalError(String message, Throwable cause) { taskManagerActions.notifyFatalError(message, cause); }
taskManagerActions.updateTaskExecutionState(new TaskExecutionState(jobId, executionId, ExecutionState.RUNNING));
taskManager.notifyFatalError(msg, null);
taskManagerActions.updateTaskExecutionState(new TaskExecutionState(jobId, executionId, ExecutionState.RUNNING));
taskManagerActions.updateTaskExecutionState(new TaskExecutionState(jobId, executionId, ExecutionState.RUNNING));