Search in sources :

Example 6 with CoordActionInputCheckXCommand

use of org.apache.oozie.command.coord.CoordActionInputCheckXCommand in project oozie by apache.

the class TestCoordinatorInputLogic method startCoordActionForWaiting.

private void startCoordActionForWaiting(final String jobId) throws CommandException, JPAExecutorException, JDOMException {
    new CoordMaterializeTransitionXCommand(jobId, 3600).call();
    new CoordActionInputCheckXCommand(jobId + "@1", jobId).call();
    waitFor(5 * 1000, new Predicate() {

        public boolean evaluate() throws Exception {
            CoordinatorActionBean actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
            return !actionBean.getStatus().equals(CoordinatorAction.Status.WAITING);
        }
    });
    CoordinatorActionBean actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
    assertTrue("should be waiting", actionBean.getStatus().equals(CoordinatorAction.Status.WAITING));
}
Also used : CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordMaterializeTransitionXCommand(org.apache.oozie.command.coord.CoordMaterializeTransitionXCommand) CoordActionInputCheckXCommand(org.apache.oozie.command.coord.CoordActionInputCheckXCommand) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) JDOMException(org.jdom.JDOMException) IOException(java.io.IOException) CommandException(org.apache.oozie.command.CommandException)

Example 7 with CoordActionInputCheckXCommand

use of org.apache.oozie.command.coord.CoordActionInputCheckXCommand in project oozie by apache.

the class TestEventGeneration method testCoordinatorActionEvent.

