Search in sources :

Example 6 with CoordinatorActionBean

use of org.apache.oozie.CoordinatorActionBean in project oozie by apache.

the class TestRecoveryService method addRecordToCoordActionTableForWaiting.

protected CoordinatorActionBean addRecordToCoordActionTableForWaiting(String jobId, int actionNum, CoordinatorAction.Status status, String resourceXmlName) throws Exception {
    CoordinatorActionBean action = createCoordAction(jobId, actionNum, status, resourceXmlName, 0);
    String testDir = getTestCaseDir();
    String missDeps = getTestCaseFileUri("2009/29/_SUCCESS") + "#" + getTestCaseFileUri("2009/22/_SUCCESS") + "#" + getTestCaseFileUri("2009/15/_SUCCESS") + "#" + getTestCaseFileUri("2009/08/_SUCCESS");
    missDeps = missDeps.replaceAll("#testDir", testDir);
    action.setMissingDependencies(missDeps);
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        CoordActionInsertJPAExecutor coordActionInsertCmd = new CoordActionInsertJPAExecutor(action);
        jpaService.execute(coordActionInsertCmd);
    } catch (JPAExecutorException je) {
        je.printStackTrace();
        fail("Unable to insert the test coord action record to table");
        throw je;
    }
    return action;
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordActionInsertJPAExecutor(org.apache.oozie.executor.jpa.CoordActionInsertJPAExecutor) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean)

Example 7 with CoordinatorActionBean

use of org.apache.oozie.CoordinatorActionBean in project oozie by apache.

the class TestRecoveryService method testCoordActionRecoveryServiceForSubmitted.

/**
 * Tests functionality of the Recovery Service Runnable command. </p> Insert a coordinator job with RUNNING and
 * action with SUBMITTED. Then, runs the recovery runnable and ensures the action status changes to RUNNING.
 *
 * @throws Exception
 */
public void testCoordActionRecoveryServiceForSubmitted() throws Exception {
    final String jobId = "0000000-" + new Date().getTime() + "-testCoordRecoveryService-C";
    final int actionNum = 1;
    final String actionId = jobId + "@" + actionNum;
    final CoordinatorEngine ce = new CoordinatorEngine(getTestUser());
    createTestCaseSubDir("one-op");
    createTestCaseSubDir("one-op", "lib");
    createTestCaseSubDir("workflows");
    createTestCaseSubDir("in");
    addRecordToJobTable(jobId, getTestCaseDir());
    addRecordToActionTable(jobId, actionNum, actionId, getTestCaseDir());
    sleep(3000);
    Runnable recoveryRunnable = new RecoveryRunnable(0, 1, 1);
    recoveryRunnable.run();
    waitFor(10000, new Predicate() {

        public boolean evaluate() throws Exception {
            CoordinatorActionBean bean = ce.getCoordAction(actionId);
            return (bean.getStatus() == CoordinatorAction.Status.RUNNING || bean.getStatus() == CoordinatorAction.Status.SUCCEEDED);
        }
    });
    CoordinatorActionBean action = getCoordinatorAction(actionId);
    if (action.getStatus() == CoordinatorAction.Status.RUNNING || action.getStatus() == CoordinatorAction.Status.SUCCEEDED) {
    } else {
        fail();
    }
}
Also used : RecoveryRunnable(org.apache.oozie.service.RecoveryService.RecoveryRunnable) CoordinatorEngine(org.apache.oozie.CoordinatorEngine) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) RecoveryRunnable(org.apache.oozie.service.RecoveryService.RecoveryRunnable) Date(java.util.Date) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) IOException(java.io.IOException)

Example 8 with CoordinatorActionBean

use of org.apache.oozie.CoordinatorActionBean in project oozie by apache.

the class MockCoordinatorEngineService method createDummyAction.

private static CoordinatorActionBean createDummyAction(int idx, String jobId) {
    CoordinatorActionBean action = new CoordinatorActionBean();
    action.setId(ACTION_ID + idx);
    action.setJobId(jobId);
    action.setActionNumber(idx);
    action.setNominalTime(new Date());
    action.setLastModifiedTime(new Date());
    action.setStatus(CoordinatorAction.Status.SUBMITTED);
    action.setActionXml(COORD_APP);
    action.setCreatedConf(CONFIGURATION);
    return action;
}
Also used : CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) Date(java.util.Date)

Example 9 with CoordinatorActionBean

use of org.apache.oozie.CoordinatorActionBean in project oozie by apache.

the class MockCoordinatorEngineService method createDummyCoordinatorJob.

private static CoordinatorJob createDummyCoordinatorJob(int idx) {
    CoordinatorJobBean coordJob = new CoordinatorJobBean();
    coordJob.setId(JOB_ID + idx);
    coordJob.setAppName("testApp");
    coordJob.setAppPath("testAppPath");
    coordJob.setStatus(CoordinatorJob.Status.RUNNING);
    coordJob.setCreatedTime(new Date());
    coordJob.setLastModifiedTime(new Date());
    coordJob.setUser(USER);
    coordJob.setGroup(GROUP);
    coordJob.setConf(CONFIGURATION);
    coordJob.setLastActionNumber(0);
    coordJob.setFrequency("1");
    coordJob.setExecutionOrder(Execution.FIFO);
    coordJob.setConcurrency(1);
    try {
        coordJob.setEndTime(DateUtils.parseDateOozieTZ("2009-02-03T23:59Z"));
        coordJob.setStartTime(DateUtils.parseDateOozieTZ("2009-02-01T23:59Z"));
    } catch (Exception e) {
        e.printStackTrace();
    }
    List<CoordinatorActionBean> actions = new ArrayList<CoordinatorActionBean>();
    for (int i = 0; i < idx; i++) {
        actions.add(createDummyAction(i, JOB_ID + idx));
    }
    coordJob.setActions(actions);
    return coordJob;
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) ArrayList(java.util.ArrayList) Date(java.util.Date) BaseEngineException(org.apache.oozie.BaseEngineException) IOException(java.io.IOException) XException(org.apache.oozie.XException) CoordinatorEngineException(org.apache.oozie.CoordinatorEngineException) CommandException(org.apache.oozie.command.CommandException)

