Search in sources :

Example 1 with TaskNotRunningException

use of org.apache.flink.runtime.operators.coordination.TaskNotRunningException in project flink by apache.

the class DefaultOperatorCoordinatorHandler method deliverOperatorEventToCoordinator.

@Override
public void deliverOperatorEventToCoordinator(final ExecutionAttemptID taskExecutionId, final OperatorID operatorId, final OperatorEvent evt) throws FlinkException {
    // Failure semantics (as per the javadocs of the method):
    // If the task manager sends an event for a non-running task or an non-existing operator
    // coordinator, then respond with an exception to the call. If task and coordinator exist,
    // then we assume that the call from the TaskManager was valid, and any bubbling exception
    // needs to cause a job failure.
    final Execution exec = executionGraph.getRegisteredExecutions().get(taskExecutionId);
    if (exec == null || exec.getState() != ExecutionState.RUNNING && exec.getState() != ExecutionState.INITIALIZING) {
        // on the safe, we notify the TM that the event could not be delivered.
        throw new TaskNotRunningException("Task is not known or in state running on the JobManager.");
    }
    final OperatorCoordinatorHolder coordinator = coordinatorMap.get(operatorId);
    if (coordinator == null) {
        throw new FlinkException("No coordinator registered for operator " + operatorId);
    }
    try {
        coordinator.handleEventFromOperator(exec.getParallelSubtaskIndex(), evt);
    } catch (Throwable t) {
        ExceptionUtils.rethrowIfFatalErrorOrOOM(t);
        globalFailureHandler.handleGlobalFailure(t);
    }
}
Also used : Execution(org.apache.flink.runtime.executiongraph.Execution) TaskNotRunningException(org.apache.flink.runtime.operators.coordination.TaskNotRunningException) OperatorCoordinatorHolder(org.apache.flink.runtime.operators.coordination.OperatorCoordinatorHolder) FlinkException(org.apache.flink.util.FlinkException)

Example 2 with TaskNotRunningException

use of org.apache.flink.runtime.operators.coordination.TaskNotRunningException in project flink by apache.

the class Task method deliverOperatorEvent.

/**
 * Dispatches an operator event to the invokable task.
 *
 * <p>If the event delivery did not succeed, this method throws an exception. Callers can use
 * that exception for error reporting, but need not react with failing this task (this method
 * takes care of that).
 *
 * @throws FlinkException This method throws exceptions indicating the reason why delivery did
 *     not succeed.
 */
public void deliverOperatorEvent(OperatorID operator, SerializedValue<OperatorEvent> evt) throws FlinkException {
    final TaskInvokable invokable = this.invokable;
    final ExecutionState currentState = this.executionState;
    if (invokable == null || (currentState != ExecutionState.RUNNING && currentState != ExecutionState.INITIALIZING)) {
        throw new TaskNotRunningException("Task is not running, but in state " + currentState);
    }
    if (invokable instanceof CoordinatedTask) {
        try {
            ((CoordinatedTask) invokable).dispatchOperatorEvent(operator, evt);
        } catch (Throwable t) {
            ExceptionUtils.rethrowIfFatalErrorOrOOM(t);
            if (getExecutionState() == ExecutionState.RUNNING || getExecutionState() == ExecutionState.INITIALIZING) {
                FlinkException e = new FlinkException("Error while handling operator event", t);
                failExternally(e);
                throw e;
            }
        }
    }
}
Also used : ExecutionState(org.apache.flink.runtime.execution.ExecutionState) TaskNotRunningException(org.apache.flink.runtime.operators.coordination.TaskNotRunningException) CoordinatedTask(org.apache.flink.runtime.jobgraph.tasks.CoordinatedTask) TaskInvokable(org.apache.flink.runtime.jobgraph.tasks.TaskInvokable) FlinkException(org.apache.flink.util.FlinkException)

Example 3 with TaskNotRunningException

use of org.apache.flink.runtime.operators.coordination.TaskNotRunningException in project flink by apache.

the class Execution method sendOperatorEvent.

/**
 * Sends the operator event to the Task on the Task Executor.
 *
 * @return True, of the message was sent, false is the task is currently not running.
 */
