Search in sources :

Example 51 with CoordJobGetJPAExecutor

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

the class TestEventGeneration method testForNoDuplicatesCoordinatorActionEvents.

@Test
public void testForNoDuplicatesCoordinatorActionEvents() throws Exception {
    // test coordinator action events (failure case)
    Date startTime = DateUtils.parseDateOozieTZ("2009-02-01T23:59Z");
    Date endTime = DateUtils.parseDateOozieTZ("2009-02-02T23:59Z");
    CoordinatorJobBean coord = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, startTime, endTime, false, false, 0);
    _modifyCoordForFailureAction(coord, "wf-invalid-fork.xml");
    new CoordMaterializeTransitionXCommand(coord.getId(), 3600).call();
    final CoordJobGetJPAExecutor readCmd1 = new CoordJobGetJPAExecutor(coord.getId());
    waitFor(1 * 100, new Predicate() {

        @Override
        public boolean evaluate() throws Exception {
            CoordinatorJobBean bean = jpaService.execute(readCmd1);
            return bean.getStatus() == CoordinatorJob.Status.SUCCEEDED || bean.getStatus() == CoordinatorJob.Status.KILLED;
        }
    });
    assertEquals(2, queue.size());
    assertEquals(EventStatus.WAITING, ((JobEvent) queue.poll()).getEventStatus());
    assertEquals(EventStatus.FAILURE, ((JobEvent) queue.poll()).getEventStatus());
    queue.clear();
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) CoordMaterializeTransitionXCommand(org.apache.oozie.command.coord.CoordMaterializeTransitionXCommand) Date(java.util.Date) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CommandException(org.apache.oozie.command.CommandException) Test(org.junit.Test)

Example 52 with CoordJobGetJPAExecutor

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

the class TestEventGeneration method testInvalidXMLCoordinatorFailsForNoDuplicates.

@Test
public void testInvalidXMLCoordinatorFailsForNoDuplicates() throws Exception {
    Date startTime = DateUtils.parseDateOozieTZ("2009-02-01T23:59Z");
    Date endTime = DateUtils.parseDateOozieTZ("2009-02-02T23:59Z");
    // test coordinator action events (failure from ActionStartX)
    ehs.getAppTypes().add("workflow_action");
    CoordinatorJobBean coord = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, startTime, endTime, false, false, 0);
    CoordinatorActionBean action = addRecordToCoordActionTable(coord.getId(), 1, CoordinatorAction.Status.RUNNING, "coord-action-sla1.xml", 0);
    WorkflowJobBean wf = addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING, action.getId());
    action.setExternalId(wf.getId());
    CoordActionQueryExecutor.getInstance().executeUpdate(CoordActionQuery.UPDATE_COORD_ACTION, action);
    String waId = _createWorkflowAction(wf.getId(), "wf-action");
    new ActionStartXCommand(waId, action.getType()).call();
    final CoordJobGetJPAExecutor readCmd2 = new CoordJobGetJPAExecutor(coord.getId());
    waitFor(1 * 100, new Predicate() {

        @Override
        public boolean evaluate() throws Exception {
            return jpaService.execute(readCmd2).getStatus() == CoordinatorJob.Status.KILLED;
        }
    });
    assertEquals(3, queue.size());
    HashMap<AppType, JobEvent> eventsMap = new HashMap<AppType, JobEvent>();
    while (queue.size() > 0) {
        JobEvent event = (JobEvent) queue.poll();
        eventsMap.put(event.getAppType(), event);
    }
    assertEquals(3, eventsMap.size());
    // Check the WF action
    {
        JobEvent wfActionEvent = eventsMap.get(AppType.WORKFLOW_ACTION);
        assertNotNull("There should be a WF action", wfActionEvent);
        assertEquals(EventStatus.FAILURE, wfActionEvent.getEventStatus());
        assertEquals(waId, wfActionEvent.getId());
        assertEquals(AppType.WORKFLOW_ACTION, wfActionEvent.getAppType());
    }
    // Check the WF job
    {
        JobEvent wfJobEvent = eventsMap.get(AppType.WORKFLOW_JOB);
        assertNotNull("There should be a WF job", wfJobEvent);
        assertEquals(EventStatus.FAILURE, wfJobEvent.getEventStatus());
        assertEquals(wf.getId(), wfJobEvent.getId());
        assertEquals(AppType.WORKFLOW_JOB, wfJobEvent.getAppType());
    }
    // Check the Coordinator action
    {
        JobEvent coordActionEvent = eventsMap.get(AppType.COORDINATOR_ACTION);
        assertNotNull("There should be a Coordinator action", coordActionEvent);
        assertEquals(EventStatus.FAILURE, coordActionEvent.getEventStatus());
        assertEquals(action.getId(), coordActionEvent.getId());
        assertEquals(AppType.COORDINATOR_ACTION, coordActionEvent.getAppType());
    }
    queue.clear();
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) HashMap(java.util.HashMap) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) Date(java.util.Date) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CommandException(org.apache.oozie.command.CommandException) JobEvent(org.apache.oozie.client.event.JobEvent) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) ActionStartXCommand(org.apache.oozie.command.wf.ActionStartXCommand) AppType(org.apache.oozie.AppType) Test(org.junit.Test)

