Search in sources :

Example 1 with Acknowledge

use of org.apache.flink.runtime.messages.Acknowledge in project flink by apache.

the class TaskExecutor method updateTaskExecutionState.

private void updateTaskExecutionState(final UUID jobMasterLeaderId, final JobMasterGateway jobMasterGateway, final TaskExecutionState taskExecutionState) {
    final ExecutionAttemptID executionAttemptID = taskExecutionState.getID();
    Future<Acknowledge> futureAcknowledge = jobMasterGateway.updateTaskExecutionState(jobMasterLeaderId, taskExecutionState);
    futureAcknowledge.exceptionallyAsync(new ApplyFunction<Throwable, Void>() {

        @Override
        public Void apply(Throwable value) {
            failTask(executionAttemptID, value);
            return null;
        }
    }, getMainThreadExecutor());
}
Also used : ExecutionAttemptID(org.apache.flink.runtime.executiongraph.ExecutionAttemptID) Acknowledge(org.apache.flink.runtime.messages.Acknowledge)

Example 2 with Acknowledge

use of org.apache.flink.runtime.messages.Acknowledge in project flink by apache.

the class Execution method sendUpdatePartitionInfoRpcCall.

/**
	 * Update the partition infos on the assigned resource.
	 *
	 * @param partitionInfos for the remote task
	 */
private void sendUpdatePartitionInfoRpcCall(final Iterable<PartitionInfo> partitionInfos) {
    final SimpleSlot slot = assignedResource;
    if (slot != null) {
        final TaskManagerGateway taskManagerGateway = slot.getTaskManagerGateway();
        final TaskManagerLocation taskManagerLocation = slot.getTaskManagerLocation();
        Future<Acknowledge> updatePartitionsResultFuture = taskManagerGateway.updatePartitions(attemptId, partitionInfos, timeout);
        updatePartitionsResultFuture.exceptionallyAsync(new ApplyFunction<Throwable, Void>() {

            @Override
            public Void apply(Throwable failure) {
                fail(new IllegalStateException("Update task on TaskManager " + taskManagerLocation + " failed due to:", failure));
                return null;
            }
        }, executor);
    }
}
Also used : Acknowledge(org.apache.flink.runtime.messages.Acknowledge) TaskManagerLocation(org.apache.flink.runtime.taskmanager.TaskManagerLocation) TaskManagerGateway(org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway) SimpleSlot(org.apache.flink.runtime.instance.SimpleSlot)

Example 3 with Acknowledge

use of org.apache.flink.runtime.messages.Acknowledge in project flink by apache.

the class Execution method deployToSlot.

public void deployToSlot(final SimpleSlot slot) throws JobException {
    checkNotNull(slot);
    // The more general check is the timeout of the deployment call
    if (!slot.isAlive()) {
        throw new JobException("Target slot (TaskManager) for deployment is no longer alive.");
    }
    // make sure exactly one deployment call happens from the correct state
    // note: the transition from CREATED to DEPLOYING is for testing purposes only
    ExecutionState previous = this.state;
    if (previous == SCHEDULED || previous == CREATED) {
        if (!transitionState(previous, DEPLOYING)) {
            // this should actually not happen and indicates a race somewhere else
            throw new IllegalStateException("Cannot deploy task: Concurrent deployment call race.");
        }
    } else {
        // vertex may have been cancelled, or it was already scheduled
        throw new IllegalStateException("The vertex must be in CREATED or SCHEDULED state to be deployed. Found state " + previous);
    }
    try {
        // good, we are allowed to deploy
        if (!slot.setExecutedVertex(this)) {
            throw new JobException("Could not assign the ExecutionVertex to the slot " + slot);
        }
        this.assignedResource = slot;
        // race double check, did we fail/cancel and do we need to release the slot?
        if (this.state != DEPLOYING) {
            slot.releaseSlot();
            return;
        }
        if (LOG.isInfoEnabled()) {
            LOG.info(String.format("Deploying %s (attempt #%d) to %s", vertex.getSimpleName(), attemptNumber, getAssignedResourceLocation().getHostname()));
        }
        final TaskDeploymentDescriptor deployment = vertex.createDeploymentDescriptor(attemptId, slot, taskState, attemptNumber);
        // register this execution at the execution graph, to receive call backs
        vertex.getExecutionGraph().registerExecution(this);
        final TaskManagerGateway taskManagerGateway = slot.getTaskManagerGateway();
        final Future<Acknowledge> submitResultFuture = taskManagerGateway.submitTask(deployment, timeout);
        submitResultFuture.exceptionallyAsync(new ApplyFunction<Throwable, Void>() {

            @Override
            public Void apply(Throwable failure) {
                if (failure instanceof TimeoutException) {
                    String taskname = vertex.getTaskNameWithSubtaskIndex() + " (" + attemptId + ')';
                    markFailed(new Exception("Cannot deploy task " + taskname + " - TaskManager (" + getAssignedResourceLocation() + ") not responding after a timeout of " + timeout, failure));
                } else {
                    markFailed(failure);
                }
                return null;
            }
        }, executor);
    } catch (Throwable t) {
        markFailed(t);
        ExceptionUtils.rethrow(t);
    }
}
Also used : ExecutionState(org.apache.flink.runtime.execution.ExecutionState) Acknowledge(org.apache.flink.runtime.messages.Acknowledge) TaskManagerGateway(org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway) TimeoutException(java.util.concurrent.TimeoutException) JobException(org.apache.flink.runtime.JobException) JobException(org.apache.flink.runtime.JobException) TaskDeploymentDescriptor(org.apache.flink.runtime.deployment.TaskDeploymentDescriptor) TimeoutException(java.util.concurrent.TimeoutException)

