use of ubic.gemma.core.job.TaskCommand in project Gemma by PavlidisLab.
the class TaskRunningTest method testFailedRun.
@Test
public final void testFailedRun() throws Exception {
// goes to the progress page...handleRequest
TaskCommand taskCommand = new TaskCommand();
// we use this for 'die' in this test.
taskCommand.setPersistJobDetails(false);
String taskId = mockLongJobController.runJob(taskCommand);
assertNotNull(taskId);
// wait for job to run
ProgressData lastResult = null;
long timeout = 5000;
long startTime = System.currentTimeMillis();
wait: while (true) {
Thread.sleep(500);
List<ProgressData> result = progressStatusService.getProgressStatus(taskId);
if (result.size() > 0) {
for (ProgressData lr : result) {
lastResult = lr;
if (lr.isFailed()) {
// yay
return;
}
if (lr.isDone())
break wait;
}
}
log.info("Waiting ..");
if (System.currentTimeMillis() - startTime > timeout)
fail("Test timed out");
}
assertNotNull(lastResult);
assertTrue(lastResult.isFailed());
}
use of ubic.gemma.core.job.TaskCommand in project Gemma by PavlidisLab.
the class TaskRunningTest method testCancelledRun.
@Test
public final void testCancelledRun() throws Exception {
// goes to the progress page...handleRequest
TaskCommand taskCommand = new TaskCommand();
String taskId = mockLongJobController.runJob(taskCommand);
// let it go a little while
Thread.sleep(100);
SubmittedTask<?> task = taskRunningService.getSubmittedTask(taskId);
assertNotNull(task);
// cancel it.
task.requestCancellation();
assertEquals(SubmittedTask.Status.CANCELLING, task.getStatus());
}
use of ubic.gemma.core.job.TaskCommand in project Gemma by PavlidisLab.
the class ArrayDesignControllerImpl method delete.
@Override
@RequestMapping("/deleteArrayDesign.html")
public ModelAndView delete(HttpServletRequest request, HttpServletResponse response) {
String stringId = request.getParameter("id");
if (stringId == null) {
// should be a validation error.
throw new EntityNotFoundException("Must provide an id");
}
Long id;
try {
id = Long.parseLong(stringId);
} catch (NumberFormatException e) {
throw new EntityNotFoundException("Identifier was invalid");
}
ArrayDesign arrayDesign = arrayDesignService.load(id);
if (arrayDesign == null) {
throw new EntityNotFoundException("Platform with id=" + id + " not found");
}
// check that no EE depend on the arraydesign we want to remove
// Do this by checking if there are any bioassays that depend this AD
Collection<BioAssay> assays = arrayDesignService.getAllAssociatedBioAssays(id);
if (assays.size() != 0) {
return new ModelAndView(new RedirectView("/arrays/showAllArrayDesigns.html", true)).addObject("message", "Array " + arrayDesign.getName() + " can't be deleted. Dataset has a dependency on this Array.");
}
String taskId = taskRunningService.submitLocalTask(new TaskCommand(arrayDesign.getId()));
return new ModelAndView().addObject("taskId", taskId);
}
use of ubic.gemma.core.job.TaskCommand in project Gemma by PavlidisLab.
the class TaskSubmissionListener method onMessage.
@Override
public void onMessage(Message message) {
log.info("Received new remote task command!");
ObjectMessage objectMessage = (ObjectMessage) message;
TaskCommand taskCommand = null;
try {
taskCommand = (TaskCommand) objectMessage.getObject();
} catch (JMSException e) {
e.printStackTrace();
}
log.info("Submitting task command for execution.");
remoteTaskRunningService.submit(taskCommand);
}
use of ubic.gemma.core.job.TaskCommand in project Gemma by PavlidisLab.
the class TaskRunningTest method testSuccessfulRun.
@Test
public final void testSuccessfulRun() throws Exception {
TaskCommand taskCommand = new TaskCommand();
String taskId = mockLongJobController.runJob(taskCommand);
// wait for job to run
long timeout = 5000;
ProgressData lastResult = null;
long startTime = System.currentTimeMillis();
wait: while (true) {
Thread.sleep(500);
List<ProgressData> result = progressStatusService.getProgressStatus(taskId);
if (result.size() > 0) {
for (ProgressData lr : result) {
lastResult = lr;
if (lr.isDone())
break wait;
}
}
log.info("Waiting ..");
if (System.currentTimeMillis() - startTime > timeout)
fail("Test timed out");
}
assertNotNull(lastResult);
assertTrue(!lastResult.isFailed());
}
Aggregations