Example 53 with CoordJobGetJPAExecutor

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

the class CoordPushDependencyCheckXCommand method loadState.

@Override
protected void loadState() throws CommandException {
    jpaService = Services.get().get(JPAService.class);
    try {
        coordAction = jpaService.execute(new CoordActionGetForInputCheckJPAExecutor(actionId));
        if (coordAction != null) {
            coordJob = jpaService.execute(new CoordJobGetJPAExecutor(coordAction.getJobId()));
            LogUtils.setLogInfo(coordAction);
        } else {
            throw new CommandException(ErrorCode.E0605, actionId);
        }
    } catch (JPAExecutorException je) {
        throw new CommandException(je);
    }
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) CoordActionGetForInputCheckJPAExecutor(org.apache.oozie.executor.jpa.CoordActionGetForInputCheckJPAExecutor) CommandException(org.apache.oozie.command.CommandException) JPAService(org.apache.oozie.service.JPAService)

Example 54 with CoordJobGetJPAExecutor

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

the class CoordResumeXCommand method loadState.

@Override
protected void loadState() throws CommandException {
    jpaService = Services.get().get(JPAService.class);
    if (jpaService == null) {
        throw new CommandException(ErrorCode.E0610);
    }
    try {
        coordJob = jpaService.execute(new CoordJobGetJPAExecutor(jobId));
    } catch (JPAExecutorException e) {
        throw new CommandException(e);
    }
    setJob(coordJob);
    prevStatus = coordJob.getStatus();
    LogUtils.setLogInfo(coordJob);
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) CommandException(org.apache.oozie.command.CommandException) JPAService(org.apache.oozie.service.JPAService)

Example 55 with CoordJobGetJPAExecutor

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

the class CoordJobXCommand method execute.

/* (non-Javadoc)
     * @see org.apache.oozie.command.XCommand#execute()
     */
@Override
protected CoordinatorJobBean execute() throws CommandException {
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        CoordinatorJobBean coordJob = null;
        if (jpaService != null) {
            coordJob = jpaService.execute(new CoordJobGetJPAExecutor(id));
            if (getActionInfo) {
                int numAction = jpaService.execute(new CoordActionsCountForJobIdJPAExecutor(id, filterMap));
                List<CoordinatorActionBean> coordActions = null;
                if (len == 0) {
                    coordActions = new ArrayList<CoordinatorActionBean>();
                } else {
                    coordActions = jpaService.execute(new CoordJobGetActionsSubsetJPAExecutor(id, filterMap, offset, len, desc));
                }
                coordJob.setActions(coordActions);
                coordJob.setNumActions(numAction);
            }
        } else {
            LOG.error(ErrorCode.E0610);
        }
        return coordJob;
    } catch (XException ex) {
        throw new CommandException(ex);
    }
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordActionsCountForJobIdJPAExecutor(org.apache.oozie.executor.jpa.CoordActionsCountForJobIdJPAExecutor) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) XException(org.apache.oozie.XException) CoordJobGetActionsSubsetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetActionsSubsetJPAExecutor) CommandException(org.apache.oozie.command.CommandException) JPAService(org.apache.oozie.service.JPAService)

Aggregations

CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)121 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)114 JPAService (org.apache.oozie.service.JPAService)85 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)79 Date (java.util.Date)66 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)42 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)32 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)30 StatusTransitRunnable (org.apache.oozie.service.StatusTransitService.StatusTransitRunnable)29 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)25 BundleJobBean (org.apache.oozie.BundleJobBean)21 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)21 BundleActionBean (org.apache.oozie.BundleActionBean)20 BundleJobGetJPAExecutor (org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor)20 WorkflowActionGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor)20 CommandException (org.apache.oozie.command.CommandException)18 BundleActionGetJPAExecutor (org.apache.oozie.executor.jpa.BundleActionGetJPAExecutor)16 IOException (java.io.IOException)5 CoordMaterializeTriggerRunnable (org.apache.oozie.service.CoordMaterializeTriggerService.CoordMaterializeTriggerRunnable)5 Services (org.apache.oozie.service.Services)5