Search in sources :

Example 26 with CoordinatorJob

use of org.apache.oozie.client.CoordinatorJob in project oozie by apache.

the class TestCoordMaterializeTransitionXCommand method checkCoordActions.

private void checkCoordActions(String jobId, int number, CoordinatorJob.Status status) {
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        Integer actionsSize = jpaService.execute(new CoordJobGetActionsJPAExecutor(jobId));
        if (actionsSize != number) {
            fail("Should have " + number + " actions created for job " + jobId + ", but has " + actionsSize + " actions.");
        }
        if (status != null) {
            CoordinatorJob job = jpaService.execute(new CoordJobGetJPAExecutor(jobId));
            if (job.getStatus() != status) {
                fail("Job status " + job.getStatus() + " should be " + status);
            }
        }
    } catch (JPAExecutorException se) {
        se.printStackTrace();
        fail("Job ID " + jobId + " was not stored properly in db");
    }
}
Also used : CoordinatorJob(org.apache.oozie.client.CoordinatorJob) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordJobGetActionsJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetActionsJPAExecutor) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService)

Example 27 with CoordinatorJob

use of org.apache.oozie.client.CoordinatorJob 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 28 with CoordinatorJob

use of org.apache.oozie.client.CoordinatorJob in project oozie by apache.

the class TestCoordinatorInputLogic method startCoordAction.

private void startCoordAction(final String jobId, final CoordinatorAction.Status coordActionStatus) throws CommandException, JPAExecutorException {
    new CoordMaterializeTransitionXCommand(jobId, 3600).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(actionBean.getStatus().equals(coordActionStatus));
    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) 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 29 with CoordinatorJob

use of org.apache.oozie.client.CoordinatorJob in project oozie by apache.

the class TestRecoveryService method testBundleRecoveryCoordExists.

/**
 * If the bundle action is in PREP state and coord is already created, recovery should not submit new coord
 * @throws Exception
 */
public void testBundleRecoveryCoordExists() throws Exception {
    final BundleJobBean bundle;
    final CoordinatorJob coord;
    bundle = addRecordToBundleJobTable(Job.Status.RUNNING, false);
    coord = addRecordToCoordJobTable(Job.Status.PREP, false, false);
    addRecordToBundleActionTable(bundle.getId(), coord.getId(), "coord1", 1, Job.Status.PREP);
    final JPAService jpaService = Services.get().get(JPAService.class);
    sleep(3000);
    Runnable recoveryRunnable = new RecoveryRunnable(0, 1, 1);
    recoveryRunnable.run();
    waitFor(3000, new Predicate() {

        public boolean evaluate() throws Exception {
            BundleActionBean mybundleAction = jpaService.execute(new BundleActionGetJPAExecutor(bundle.getId(), "coord1"));
            return !mybundleAction.getCoordId().equals(coord.getId());
        }
    });
    BundleActionBean mybundleAction = jpaService.execute(new BundleActionGetJPAExecutor(bundle.getId(), "coord1"));
    assertEquals(coord.getId(), mybundleAction.getCoordId());
}
Also used : RecoveryRunnable(org.apache.oozie.service.RecoveryService.RecoveryRunnable) CoordinatorJob(org.apache.oozie.client.CoordinatorJob) BundleJobBean(org.apache.oozie.BundleJobBean) BundleActionGetJPAExecutor(org.apache.oozie.executor.jpa.BundleActionGetJPAExecutor) RecoveryRunnable(org.apache.oozie.service.RecoveryService.RecoveryRunnable) BundleActionBean(org.apache.oozie.BundleActionBean) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) IOException(java.io.IOException)

Example 30 with CoordinatorJob

use of org.apache.oozie.client.CoordinatorJob in project oozie by apache.

the class MockCoordinatorEngineService method reset.

public static void reset() {
    did = null;
    offset = null;
    length = null;
    order = null;
    filter = null;
    coordJobs = new ArrayList<CoordinatorJob>();
    coordWfActions = new ArrayList<CoordinatorWfActionBean>();
    startedCoordJobs = new ArrayList<Boolean>();
    for (int i = 0; i < INIT_COORD_COUNT; i++) {
        coordJobs.add(createDummyCoordinatorJob(i));
        startedCoordJobs.add(false);
    }
    for (int i = 0; i < INIT_WF_ACTION_COUNT; i++) {
        coordWfActions.add(createDummyCoordWfAction("actionTest", i + 1));
    }
    String nullReason = CoordinatorWfAction.NullReason.ACTION_NULL.getNullReason("actionTest2", "wf1");
    coordWfActions.add(new CoordinatorWfActionBean(INIT_WF_ACTION_COUNT + 1, null, nullReason));
}
Also used : CoordinatorJob(org.apache.oozie.client.CoordinatorJob) CoordinatorWfActionBean(org.apache.oozie.CoordinatorWfActionBean)

Aggregations

CoordinatorJob (org.apache.oozie.client.CoordinatorJob)30 CoordinatorAction (org.apache.oozie.client.CoordinatorAction)9 IOException (java.io.IOException)8 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)8 BundleJob (org.apache.oozie.client.BundleJob)5 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)4 VisibleForTesting (com.google.common.annotations.VisibleForTesting)3 OozieClientException (org.apache.oozie.client.OozieClientException)3 StoreException (org.apache.oozie.store.StoreException)3 JSONObject (org.json.simple.JSONObject)3 File (java.io.File)2 List (java.util.List)2 Properties (java.util.Properties)2 CoordinatorEngine (org.apache.oozie.CoordinatorEngine)2 BulkResponse (org.apache.oozie.client.BulkResponse)2 OozieClient (org.apache.oozie.client.OozieClient)2 CommandException (org.apache.oozie.command.CommandException)2 CoordActionInputCheckXCommand (org.apache.oozie.command.coord.CoordActionInputCheckXCommand)2 CoordActionStartXCommand (org.apache.oozie.command.coord.CoordActionStartXCommand)2 CoordMaterializeTransitionXCommand (org.apache.oozie.command.coord.CoordMaterializeTransitionXCommand)2