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());
}
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());
}
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());
}
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));
}
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());
}
Aggregations