Search in sources :

Example 6 with RecoveryRunnable

use of org.apache.oozie.service.RecoveryService.RecoveryRunnable in project oozie by apache.

the class TestRecoveryService method testCoordCreateNotifyParentFailed.

public void testCoordCreateNotifyParentFailed() throws Exception {
    final BundleActionBean bundleAction;
    final BundleJobBean bundle;
    bundle = addRecordToBundleJobTable(Job.Status.RUNNING, false);
    bundleAction = addRecordToBundleActionTable(bundle.getId(), "coord1", 1, Job.Status.PREP);
    CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.PREP, new Date(), new Date(), false, false, 1);
    coordJob.setBundleId(bundle.getId());
    coordJob.setAppName("coord1");
    CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB, coordJob);
    assertNull(bundleAction.getCoordId());
    sleep(3000);
    Runnable recoveryRunnable = new RecoveryRunnable(0, 1, 1);
    recoveryRunnable.run();
    waitFor(10000, new Predicate() {

        public boolean evaluate() throws Exception {
            BundleActionBean mybundleAction = BundleActionQueryExecutor.getInstance().get(BundleActionQuery.GET_BUNDLE_ACTION, bundle.getId() + "_coord1");
            return mybundleAction.getCoordId() != null;
        }
    });
    BundleActionBean mybundleAction = BundleActionQueryExecutor.getInstance().get(BundleActionQuery.GET_BUNDLE_ACTION, bundle.getId() + "_coord1");
    assertNotNull(mybundleAction.getCoordId());
}
Also used : RecoveryRunnable(org.apache.oozie.service.RecoveryService.RecoveryRunnable) CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) BundleJobBean(org.apache.oozie.BundleJobBean) RecoveryRunnable(org.apache.oozie.service.RecoveryService.RecoveryRunnable) BundleActionBean(org.apache.oozie.BundleActionBean) Date(java.util.Date) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) IOException(java.io.IOException)

Example 7 with RecoveryRunnable

use of org.apache.oozie.service.RecoveryService.RecoveryRunnable 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 8 with RecoveryRunnable

use of org.apache.oozie.service.RecoveryService.RecoveryRunnable in project oozie by apache.

the class TestRecoveryService method testCoordActionRecoveryServiceForKilled.

/**
 * Tests functionality of the Recovery Service Runnable command. </p> Insert a coordinator job with KILLED and
 * action with KILLED and workflow with RUNNING. Then, runs the recovery runnable and ensures the workflow
 *  status changes to KILLED.
 *
 * @throws Exception
 */
public void testCoordActionRecoveryServiceForKilled() throws Exception {
    Date start = DateUtils.parseDateOozieTZ("2009-02-01T01:00Z");
    Date end = DateUtils.parseDateOozieTZ("2009-02-02T23:59Z");
    CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.KILLED, start, end, false, false, 1);
    WorkflowJobBean wfJob = addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
    final String wfJobId = wfJob.getId();
    addRecordToCoordActionTable(coordJob.getId(), 1, CoordinatorAction.Status.KILLED, "coord-action-get.xml", wfJobId, "RUNNING", 1);
    sleep(3000);
    Runnable recoveryRunnable = new RecoveryRunnable(0, 1, 1);
    recoveryRunnable.run();
    final JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    waitFor(10000, new Predicate() {

        public boolean evaluate() throws Exception {
            WorkflowJobGetJPAExecutor wfGetCmd = new WorkflowJobGetJPAExecutor(wfJobId);
            WorkflowJobBean ret = jpaService.execute(wfGetCmd);
            return (ret.getStatus() == WorkflowJob.Status.KILLED);
        }
    });
    WorkflowJobGetJPAExecutor wfGetCmd = new WorkflowJobGetJPAExecutor(wfJobId);
    WorkflowJobBean ret = jpaService.execute(wfGetCmd);
    assertEquals(WorkflowJob.Status.KILLED, ret.getStatus());
}
Also used : RecoveryRunnable(org.apache.oozie.service.RecoveryService.RecoveryRunnable) WorkflowJobGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor) CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) RecoveryRunnable(org.apache.oozie.service.RecoveryService.RecoveryRunnable) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) Date(java.util.Date) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) IOException(java.io.IOException)

Example 9 with RecoveryRunnable

use of org.apache.oozie.service.RecoveryService.RecoveryRunnable in project oozie by apache.

the class TestRecoveryService method testCoordActionRecoveryServiceForWaiting.

/**
 * Tests functionality of the Recovery Service Runnable command. </p> Insert a coordinator job with RUNNING and
 * action with WAITING. Then, runs the recovery runnable and ensures the action status changes to READY.
 *
 * @throws Exception
 */