@Test
public void testCoordinatorActionEvent() throws Exception {
    // avoid noise from other apptype events by setting it to only
    // coord action
    ehs.setAppTypes(new HashSet<String>(Arrays.asList("coordinator_action")));
    assertEquals(queue.size(), 0);
    Date startTime = DateUtils.parseDateOozieTZ("2013-01-01T10:00Z");
    Date endTime = DateUtils.parseDateOozieTZ("2013-01-01T10:01Z");
    CoordinatorJobBean coord = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, startTime, endTime, false, false, 0);
    modifyCoordForRunning(coord);
    // Action WAITING on materialization
    new CoordMaterializeTransitionXCommand(coord.getId(), 3600).call();
    final CoordActionGetJPAExecutor coordGetCmd = new CoordActionGetJPAExecutor(coord.getId() + "@1");
    CoordinatorActionBean action = jpaService.execute(coordGetCmd);
    assertEquals(CoordinatorAction.Status.WAITING, action.getStatus());
    assertEquals(1, queue.size());
    JobEvent event = (JobEvent) queue.poll();
    assertNotNull(event);
    assertEquals(EventStatus.WAITING, event.getEventStatus());
    assertEquals(AppType.COORDINATOR_ACTION, event.getAppType());
    assertEquals(action.getId(), event.getId());
    assertEquals(action.getJobId(), event.getParentId());
    assertEquals(action.getNominalTime(), ((CoordinatorActionEvent) event).getNominalTime());
    assertNull(event.getStartTime());
    assertEquals(coord.getUser(), event.getUser());
    assertEquals(coord.getAppName(), event.getAppName());
    assertEquals(0, queue.size());
    // Make Action ready
    // In this case it will proceed to Running since n(ready_actions) < concurrency
    new CoordActionInputCheckXCommand(action.getId(), coord.getId()).call();
    action = jpaService.execute(coordGetCmd);
    assertEquals(CoordinatorAction.Status.RUNNING, action.getStatus());
    event = (JobEvent) queue.poll();
    assertEquals(EventStatus.STARTED, event.getEventStatus());
    assertEquals(AppType.COORDINATOR_ACTION, event.getAppType());
    assertEquals(action.getId(), event.getId());
    assertEquals(action.getJobId(), event.getParentId());
    assertEquals(action.getNominalTime(), ((CoordinatorActionEvent) event).getNominalTime());
    WorkflowJobBean wfJob = jpaService.execute(new WorkflowJobGetJPAExecutor(action.getExternalId()));
    assertEquals(wfJob.getStartTime(), event.getStartTime());
    assertEquals(coord.getUser(), event.getUser());
    assertEquals(coord.getAppName(), event.getAppName());
    sleep(2000);
    // Action Success
    wfJob.setStatus(WorkflowJob.Status.SUCCEEDED);
    WorkflowJobQueryExecutor.getInstance().executeUpdate(WorkflowJobQuery.UPDATE_WORKFLOW_STATUS_MODTIME, wfJob);
    action.setStatus(CoordinatorAction.Status.RUNNING);
    CoordActionQueryExecutor.getInstance().executeUpdate(CoordActionQuery.UPDATE_COORD_ACTION_STATUS_PENDING_TIME, action);
    new CoordActionCheckXCommand(action.getId(), 0).call();
    action = jpaService.execute(coordGetCmd);
    assertEquals(CoordinatorAction.Status.SUCCEEDED, action.getStatus());
    List<Event> list = queue.pollBatch();
    event = (JobEvent) list.get(list.size() - 1);
    assertEquals(EventStatus.SUCCESS, event.getEventStatus());
    assertEquals(AppType.COORDINATOR_ACTION, event.getAppType());
    assertEquals(action.getId(), event.getId());
    assertEquals(action.getJobId(), event.getParentId());
    assertEquals(action.getNominalTime(), ((CoordinatorActionEvent) event).getNominalTime());
    assertEquals(wfJob.getStartTime(), event.getStartTime());
    assertEquals(coord.getUser(), event.getUser());
    assertEquals(coord.getAppName(), event.getAppName());
    // Action Failure
    wfJob.setStatus(WorkflowJob.Status.FAILED);
    action.setStatus(CoordinatorAction.Status.RUNNING);
    CoordActionQueryExecutor.getInstance().executeUpdate(CoordActionQuery.UPDATE_COORD_ACTION_STATUS_PENDING_TIME, action);
    WorkflowJobQueryExecutor.getInstance().executeUpdate(WorkflowJobQuery.UPDATE_WORKFLOW_STATUS_MODTIME, wfJob);
    new CoordActionCheckXCommand(action.getId(), 0).call();
    action = jpaService.execute(coordGetCmd);
    assertEquals(CoordinatorAction.Status.FAILED, action.getStatus());
    event = (JobEvent) queue.poll();
    assertEquals(EventStatus.FAILURE, event.getEventStatus());
    assertEquals(AppType.COORDINATOR_ACTION, event.getAppType());
    assertEquals(action.getId(), event.getId());
    assertEquals(action.getJobId(), event.getParentId());
    assertEquals(action.getNominalTime(), ((CoordinatorActionEvent) event).getNominalTime());
    assertEquals(wfJob.getStartTime(), event.getStartTime());
    assertEquals(coord.getUser(), event.getUser());
    assertEquals(coord.getAppName(), event.getAppName());
    // Action Suspended
    wfJob.setStatus(WorkflowJob.Status.SUSPENDED);
    action.setStatus(CoordinatorAction.Status.RUNNING);
    CoordActionQueryExecutor.getInstance().executeUpdate(CoordActionQuery.UPDATE_COORD_ACTION_STATUS_PENDING_TIME, action);
    WorkflowJobQueryExecutor.getInstance().executeUpdate(WorkflowJobQuery.UPDATE_WORKFLOW_STATUS_MODTIME, wfJob);
    new CoordActionCheckXCommand(action.getId(), 0).call();
    action = jpaService.execute(coordGetCmd);
    assertEquals(CoordinatorAction.Status.SUSPENDED, action.getStatus());
    event = (JobEvent) queue.poll();
    assertEquals(EventStatus.SUSPEND, event.getEventStatus());
    assertEquals(AppType.COORDINATOR_ACTION, event.getAppType());
    assertEquals(action.getId(), event.getId());
    assertEquals(action.getJobId(), event.getParentId());
    assertEquals(action.getNominalTime(), ((CoordinatorActionEvent) event).getNominalTime());
    assertEquals(wfJob.getStartTime(), event.getStartTime());
    assertEquals(coord.getUser(), event.getUser());
    assertEquals(coord.getAppName(), event.getAppName());
    // Action start on Coord Resume
    coord.setStatus(CoordinatorJobBean.Status.SUSPENDED);
    CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB_STATUS, coord);
    action.setStatus(CoordinatorAction.Status.SUSPENDED);
    CoordActionQueryExecutor.getInstance().executeUpdate(CoordActionQuery.UPDATE_COORD_ACTION_STATUS_PENDING_TIME, action);
    wfJob.setStatus(WorkflowJob.Status.SUSPENDED);
    WorkflowInstance wfInstance = wfJob.getWorkflowInstance();
    ((LiteWorkflowInstance) wfInstance).setStatus(WorkflowInstance.Status.SUSPENDED);
    wfJob.setWorkflowInstance(wfInstance);
    WorkflowJobQueryExecutor.getInstance().executeUpdate(WorkflowJobQuery.UPDATE_WORKFLOW_STATUS_INSTANCE_MODIFIED, wfJob);
    queue.clear();
    new CoordResumeXCommand(coord.getId()).call();
    waitForEventGeneration(1000);
    CoordinatorActionEvent cevent = (CoordinatorActionEvent) queue.poll();
    assertEquals(EventStatus.STARTED, cevent.getEventStatus());
    assertEquals(AppType.COORDINATOR_ACTION, cevent.getAppType());
    assertEquals(action.getId(), cevent.getId());
    assertEquals(action.getJobId(), cevent.getParentId());
    assertEquals(action.getNominalTime(), cevent.getNominalTime());
    coord = CoordJobQueryExecutor.getInstance().get(CoordJobQuery.GET_COORD_JOB, coord.getId());
    assertEquals(coord.getLastModifiedTime(), cevent.getStartTime());
    // Action going to WAITING on Coord Rerun
    action.setStatus(CoordinatorAction.Status.KILLED);
    CoordActionQueryExecutor.getInstance().executeUpdate(CoordActionQuery.UPDATE_COORD_ACTION_STATUS_PENDING_TIME, action);
    queue.clear();
    new CoordRerunXCommand(coord.getId(), RestConstants.JOB_COORD_SCOPE_ACTION, "1", false, true, false, null).call();
    waitFor(3 * 100, new Predicate() {

        @Override
        public boolean evaluate() throws Exception {
            return jpaService.execute(coordGetCmd).getStatus() == CoordinatorAction.Status.WAITING;
        }
    });
    cevent = (CoordinatorActionEvent) queue.poll();
    assertEquals(EventStatus.WAITING, cevent.getEventStatus());
    assertEquals(AppType.COORDINATOR_ACTION, cevent.getAppType());
    assertEquals(action.getId(), cevent.getId());
    assertEquals(action.getJobId(), cevent.getParentId());
    assertEquals(action.getNominalTime(), cevent.getNominalTime());
    assertEquals(wfJob.getStartTime(), event.getStartTime());
    assertNotNull(cevent.getMissingDeps());
}
Also used : WorkflowJobGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor) CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordRerunXCommand(org.apache.oozie.command.coord.CoordRerunXCommand) LiteWorkflowInstance(org.apache.oozie.workflow.lite.LiteWorkflowInstance) CoordActionGetJPAExecutor(org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor) CoordMaterializeTransitionXCommand(org.apache.oozie.command.coord.CoordMaterializeTransitionXCommand) CoordActionCheckXCommand(org.apache.oozie.command.coord.CoordActionCheckXCommand) LiteWorkflowInstance(org.apache.oozie.workflow.lite.LiteWorkflowInstance) WorkflowInstance(org.apache.oozie.workflow.WorkflowInstance) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) Date(java.util.Date) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CommandException(org.apache.oozie.command.CommandException) CoordResumeXCommand(org.apache.oozie.command.coord.CoordResumeXCommand) JobEvent(org.apache.oozie.client.event.JobEvent) JobEvent(org.apache.oozie.client.event.JobEvent) Event(org.apache.oozie.client.event.Event) CoordActionInputCheckXCommand(org.apache.oozie.command.coord.CoordActionInputCheckXCommand) Test(org.junit.Test)

