Search in sources :

Example 1 with TaskCommand

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());
}
Also used : List(java.util.List) TaskCommand(ubic.gemma.core.job.TaskCommand) ProgressData(ubic.gemma.core.job.progress.ProgressData) Test(org.junit.Test) BaseSpringWebTest(ubic.gemma.web.util.BaseSpringWebTest)

Example 2 with TaskCommand

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());
}
Also used : TaskCommand(ubic.gemma.core.job.TaskCommand) Test(org.junit.Test) BaseSpringWebTest(ubic.gemma.web.util.BaseSpringWebTest)

Example 3 with TaskCommand

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);
}
Also used : ArrayDesign(ubic.gemma.model.expression.arrayDesign.ArrayDesign) ModelAndView(org.springframework.web.servlet.ModelAndView) RedirectView(org.springframework.web.servlet.view.RedirectView) EntityNotFoundException(ubic.gemma.web.util.EntityNotFoundException) BioAssay(ubic.gemma.model.expression.bioAssay.BioAssay) TaskCommand(ubic.gemma.core.job.TaskCommand) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with TaskCommand

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);
}
Also used : ObjectMessage(javax.jms.ObjectMessage) JMSException(javax.jms.JMSException) TaskCommand(ubic.gemma.core.job.TaskCommand)

Example 5 with 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());
}
Also used : List(java.util.List) TaskCommand(ubic.gemma.core.job.TaskCommand) ProgressData(ubic.gemma.core.job.progress.ProgressData) Test(org.junit.Test) BaseSpringWebTest(ubic.gemma.web.util.BaseSpringWebTest)

Aggregations

TaskCommand (ubic.gemma.core.job.TaskCommand)8 Test (org.junit.Test)3 BaseSpringWebTest (ubic.gemma.web.util.BaseSpringWebTest)3 List (java.util.List)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ModelAndView (org.springframework.web.servlet.ModelAndView)2 RedirectView (org.springframework.web.servlet.view.RedirectView)2 ProgressData (ubic.gemma.core.job.progress.ProgressData)2 ArrayDesign (ubic.gemma.model.expression.arrayDesign.ArrayDesign)2 BioAssay (ubic.gemma.model.expression.bioAssay.BioAssay)2 EntityNotFoundException (ubic.gemma.web.util.EntityNotFoundException)2 Date (java.util.Date)1 Queue (java.util.Queue)1 JMSException (javax.jms.JMSException)1 ObjectMessage (javax.jms.ObjectMessage)1 TaskResult (ubic.gemma.core.job.TaskResult)1