Example 10 with CoordinatorActionBean

use of org.apache.oozie.CoordinatorActionBean in project oozie by apache.

the class TestStatusTransitService method testBundleStatusTransitServiceRunningWithError.

/**
 * Test : kill one coord job and keep the other running. Check whether the bundle job's status
 * is updated to RUNNINGWITHERROR
 * @throws Exception
 */
public void testBundleStatusTransitServiceRunningWithError() throws Exception {
    Services.get().destroy();
    setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_STATES_WITHOUT_ERROR, "false");
    services = new Services();
    setClassesToBeExcluded(services.getConf(), excludedServices);
    services.init();
    BundleJobBean bundleJob = this.addRecordToBundleJobTable(Job.Status.RUNNING, true);
    final JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    final String bundleId = bundleJob.getId();
    addRecordToBundleActionTable(bundleId, "action1-C", 1, Job.Status.RUNNING);
    addRecordToBundleActionTable(bundleId, "action2-C", 1, Job.Status.RUNNING);
    String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
    Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
    Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
    addRecordToCoordJobTableWithBundle(bundleId, "action1-C", CoordinatorJob.Status.RUNNING, start, end, false, true, 2);
    addRecordToCoordJobTableWithBundle(bundleId, "action2-C", CoordinatorJob.Status.RUNNING, start, end, true, false, 2);
    WorkflowJobBean wfJob1_1 = addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
    WorkflowJobBean wfJob1_2 = addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
    WorkflowJobBean wfJob1_3 = addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
    WorkflowJobBean wfJob1_4 = addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
    final CoordinatorActionBean coordAction1_1 = addRecordToCoordActionTable("action1-C", 1, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", wfJob1_1.getId(), wfJob1_1.getStatusStr(), 0);
    final CoordinatorActionBean coordAction1_2 = addRecordToCoordActionTable("action1-C", 2, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", wfJob1_2.getId(), wfJob1_2.getStatusStr(), 0);
    final CoordinatorActionBean coordAction1_3 = addRecordToCoordActionTable("action2-C", 1, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", wfJob1_3.getId(), wfJob1_3.getStatusStr(), 1);
    final CoordinatorActionBean coordAction1_4 = addRecordToCoordActionTable("action2-C", 2, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", wfJob1_4.getId(), wfJob1_4.getStatusStr(), 1);
    new CoordKillXCommand("action1-C").call();
    waitFor(5 * 1000, new Predicate() {

        public boolean evaluate() throws Exception {
            WorkflowJobBean wfJob = jpaService.execute(new WorkflowJobGetJPAExecutor(coordAction1_1.getExternalId()));
            return wfJob.getStatus().equals(Job.Status.KILLED);
        }
    });
    Runnable runnable = new StatusTransitRunnable();
    runnable.run();
    waitFor(5 * 1000, new Predicate() {

        public boolean evaluate() throws Exception {
            BundleJobBean bundle = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
            return bundle.isPending() == false;
        }
    });
    bundleJob = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
    assertTrue(bundleJob.isPending());
    assertEquals(Job.Status.RUNNINGWITHERROR, bundleJob.getStatus());
    BundleActionBean bundleAction1 = jpaService.execute(new BundleActionGetJPAExecutor(bundleId, "action1-C"));
    assertFalse(bundleAction1.isPending());
    assertEquals(Job.Status.KILLED, bundleAction1.getStatus());
    CoordinatorJobBean coordJob1 = jpaService.execute(new CoordJobGetJPAExecutor("action1-C"));
    assertFalse(coordJob1.isPending());
    assertEquals(Job.Status.KILLED, coordJob1.getStatus());
    BundleActionBean bundleAction2 = jpaService.execute(new BundleActionGetJPAExecutor(bundleId, "action2-C"));
    assertTrue(bundleAction2.isPending());
    assertEquals(Job.Status.RUNNING, bundleAction2.getStatus());
    CoordinatorJobBean coordJob2 = jpaService.execute(new CoordJobGetJPAExecutor("action2-C"));
    assertTrue(coordJob2.isPending());
    assertEquals(Job.Status.RUNNING, coordJob2.getStatus());
}
Also used : WorkflowJobGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor) CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordKillXCommand(org.apache.oozie.command.coord.CoordKillXCommand) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) BundleActionGetJPAExecutor(org.apache.oozie.executor.jpa.BundleActionGetJPAExecutor) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) Date(java.util.Date) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) BundleJobGetJPAExecutor(org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor) BundleJobBean(org.apache.oozie.BundleJobBean) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) BundleActionBean(org.apache.oozie.BundleActionBean)

Aggregations

CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)307 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)148 Date (java.util.Date)117 JPAService (org.apache.oozie.service.JPAService)113 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)102 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)60 CommandException (org.apache.oozie.command.CommandException)55 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)53 IOException (java.io.IOException)49 XConfiguration (org.apache.oozie.util.XConfiguration)44 Configuration (org.apache.hadoop.conf.Configuration)43 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)42 ArrayList (java.util.ArrayList)40 JDOMException (org.jdom.JDOMException)33 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)32 StringReader (java.io.StringReader)30 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)29 StoreException (org.apache.oozie.store.StoreException)24 Test (org.junit.Test)24 WorkflowActionGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor)22