Example 8 with CoordActionInputCheckXCommand

use of org.apache.oozie.command.coord.CoordActionInputCheckXCommand in project oozie by apache.

the class TestCoordInputLogicPush method testHcatHdfs.

public void testHcatHdfs() throws Exception {
    Configuration conf = getConfForCombine();
    conf.set("initial_instance_a", "2014-10-07T00:00Z");
    conf.set("initial_instance_b", "2014-10-07T00:00Z");
    String inputLogic = // @formatter:off
    "<and name=\"test\">" + "<data-in name=\"testA\" dataset=\"A\" />" + "<data-in name=\"testB\" dataset=\"B\" />" + "</and>";
    // @formatter:on
    String jobId = submitCoord("coord-inputlogic-combine.xml", conf, inputLogic, TEST_TYPE.CURRENT_SINGLE);
    String input1 = createTestCaseSubDir("input-data/b/2014/10/08/_SUCCESS".split("/"));
    String input2 = addPartition("db_a", "table1", "dt=20141008;country=usa");
    new CoordMaterializeTransitionXCommand(jobId, 3600).call();
    new CoordPushDependencyCheckXCommand(jobId + "@1").call();
    new CoordActionInputCheckXCommand(jobId + "@1", jobId).call();
    startCoordAction(jobId);
    CoordinatorActionBean actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
    assertFalse(CoordinatorAction.Status.WAITING.equals(actionBean.getStatus()));
    XConfiguration runConf = new XConfiguration(new StringReader(actionBean.getRunConf()));
    String dataSets = runConf.get("inputLogicData");
    assertEquals(dataSets.split(",").length, 2);
    checkDataSets(dataSets, input1, input2);
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) CoordPushDependencyCheckXCommand(org.apache.oozie.command.coord.CoordPushDependencyCheckXCommand) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) StringReader(java.io.StringReader) CoordMaterializeTransitionXCommand(org.apache.oozie.command.coord.CoordMaterializeTransitionXCommand) CoordActionInputCheckXCommand(org.apache.oozie.command.coord.CoordActionInputCheckXCommand)

