use of com.hubspot.singularity.executor.SingularityExecutorMonitor.SubmitState in project Singularity by HubSpot.
the class SingularityExecutor method launchTask.
/**
* Invoked when a task has been launched on this executor (initiated
* via Scheduler::launchTasks). Note that this task can be realized
* with a thread, a process, or some simple computation, however, no
* other callbacks will be invoked on this executor until this
* callback has returned.
*/
@Override
public void launchTask(final ExecutorDriver executorDriver, final Protos.TaskInfo taskInfo) {
final String taskId = taskInfo.getTaskId().getValue();
LOG.info("Asked to launch task {}", taskId);
try {
final ch.qos.logback.classic.Logger taskLog = taskBuilder.buildTaskLogger(taskId, taskInfo.getExecutor().getExecutorId().getValue());
final SingularityExecutorTask task = taskBuilder.buildTask(taskId, executorDriver, taskInfo, taskLog);
SubmitState submitState = monitor.submit(task);
switch(submitState) {
case REJECTED:
LOG.warn("Can't launch task {}, it was rejected (probably due to shutdown)", taskInfo);
break;
case TASK_ALREADY_EXISTED:
LOG.error("Can't launch task {}, already had a task with that ID", taskInfo);
break;
case SUBMITTED:
task.getLog().info("Launched task {} with data {}", taskId, task.getExecutorData());
break;
}
} catch (Throwable t) {
LOG.error("Unexpected exception starting task {}", taskId, t);
TaskState state = t instanceof ArtifactVerificationException ? TaskState.TASK_FAILED : TaskState.TASK_LOST;
executorUtils.sendStatusUpdate(executorDriver, taskInfo.getTaskId(), state, String.format("Unexpected exception while launching task %s - %s", taskId, t.getMessage()), LOG);
}
}
Aggregations