Example 4 with Acknowledge

use of org.apache.flink.runtime.messages.Acknowledge in project flink by apache.

the class Execution method stop.

/**
	 * Sends stop RPC call.
	 */
public void stop() {
    final SimpleSlot slot = assignedResource;
    if (slot != null) {
        final TaskManagerGateway taskManagerGateway = slot.getTaskManagerGateway();
        Future<Acknowledge> stopResultFuture = FutureUtils.retry(new Callable<Future<Acknowledge>>() {

            @Override
            public Future<Acknowledge> call() throws Exception {
                return taskManagerGateway.stopTask(attemptId, timeout);
            }
        }, NUM_STOP_CALL_TRIES, executor);
        stopResultFuture.exceptionally(new ApplyFunction<Throwable, Void>() {

            @Override
            public Void apply(Throwable failure) {
                LOG.info("Stopping task was not successful.", failure);
                return null;
            }
        });
    }
}
Also used : Acknowledge(org.apache.flink.runtime.messages.Acknowledge) TaskManagerGateway(org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway) FlinkFuture(org.apache.flink.runtime.concurrent.impl.FlinkFuture) Future(org.apache.flink.runtime.concurrent.Future) FlinkCompletableFuture(org.apache.flink.runtime.concurrent.impl.FlinkCompletableFuture) SimpleSlot(org.apache.flink.runtime.instance.SimpleSlot) TimeoutException(java.util.concurrent.TimeoutException) JobException(org.apache.flink.runtime.JobException)

Example 5 with Acknowledge

use of org.apache.flink.runtime.messages.Acknowledge in project flink by apache.

the class Execution method sendCancelRpcCall.

/**
	 * This method sends a CancelTask message to the instance of the assigned slot.
	 *
	 * The sending is tried up to NUM_CANCEL_CALL_TRIES times.
	 */
private void sendCancelRpcCall() {
    final SimpleSlot slot = assignedResource;
    if (slot != null) {
        final TaskManagerGateway taskManagerGateway = slot.getTaskManagerGateway();
        Future<Acknowledge> cancelResultFuture = FutureUtils.retry(new Callable<Future<Acknowledge>>() {

            @Override
            public Future<Acknowledge> call() throws Exception {
                return taskManagerGateway.cancelTask(attemptId, timeout);
            }
        }, NUM_CANCEL_CALL_TRIES, executor);
        cancelResultFuture.exceptionallyAsync(new ApplyFunction<Throwable, Void>() {

            @Override
            public Void apply(Throwable failure) {
                fail(new Exception("Task could not be canceled.", failure));
                return null;
            }
        }, executor);
    }
}
Also used : Acknowledge(org.apache.flink.runtime.messages.Acknowledge) TaskManagerGateway(org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway) FlinkFuture(org.apache.flink.runtime.concurrent.impl.FlinkFuture) Future(org.apache.flink.runtime.concurrent.Future) FlinkCompletableFuture(org.apache.flink.runtime.concurrent.impl.FlinkCompletableFuture) SimpleSlot(org.apache.flink.runtime.instance.SimpleSlot) TimeoutException(java.util.concurrent.TimeoutException) JobException(org.apache.flink.runtime.JobException)

Aggregations

Acknowledge (org.apache.flink.runtime.messages.Acknowledge)5 TaskManagerGateway (org.apache.flink.runtime.jobmanager.slots.TaskManagerGateway)4 TimeoutException (java.util.concurrent.TimeoutException)3 JobException (org.apache.flink.runtime.JobException)3 SimpleSlot (org.apache.flink.runtime.instance.SimpleSlot)3 Future (org.apache.flink.runtime.concurrent.Future)2 FlinkCompletableFuture (org.apache.flink.runtime.concurrent.impl.FlinkCompletableFuture)2 FlinkFuture (org.apache.flink.runtime.concurrent.impl.FlinkFuture)2 TaskDeploymentDescriptor (org.apache.flink.runtime.deployment.TaskDeploymentDescriptor)1 ExecutionState (org.apache.flink.runtime.execution.ExecutionState)1 ExecutionAttemptID (org.apache.flink.runtime.executiongraph.ExecutionAttemptID)1 TaskManagerLocation (org.apache.flink.runtime.taskmanager.TaskManagerLocation)1