Example 9 with CoordActionInputCheckXCommand

use of org.apache.oozie.command.coord.CoordActionInputCheckXCommand in project oozie by apache.

the class TestCoordInputLogicPush method startCoordAction.

private void startCoordAction(final String jobId) throws CommandException, JPAExecutorException {
    new CoordMaterializeTransitionXCommand(jobId, 3600).call();
    new CoordActionInputCheckXCommand(jobId + "@1", jobId).call();
    new CoordPushDependencyCheckXCommand(jobId + "@1").call();
    new CoordActionInputCheckXCommand(jobId + "@1", jobId).call();
    waitFor(50 * 1000, new Predicate() {

        public boolean evaluate() throws Exception {
            CoordinatorActionBean actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
            return !actionBean.getStatus().equals(CoordinatorAction.Status.WAITING);
        }
    });
    CoordinatorAction actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
    assertFalse("Action status should not be waiting", actionBean.getStatus().equals(CoordinatorAction.Status.WAITING));
    waitFor(50 * 1000, new Predicate() {

        public boolean evaluate() throws Exception {
            CoordinatorActionBean actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
            return !actionBean.getStatus().equals(CoordinatorAction.Status.READY);
        }
    });
    CoordinatorJob coordJob = CoordJobQueryExecutor.getInstance().get(CoordJobQuery.GET_COORD_JOB, jobId);
    new CoordActionStartXCommand(actionBean.getId(), coordJob.getUser(), coordJob.getAppName(), actionBean.getJobId()).call();
}
Also used : CoordinatorJob(org.apache.oozie.client.CoordinatorJob) CoordPushDependencyCheckXCommand(org.apache.oozie.command.coord.CoordPushDependencyCheckXCommand) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordinatorAction(org.apache.oozie.client.CoordinatorAction) CoordActionStartXCommand(org.apache.oozie.command.coord.CoordActionStartXCommand) CoordMaterializeTransitionXCommand(org.apache.oozie.command.coord.CoordMaterializeTransitionXCommand) CoordActionInputCheckXCommand(org.apache.oozie.command.coord.CoordActionInputCheckXCommand) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) JDOMException(org.jdom.JDOMException) IOException(java.io.IOException) CommandException(org.apache.oozie.command.CommandException)

