Search in sources :

Example 1 with CoordActionGetForCheckJPAExecutor

use of org.apache.oozie.executor.jpa.CoordActionGetForCheckJPAExecutor in project oozie by apache.

the class TestCoordActionsKillXCommand method testActionKillCommandActionNumbers.

/**
 * Test the working of CoordActionKillXCommand by passing range
 * as action ids
 *
 * @throws Exception
 */
public void testActionKillCommandActionNumbers() throws Exception {
    JPAService jpaService = services.get(JPAService.class);
    String[] ids = createDBRecords();
    new CoordActionsKillXCommand(ids[0], "action", "1,3").call();
    CoordinatorActionBean action = jpaService.execute(new CoordActionGetForCheckJPAExecutor(ids[1]));
    assertEquals(CoordinatorAction.Status.KILLED, action.getStatus());
    sleep(100);
    WorkflowJobBean wf = WorkflowJobQueryExecutor.getInstance().get(WorkflowJobQuery.GET_WORKFLOW_FOR_SLA, ids[3]);
    assertEquals(WorkflowJob.Status.KILLED, wf.getStatus());
    CoordinatorJobBean job = jpaService.execute(new CoordJobGetJPAExecutor(ids[0]));
    assertEquals(CoordinatorJob.Status.RUNNING, job.getStatus());
    Runnable runnable = new StatusTransitRunnable();
    runnable.run();
    job = jpaService.execute(new CoordJobGetJPAExecutor(ids[0]));
    assertEquals(CoordinatorJob.Status.RUNNINGWITHERROR, job.getStatus());
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) JPAService(org.apache.oozie.service.JPAService) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) CoordActionGetForCheckJPAExecutor(org.apache.oozie.executor.jpa.CoordActionGetForCheckJPAExecutor)

Example 2 with CoordActionGetForCheckJPAExecutor

use of org.apache.oozie.executor.jpa.CoordActionGetForCheckJPAExecutor in project oozie by apache.

the class CoordActionCheckXCommand method loadState.

/* (non-Javadoc)
     * @see org.apache.oozie.command.XCommand#loadState()
     */
@Override
protected void loadState() throws CommandException {
    try {
        jpaService = Services.get().get(JPAService.class);
        if (jpaService != null) {
            coordAction = jpaService.execute(new CoordActionGetForCheckJPAExecutor(actionId));
            coordJob = jpaService.execute(new CoordinatorJobGetForUserAppnameJPAExecutor(coordAction.getJobId()));
            workflowJob = WorkflowJobQueryExecutor.getInstance().get(WorkflowJobQuery.GET_WORKFLOW_FOR_SLA, coordAction.getExternalId());
            LogUtils.setLogInfo(coordAction);
        } else {
            throw new CommandException(ErrorCode.E0610);
        }
    } catch (XException ex) {
        throw new CommandException(ex);
    }
}
Also used : XException(org.apache.oozie.XException) CommandException(org.apache.oozie.command.CommandException) JPAService(org.apache.oozie.service.JPAService) CoordActionGetForCheckJPAExecutor(org.apache.oozie.executor.jpa.CoordActionGetForCheckJPAExecutor) CoordinatorJobGetForUserAppnameJPAExecutor(org.apache.oozie.executor.jpa.CoordinatorJobGetForUserAppnameJPAExecutor)

Example 3 with CoordActionGetForCheckJPAExecutor

use of org.apache.oozie.executor.jpa.CoordActionGetForCheckJPAExecutor in project oozie by apache.

the class TestCoordActionsKillXCommand method testActionKillCommandDate.

/**
 * Test the working of CoordActionKillXCommand by passing range
 * as date
 *
 * @throws Exception
 */
public void testActionKillCommandDate() throws Exception {
    JPAService jpaService = services.get(JPAService.class);
    String[] ids = createDBRecords();
    System.out.println(DateUtils.parseDateOozieTZ("2009-12-15T01:00Z"));
    System.out.println(DateUtils.parseDateOozieTZ("2009-12-15T02:00Z"));
    new CoordActionsKillXCommand(ids[0], "date", "2009-12-15T01:00Z::2009-12-15T02:00Z").call();
    CoordinatorActionBean action = jpaService.execute(new CoordActionGetForCheckJPAExecutor(ids[1]));
    System.out.println(action.getNominalTime());
    assertEquals(CoordinatorAction.Status.KILLED, action.getStatus());
    action = jpaService.execute(new CoordActionGetForCheckJPAExecutor(ids[2]));
    System.out.println(action.getNominalTime());
    assertEquals(CoordinatorAction.Status.KILLED, action.getStatus());
    sleep(100);
    WorkflowJobBean wf = WorkflowJobQueryExecutor.getInstance().get(WorkflowJobQuery.GET_WORKFLOW_FOR_SLA, ids[3]);
    assertEquals(WorkflowJob.Status.KILLED, wf.getStatus());
    CoordinatorJobBean job = jpaService.execute(new CoordJobGetJPAExecutor(ids[0]));
    assertEquals(CoordinatorJob.Status.RUNNING, job.getStatus());
    Runnable runnable = new StatusTransitRunnable();
    runnable.run();
    job = jpaService.execute(new CoordJobGetJPAExecutor(ids[0]));
    assertEquals(CoordinatorJob.Status.KILLED, job.getStatus());
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) JPAService(org.apache.oozie.service.JPAService) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) CoordActionGetForCheckJPAExecutor(org.apache.oozie.executor.jpa.CoordActionGetForCheckJPAExecutor)

Aggregations

CoordActionGetForCheckJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetForCheckJPAExecutor)3 JPAService (org.apache.oozie.service.JPAService)3 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)2 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)2 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)2 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)2 StatusTransitRunnable (org.apache.oozie.service.StatusTransitService.StatusTransitRunnable)2 XException (org.apache.oozie.XException)1 CommandException (org.apache.oozie.command.CommandException)1 CoordinatorJobGetForUserAppnameJPAExecutor (org.apache.oozie.executor.jpa.CoordinatorJobGetForUserAppnameJPAExecutor)1