Search in sources :

Example 1 with PartitionException

use of org.apache.flink.runtime.taskexecutor.exceptions.PartitionException in project flink by apache.

the class TaskExecutor method updatePartitions.

// ----------------------------------------------------------------------
// Partition lifecycle RPCs
// ----------------------------------------------------------------------
@RpcMethod
public Acknowledge updatePartitions(final ExecutionAttemptID executionAttemptID, Iterable<PartitionInfo> partitionInfos) throws PartitionException {
    final Task task = taskSlotTable.getTask(executionAttemptID);
    if (task != null) {
        for (final PartitionInfo partitionInfo : partitionInfos) {
            IntermediateDataSetID intermediateResultPartitionID = partitionInfo.getIntermediateDataSetID();
            final SingleInputGate singleInputGate = task.getInputGateById(intermediateResultPartitionID);
            if (singleInputGate != null) {
                // Run asynchronously because it might be blocking
                getRpcService().execute(new Runnable() {

                    @Override
                    public void run() {
                        try {
                            singleInputGate.updateInputChannel(partitionInfo.getInputChannelDeploymentDescriptor());
                        } catch (IOException | InterruptedException e) {
                            log.error("Could not update input data location for task {}. Trying to fail task.", task.getTaskInfo().getTaskName(), e);
                            try {
                                task.failExternally(e);
                            } catch (RuntimeException re) {
                                // TODO: Check whether we need this or make exception in failExtenally checked
                                log.error("Failed canceling task with execution ID {} after task update failure.", executionAttemptID, re);
                            }
                        }
                    }
                });
            } else {
                throw new PartitionException("No reader with ID " + intermediateResultPartitionID + " for task " + executionAttemptID + " was found.");
            }
        }
        return Acknowledge.get();
    } else {
        log.debug("Discard update for input partitions of task {}. Task is no longer running.", executionAttemptID);
        return Acknowledge.get();
    }
}
Also used : Task(org.apache.flink.runtime.taskmanager.Task) PartitionException(org.apache.flink.runtime.taskexecutor.exceptions.PartitionException) IntermediateDataSetID(org.apache.flink.runtime.jobgraph.IntermediateDataSetID) PartitionInfo(org.apache.flink.runtime.executiongraph.PartitionInfo) SingleInputGate(org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate) RpcMethod(org.apache.flink.runtime.rpc.RpcMethod)

Aggregations

PartitionInfo (org.apache.flink.runtime.executiongraph.PartitionInfo)1 SingleInputGate (org.apache.flink.runtime.io.network.partition.consumer.SingleInputGate)1 IntermediateDataSetID (org.apache.flink.runtime.jobgraph.IntermediateDataSetID)1 RpcMethod (org.apache.flink.runtime.rpc.RpcMethod)1 PartitionException (org.apache.flink.runtime.taskexecutor.exceptions.PartitionException)1 Task (org.apache.flink.runtime.taskmanager.Task)1