Example 10 with CoordActionInputCheckXCommand

use of org.apache.oozie.command.coord.CoordActionInputCheckXCommand in project oozie by apache.

the class TestCoordinatorInputLogic method testWaitFail.

public void testWaitFail() throws Exception {
    Configuration conf = getConf();
    Date now = new Date();
    String inputLogic = // @formatter:off
    "<or name=\"test\" min=\"${min}\" wait=\"${wait}\">" + "<data-in dataset=\"${dataA}\" />" + "<data-in dataset=\"${dataB}\" />" + "</or>";
    // @formatter:on
    conf.set("start_time", DateUtils.formatDateOozieTZ(now));
    conf.set("min", "4");
    conf.set("wait", "180");
    conf.set("dataA", "A");
    conf.set("dataB", "B");
    conf.set("end_time", DateUtils.formatDateOozieTZ(new Date(now.getTime() + 3 * 60 * 60 * 1000)));
    conf.set("initial_instance_a", DateUtils.formatDateOozieTZ(new Date(now.getTime() - 5 * 60 * 60 * 1000)));
    conf.set("initial_instance_b", DateUtils.formatDateOozieTZ(new Date(now.getTime() - 5 * 60 * 60 * 1000)));
    String jobId = _testCoordSubmit("coord-inputlogic-range.xml", conf, inputLogic, getInputEventForRange());
    createDirWithTime("input-data/b/", now, 0, 1, 2, 3, 4);
    startCoordActionForWaiting(jobId);
    new CoordActionInputCheckXCommand(jobId + "@1", jobId).call();
    CoordinatorActionBean actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
    assertTrue(CoordinatorAction.Status.WAITING.equals(actionBean.getStatus()));
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordActionInputCheckXCommand(org.apache.oozie.command.coord.CoordActionInputCheckXCommand) Date(java.util.Date)

Aggregations

CoordActionInputCheckXCommand (org.apache.oozie.command.coord.CoordActionInputCheckXCommand)13 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)12 CoordMaterializeTransitionXCommand (org.apache.oozie.command.coord.CoordMaterializeTransitionXCommand)11 Configuration (org.apache.hadoop.conf.Configuration)9 XConfiguration (org.apache.oozie.util.XConfiguration)9 StringReader (java.io.StringReader)6 Date (java.util.Date)5 CommandException (org.apache.oozie.command.CommandException)5 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)5 IOException (java.io.IOException)4 CoordinatorAction (org.apache.oozie.client.CoordinatorAction)4 JDOMException (org.jdom.JDOMException)4 CoordinatorJob (org.apache.oozie.client.CoordinatorJob)2 CoordActionStartXCommand (org.apache.oozie.command.coord.CoordActionStartXCommand)2 CoordPushDependencyCheckXCommand (org.apache.oozie.command.coord.CoordPushDependencyCheckXCommand)2 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)1 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)1 Event (org.apache.oozie.client.event.Event)1 JobEvent (org.apache.oozie.client.event.JobEvent)1 CoordActionCheckXCommand (org.apache.oozie.command.coord.CoordActionCheckXCommand)1