Search in sources :

Example 16 with CoordinatorActionBean

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

the class TestFutureActionsTimeOut method _testTimeout.

/**
 * The catch-up mode time up has been setup in {@link CoordActionMaterializeXCommand}
 * @param jobId job id
 * @param createDate create date
 * @throws Exception thrown if failed
 */
private void _testTimeout(final String jobId, Date createDate) throws Exception {
    final CoordinatorEngine ce = new CoordinatorEngine(getTestUser());
    waitFor(12000, new Predicate() {

        public boolean evaluate() throws Exception {
            CoordinatorJob job = ce.getCoordJob(jobId);
            return !(job.getStatus().equals(CoordinatorJob.Status.PREP));
        }
    });
    CoordinatorJob job = ce.getCoordJob(jobId);
    assertTrue(!(job.getStatus().equals(CoordinatorJob.Status.PREP)));
    waitFor(12000, new Predicate() {

        public boolean evaluate() throws Exception {
            CoordinatorJob job = ce.getCoordJob(jobId);
            List<CoordinatorAction> actions = job.getActions();
            return actions.size() > 0;
        }
    });
    job = ce.getCoordJob(jobId);
    List<CoordinatorAction> actions = job.getActions();
    assertTrue(actions.size() > 0);
    for (CoordinatorAction action : actions) {
        CoordinatorActionBean jsonAction = (CoordinatorActionBean) action;
        if (jsonAction.getNominalTime().before(createDate)) {
            assertEquals(10, jsonAction.getTimeOut());
        } else {
            assertEquals(10, jsonAction.getTimeOut());
        }
    }
}
Also used : CoordinatorJob(org.apache.oozie.client.CoordinatorJob) CoordinatorEngine(org.apache.oozie.CoordinatorEngine) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordinatorAction(org.apache.oozie.client.CoordinatorAction) List(java.util.List) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) IOException(java.io.IOException) StoreException(org.apache.oozie.store.StoreException)

Example 17 with CoordinatorActionBean

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

the class TestPastActionsTimeOut method _testTimeout.

/**
 * The catch-up mode time up has been setup in {@link CoordActionMaterializeXCommand}
 * @param jobId job id
 * @throws Exception thrown if failed
 */
private void _testTimeout(final String jobId) throws Exception {
    final CoordinatorEngine ce = new CoordinatorEngine(getTestUser());
    waitFor(6000, new Predicate() {

        public boolean evaluate() throws Exception {
            CoordinatorJob job = ce.getCoordJob(jobId);
            return !(job.getStatus().equals(CoordinatorJob.Status.PREP));
        }
    });
    CoordinatorJob job = ce.getCoordJob(jobId);
    assertTrue(!(job.getStatus().equals(CoordinatorJob.Status.PREP)));
    waitFor(6000, new Predicate() {

        public boolean evaluate() throws Exception {
            CoordinatorJob job = ce.getCoordJob(jobId);
            List<CoordinatorAction> actions = job.getActions();
            return actions.size() > 0;
        }
    });
    job = ce.getCoordJob(jobId);
    List<CoordinatorAction> actions = job.getActions();
    assertTrue(actions.size() > 0);
    for (CoordinatorAction action : actions) {
        CoordinatorActionBean json = (CoordinatorActionBean) action;
        assertEquals(10, json.getTimeOut());
    }
}
Also used : CoordinatorJob(org.apache.oozie.client.CoordinatorJob) CoordinatorEngine(org.apache.oozie.CoordinatorEngine) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordinatorAction(org.apache.oozie.client.CoordinatorAction) List(java.util.List) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) IOException(java.io.IOException) StoreException(org.apache.oozie.store.StoreException)

Example 18 with CoordinatorActionBean

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

the class TestCoordRerunXCommand method testCoordRerunDate1.

/**
 * Test : rerun <jobId> -date 2009-12-15T17:00Z -nocleanup
 *
 * @throws Exception
 */
public void testCoordRerunDate1() throws Exception {
    final String jobId = "0000000-" + new Date().getTime() + "-testCoordRerun-C";
    final int actionNum = 1;
    final String actionId = jobId + "@" + actionNum;
    try {
        addRecordToJobTable(jobId, CoordinatorJob.Status.SUCCEEDED);
        addRecordToActionTable(jobId, actionNum, actionId, CoordinatorAction.Status.SUCCEEDED, "coord-rerun-action1.xml");
    } catch (Exception e) {
        e.printStackTrace();
        fail("Could not update db.");
    }
    CoordinatorActionBean action1 = getCoordinatorAction(actionId);
    assertEquals(action1.getStatus(), CoordinatorAction.Status.SUCCEEDED);
    final OozieClient coordClient = LocalOozie.getCoordClient();
    coordClient.reRunCoord(jobId, RestConstants.JOB_COORD_SCOPE_DATE, "2009-12-15T01:00Z", false, true);
    CoordinatorActionBean action2 = getCoordinatorAction(actionId);
    assertNotSame(action2.getStatus(), CoordinatorAction.Status.SUCCEEDED);
}
Also used : CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) Date(java.util.Date) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) JDOMException(org.jdom.JDOMException) CommandException(org.apache.oozie.command.CommandException) StoreException(org.apache.oozie.store.StoreException) IOException(java.io.IOException)

