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