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);
}
}
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;
}
}
}
}
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()));
}
}
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);
}
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);
}
}
Aggregations