Example 19 with CoordinatorActionBean

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

the class TestCoordRerunXCommand method testCoordRerunCleanupNoOutputEvents.

/**
 * Test : rerun <jobId> -action 1 with no output-event
 *
 * @throws Exception
 */
public void testCoordRerunCleanupNoOutputEvents() throws Exception {
    final String jobId = "0000000-" + new Date().getTime() + "-testCoordRerun-C";
    final int actionNum = 1;
    final String actionId = jobId + "@" + actionNum;
    try {
        addRecordToJobTable(jobId, CoordinatorJob.Status.SUCCEEDED);
        addRecordToActionTable(jobId, actionNum, actionId, CoordinatorAction.Status.SUCCEEDED, "coord-rerun-action3.xml");
    } catch (Exception e) {
        e.printStackTrace();
        fail("Could not update db.");
    }
    final OozieClient coordClient = LocalOozie.getCoordClient();
    coordClient.reRunCoord(jobId, RestConstants.JOB_COORD_SCOPE_ACTION, Integer.toString(actionNum), false, false);
    CoordinatorActionBean action2 = getCoordinatorAction(actionId);
    assertNotSame(action2.getStatus(), CoordinatorAction.Status.SUCCEEDED);
    waitFor(120 * 1000, new Predicate() {

        @Override
        public boolean evaluate() throws Exception {
            CoordinatorAction bean = coordClient.getCoordActionInfo(actionId);
            return (bean.getStatus() == CoordinatorAction.Status.WAITING || bean.getStatus() == CoordinatorAction.Status.READY);
        }
    });
    CoordinatorAction bean = coordClient.getCoordActionInfo(actionId);
    assertTrue(bean.getStatus() == CoordinatorAction.Status.WAITING || bean.getStatus() == CoordinatorAction.Status.READY);
}
Also used : CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) Date(java.util.Date) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) JDOMException(org.jdom.JDOMException) CommandException(org.apache.oozie.command.CommandException) StoreException(org.apache.oozie.store.StoreException) IOException(java.io.IOException)

Example 20 with CoordinatorActionBean

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

the class TestCoordRerunXCommand method testCoordRerunCleanupOption.

/**
 * Test : nocleanup option in dataset
 *
 * @throws Exception
 */
public void testCoordRerunCleanupOption() throws Exception {
    final String jobId = "0000000-" + new Date().getTime() + "-testCoordRerun-C";
    final int actionNum = 1;
    final String actionId = jobId + "@" + actionNum;
    try {
        addRecordToJobTable(jobId, CoordinatorJob.Status.SUCCEEDED);
        addRecordToActionTable(jobId, actionNum, actionId, CoordinatorAction.Status.SUCCEEDED, "coord-rerun-action4.xml");
    } catch (Exception e) {
        e.printStackTrace();
        fail("Could not update db.");
    }
    Path appPath = new Path(getFsTestCaseDir(), "coord");
    String outputDir = appPath.toString() + "/coord-input/2009/12/14/11/00";
    Path success = new Path(outputDir, "_SUCCESS");
    FileSystem fs = getFileSystem();
    fs.mkdirs(new Path(outputDir));
    fs.create(success, true);
    // before cleanup
    assertTrue(fs.exists(success));
    long beforeModifiedTime = fs.getFileStatus(success).getModificationTime();
    final OozieClient coordClient = LocalOozie.getCoordClient();
    coordClient.reRunCoord(jobId, RestConstants.JOB_COORD_SCOPE_ACTION, Integer.toString(actionNum), false, false);
    CoordinatorActionBean action2 = getCoordinatorAction(actionId);
    assertNotSame(action2.getStatus(), CoordinatorAction.Status.SUCCEEDED);
    waitFor(120 * 1000, new Predicate() {

        @Override
        public boolean evaluate() throws Exception {
            CoordinatorAction bean = coordClient.getCoordActionInfo(actionId);
            return (bean.getStatus() == CoordinatorAction.Status.WAITING || bean.getStatus() == CoordinatorAction.Status.READY);
        }
    });
    // after cleanup
    assertTrue(fs.exists(success));
    long afterModifiedTime = fs.getFileStatus(success).getModificationTime();
    assertEquals(beforeModifiedTime, afterModifiedTime);
}
Also used : Path(org.apache.hadoop.fs.Path) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) FileSystem(org.apache.hadoop.fs.FileSystem) Date(java.util.Date) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) JDOMException(org.jdom.JDOMException) CommandException(org.apache.oozie.command.CommandException) StoreException(org.apache.oozie.store.StoreException) IOException(java.io.IOException)

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