use of ubic.gemma.core.job.TaskCommand in project Gemma by PavlidisLab.
the class TaskRunningServiceImpl method submitLocalTask.
@Override
public <T extends Task> String submitLocalTask(T task) {
this.checkTask(task);
TaskCommand taskCommand = task.getTaskCommand();
this.checkTaskCommand(taskCommand);
final String taskId = task.getTaskCommand().getTaskId();
if (TaskRunningServiceImpl.log.isDebugEnabled()) {
TaskRunningServiceImpl.log.debug("Submitting local task with id: " + taskId);
}
final SubmittedTaskLocal submittedTask = new SubmittedTaskLocal(task.getTaskCommand(), taskPostProcessing);
final ExecutingTask<TaskResult> executingTask = new ExecutingTask<TaskResult>(task, taskCommand);
executingTask.setStatusCallback(new ExecutingTask.TaskLifecycleHandler() {
@Override
public void onFailure(Throwable e) {
TaskRunningServiceImpl.log.error(e, e);
submittedTask.updateStatus(SubmittedTask.Status.FAILED, new Date());
}
@Override
public void onFinish() {
submittedTask.updateStatus(SubmittedTask.Status.COMPLETED, new Date());
}
@Override
public void onStart() {
submittedTask.updateStatus(SubmittedTask.Status.RUNNING, new Date());
}
});
executingTask.setProgressAppender(new LogBasedProgressAppender(taskId, new ProgressUpdateCallback() {
private final Queue<String> progressUpdates = submittedTask.getProgressUpdates();
@Override
public void addProgressUpdate(String message) {
progressUpdates.add(message);
}
}));
ListenableFuture<TaskResult> future = executorService.submit(executingTask);
submittedTask.setFuture(future);
// Currently we have only email notification.
if (taskCommand.isEmailAlert()) {
submittedTask.addEmailAlert();
}
submittedTasks.put(taskId, submittedTask);
return taskId;
}
use of ubic.gemma.core.job.TaskCommand in project Gemma by PavlidisLab.
the class ArrayDesignControllerImpl method generateSummary.
@Override
@RequestMapping("/generateArrayDesignSummary.html")
public ModelAndView generateSummary(HttpServletRequest request, HttpServletResponse response) {
String sId = request.getParameter("id");
// if no IDs are specified, then load all expressionExperiments and show the summary (if available)
GenerateArraySummaryLocalTask job;
if (StringUtils.isBlank(sId)) {
job = new GenerateArraySummaryLocalTask(new TaskCommand());
String taskId = taskRunningService.submitLocalTask(job);
return new ModelAndView(new RedirectView("/arrays/showAllArrayDesigns.html", true)).addObject("taskId", taskId);
}
try {
Long id = Long.parseLong(sId);
job = new GenerateArraySummaryLocalTask(new TaskCommand(id));
String taskId = taskRunningService.submitLocalTask(job);
return new ModelAndView(new RedirectView("/arrays/showAllArrayDesigns.html?id=" + sId, true)).addObject("taskId", taskId);
} catch (NumberFormatException e) {
throw new RuntimeException("Invalid ID: " + sId);
}
}
use of ubic.gemma.core.job.TaskCommand in project Gemma by PavlidisLab.
the class ArrayDesignControllerImpl method remove.
@Override
public String remove(EntityDelegator ed) {
ArrayDesign arrayDesign = arrayDesignService.load(ed.getId());
if (arrayDesign == null) {
throw new EntityNotFoundException(ed.getId() + " not found");
}
Collection<BioAssay> assays = arrayDesignService.getAllAssociatedBioAssays(ed.getId());
if (assays.size() != 0) {
throw new IllegalArgumentException("Cannot remove " + arrayDesign + ", it is used by an expression experiment");
}
RemoveArrayLocalTask job = new RemoveArrayLocalTask(new TaskCommand(arrayDesign.getId()));
return taskRunningService.submitLocalTask(job);
}
Aggregations