public void testCoordActionRecoveryServiceForWaiting() throws Exception {
    CoordinatorJobBean job = addRecordToCoordJobTableForWaiting("coord-job-for-action-input-check.xml", CoordinatorJob.Status.RUNNING, false, true);
    CoordinatorJobBean jobWithError = addRecordToCoordJobTableForWaiting("coord-job-for-action-input-check.xml", CoordinatorJob.Status.RUNNINGWITHERROR, false, true);
    CoordinatorJobBean suspendedJob = addRecordToCoordJobTableForWaiting("coord-job-for-action-input-check.xml", CoordinatorJob.Status.SUSPENDED, false, true);
    CoordinatorActionBean action = addRecordToCoordActionTableForWaiting(job.getId(), 1, CoordinatorAction.Status.WAITING, "coord-action-for-action-input-check.xml");
    CoordinatorActionBean actionReady = addRecordToCoordActionTableForWaiting(job.getId(), 2, CoordinatorAction.Status.READY, "coord-action-for-action-input-check.xml");
    CoordinatorActionBean suspendedAction = addRecordToCoordActionTableForWaiting(suspendedJob.getId(), 1, CoordinatorAction.Status.WAITING, "coord-action-for-action-input-check.xml");
    CoordinatorActionBean runningWithErrorAction = addRecordToCoordActionTableForWaiting(jobWithError.getId(), 1, CoordinatorAction.Status.WAITING, "coord-action-for-action-input-check.xml");
    CoordinatorActionBean submittedAction = addRecordToCoordActionTableForWaiting(suspendedJob.getId(), 2, CoordinatorAction.Status.SUBMITTED, "coord-action-for-action-input-check.xml");
    createDir(new File(getTestCaseDir(), "/2009/29/"));
    createDir(new File(getTestCaseDir(), "/2009/22/"));
    createDir(new File(getTestCaseDir(), "/2009/15/"));
    createDir(new File(getTestCaseDir(), "/2009/08/"));
    sleep(3000);
    Runnable recoveryRunnable = new RecoveryRunnable(0, 1, 1);
    recoveryRunnable.run();
    final String actionId = action.getId();
    waitFor(10000, new Predicate() {

        public boolean evaluate() throws Exception {
            CoordinatorActionBean newAction = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, actionId);
            return (newAction.getStatus() != CoordinatorAction.Status.WAITING);
        }
    });
    action = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, actionId);
    // action status should change from waiting
    assertFalse(action.getStatus().equals(CoordinatorAction.Status.WAITING));
    // action status should change from waiting
    assertFalse(CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, runningWithErrorAction.getId()).getStatus().equals(CoordinatorAction.Status.WAITING));
    // action status should change from waiting
    assertFalse(CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, actionReady.getId()).getStatus().equals(CoordinatorAction.Status.READY));
    assertTrue(CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, suspendedAction.getId()).getStatus().equals(CoordinatorAction.Status.WAITING));
    // action status should remain to submitted bcz job is suspended
    assertEquals(CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, submittedAction.getId()).getStatus(), (CoordinatorAction.Status.SUBMITTED));
}
Also used : RecoveryRunnable(org.apache.oozie.service.RecoveryService.RecoveryRunnable) CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) RecoveryRunnable(org.apache.oozie.service.RecoveryService.RecoveryRunnable) File(java.io.File) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) IOException(java.io.IOException)

Example 10 with RecoveryRunnable

use of org.apache.oozie.service.RecoveryService.RecoveryRunnable in project oozie by apache.

the class TestRecoveryService method testCoordActionRecoveryServiceForResume.

/**
 * Tests functionality of the Recovery Service Runnable command. </p> Insert a coordinator job with RUNNING and
 * action with RUNNING and workflow with SUSPENDED. Then, runs the recovery runnable and ensures the workflow status
 *  changes to RUNNING.
 *
 * @throws Exception
 */
public void testCoordActionRecoveryServiceForResume() throws Exception {
    CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, false, false);
    WorkflowJobBean wfJob = addRecordToWfJobTable(WorkflowJob.Status.SUSPENDED, WorkflowInstance.Status.SUSPENDED);
    final String wfJobId = wfJob.getId();
    addRecordToCoordActionTable(coordJob.getId(), 1, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", wfJobId, "SUSPENDED", 1);
    sleep(3000);
    Runnable recoveryRunnable = new RecoveryRunnable(0, 1, 1);
    recoveryRunnable.run();
    final JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    waitFor(10000, new Predicate() {

        public boolean evaluate() throws Exception {
            WorkflowJobGetJPAExecutor wfGetCmd = new WorkflowJobGetJPAExecutor(wfJobId);
            WorkflowJobBean ret = jpaService.execute(wfGetCmd);
            return (ret.getStatus() == WorkflowJob.Status.RUNNING);
        }
    });
    WorkflowJobGetJPAExecutor wfGetCmd = new WorkflowJobGetJPAExecutor(wfJobId);
    WorkflowJobBean ret = jpaService.execute(wfGetCmd);
    assertEquals(WorkflowJob.Status.RUNNING, ret.getStatus());
}
Also used : RecoveryRunnable(org.apache.oozie.service.RecoveryService.RecoveryRunnable) WorkflowJobGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor) CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) RecoveryRunnable(org.apache.oozie.service.RecoveryService.RecoveryRunnable) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) IOException(java.io.IOException)

Aggregations

RecoveryRunnable (org.apache.oozie.service.RecoveryService.RecoveryRunnable)12 IOException (java.io.IOException)10 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)10 Date (java.util.Date)5 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)5 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)4 BundleActionBean (org.apache.oozie.BundleActionBean)3 BundleJobBean (org.apache.oozie.BundleJobBean)3 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)3 File (java.io.File)2 Configuration (org.apache.hadoop.conf.Configuration)2 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)2 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)2 BundleActionGetJPAExecutor (org.apache.oozie.executor.jpa.BundleActionGetJPAExecutor)2 HCatURI (org.apache.oozie.util.HCatURI)2 XConfiguration (org.apache.oozie.util.XConfiguration)2 FileWriter (java.io.FileWriter)1 OutputStreamWriter (java.io.OutputStreamWriter)1 PrintWriter (java.io.PrintWriter)1 Reader (java.io.Reader)1