public CompletableFuture<Acknowledge> sendOperatorEvent(OperatorID operatorId, SerializedValue<OperatorEvent> event) {
    assertRunningInJobMasterMainThread();
    final LogicalSlot slot = assignedResource;
    if (slot != null && (getState() == RUNNING || getState() == INITIALIZING)) {
        final TaskExecutorOperatorEventGateway eventGateway = slot.getTaskManagerGateway();
        return eventGateway.sendOperatorEventToTask(getAttemptId(), operatorId, event);
    } else {
        return FutureUtils.completedExceptionally(new TaskNotRunningException('"' + vertex.getTaskNameWithSubtaskIndex() + "\" is not running, but in state " + getState()));
    }
}
Also used : TaskExecutorOperatorEventGateway(org.apache.flink.runtime.taskexecutor.TaskExecutorOperatorEventGateway) TaskNotRunningException(org.apache.flink.runtime.operators.coordination.TaskNotRunningException) LogicalSlot(org.apache.flink.runtime.jobmaster.LogicalSlot)

Example 4 with TaskNotRunningException

use of org.apache.flink.runtime.operators.coordination.TaskNotRunningException in project flink by apache.

the class AdaptiveScheduler method deliverOperatorEventToCoordinator.

@Override
public void deliverOperatorEventToCoordinator(ExecutionAttemptID taskExecution, OperatorID operator, OperatorEvent evt) throws FlinkException {
    final StateWithExecutionGraph stateWithExecutionGraph = state.as(StateWithExecutionGraph.class).orElseThrow(() -> new TaskNotRunningException("Task is not known or in state running on the JobManager."));
    stateWithExecutionGraph.deliverOperatorEventToCoordinator(taskExecution, operator, evt);
}
Also used : TaskNotRunningException(org.apache.flink.runtime.operators.coordination.TaskNotRunningException)

Example 5 with TaskNotRunningException

use of org.apache.flink.runtime.operators.coordination.TaskNotRunningException in project flink by apache.

the class TaskExecutor method sendOperatorEventToTask.

// ----------------------------------------------------------------------
// Other RPCs
// ----------------------------------------------------------------------
@Override
public CompletableFuture<Acknowledge> sendOperatorEventToTask(ExecutionAttemptID executionAttemptID, OperatorID operatorId, SerializedValue<OperatorEvent> evt) {
    log.debug("Operator event for {} - {}", executionAttemptID, operatorId);
    final Task task = taskSlotTable.getTask(executionAttemptID);
    if (task == null) {
        return FutureUtils.completedExceptionally(new TaskNotRunningException("Task " + executionAttemptID + " not running on TaskManager"));
    }
    try {
        task.deliverOperatorEvent(operatorId, evt);
        return CompletableFuture.completedFuture(Acknowledge.get());
    } catch (Throwable t) {
        ExceptionUtils.rethrowIfFatalError(t);
        return FutureUtils.completedExceptionally(t);
    }
}
Also used : Task(org.apache.flink.runtime.taskmanager.Task) TaskNotRunningException(org.apache.flink.runtime.operators.coordination.TaskNotRunningException)

Aggregations

TaskNotRunningException (org.apache.flink.runtime.operators.coordination.TaskNotRunningException)5 FlinkException (org.apache.flink.util.FlinkException)2 ExecutionState (org.apache.flink.runtime.execution.ExecutionState)1 Execution (org.apache.flink.runtime.executiongraph.Execution)1 CoordinatedTask (org.apache.flink.runtime.jobgraph.tasks.CoordinatedTask)1 TaskInvokable (org.apache.flink.runtime.jobgraph.tasks.TaskInvokable)1 LogicalSlot (org.apache.flink.runtime.jobmaster.LogicalSlot)1 OperatorCoordinatorHolder (org.apache.flink.runtime.operators.coordination.OperatorCoordinatorHolder)1 TaskExecutorOperatorEventGateway (org.apache.flink.runtime.taskexecutor.TaskExecutorOperatorEventGateway)1 Task (org.apache.flink.runtime.taskmanager.Task)1