use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.
the class TestPurgeXCommand method testPurgeLongRunningCoordWithWFChild.
/**
* Test : The workflow should get purged, but the coordinator parent shouldn't get purged -->
* the workflow and corresponding coord actions will get purged after we turn the purge.old.coord.action on
* Coordinator itself will not be purged
*
* @throws Exception
*/
public void testPurgeLongRunningCoordWithWFChild() throws Exception {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, false, false);
WorkflowJobBean wfJob = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
WorkflowActionBean wfAction = addRecordToWfActionTable(wfJob.getId(), "1", WorkflowAction.Status.OK);
CoordinatorActionBean coordAction = addRecordToCoordActionTable(coordJob.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJob.getId(), "SUCCEEDED", 0);
WorkflowJobGetJPAExecutor wfJobGetCmd = new WorkflowJobGetJPAExecutor(wfJob.getId());
WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(wfAction.getId());
CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(coordJob.getId());
CoordActionGetJPAExecutor coordActionGetCmd = new CoordActionGetJPAExecutor(coordAction.getId());
wfJob = jpaService.execute(wfJobGetCmd);
wfAction = jpaService.execute(wfActionGetCmd);
coordJob = jpaService.execute(coordJobGetCmd);
coordAction = jpaService.execute(coordActionGetCmd);
assertEquals(WorkflowJob.Status.SUCCEEDED, wfJob.getStatus());
assertEquals(WorkflowAction.Status.OK, wfAction.getStatus());
assertEquals(CoordinatorJob.Status.RUNNING, coordJob.getStatus());
assertEquals(CoordinatorAction.Status.SUCCEEDED, coordAction.getStatus());
new PurgeXCommand(7, getNumDaysToNotBePurged(coordJob.getLastModifiedTime()), 1, 10, true).call();
try {
jpaService.execute(coordJobGetCmd);
} catch (JPAExecutorException je) {
fail("Coordinator Job should not have been purged");
}
try {
jpaService.execute(coordActionGetCmd);
fail("Coordinator Action should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
try {
jpaService.execute(wfJobGetCmd);
fail("Workflow Job should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0604, je.getErrorCode());
}
try {
jpaService.execute(wfActionGetCmd);
fail("Workflow Action should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
}
use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.
the class TestSLAAlertXCommand method testBundleSLAAlertCommands.
public void testBundleSLAAlertCommands() throws Exception {
setupSLAJobs();
String jobIdsStr = bundle.getId();
String actions = "1,2";
String coords = null;
bundleEngine.disableSLAAlert(jobIdsStr, actions, null, coords);
checkSLAStatus(coord1.getId() + "@1", true);
checkSLAStatus(coord1.getId() + "@2", true);
checkSLAStatus(coord1.getId() + "@3", false);
checkSLAStatus(coord1.getId() + "@5", false);
checkSLAStatus(coord1.getId() + "@4", false);
checkSLAStatus(coord2.getId() + "@1", true);
checkSLAStatus(coord2.getId() + "@1", true);
bundleEngine.enableSLAAlert(jobIdsStr, null, null, null);
checkSLAStatus(coord1.getId() + "@1", false);
checkSLAStatus(coord1.getId() + "@2", false);
checkSLAStatus(coord1.getId() + "@3", false);
checkSLAStatus(coord1.getId() + "@5", false);
checkSLAStatus(coord1.getId() + "@4", false);
checkSLAStatus(coord2.getId() + "@1", false);
checkSLAStatus(coord2.getId() + "@2", false);
CoordinatorJobBean job1 = CoordJobQueryExecutor.getInstance().get(CoordJobQueryExecutor.CoordJobQuery.GET_COORD_JOB, coord1.getId());
XConfiguration xConf = new XConfiguration(new StringReader(job1.getConf()));
assertEquals(xConf.get(OozieClient.SLA_DISABLE_ALERT), null);
CoordinatorJobBean job2 = CoordJobQueryExecutor.getInstance().get(CoordJobQueryExecutor.CoordJobQuery.GET_COORD_JOB, coord2.getId());
xConf = new XConfiguration(new StringReader(job2.getConf()));
assertEquals(xConf.get(OozieClient.SLA_DISABLE_ALERT), null);
bundleEngine.disableSLAAlert(jobIdsStr, null, null, "coord1");
checkSLAStatus(coord1.getId() + "@1", true);
checkSLAStatus(coord1.getId() + "@2", true);
checkSLAStatus(coord1.getId() + "@3", true);
checkSLAStatus(coord1.getId() + "@4", true);
checkSLAStatus(coord1.getId() + "@5", true);
checkSLAStatus(coord2.getId() + "@1", false);
checkSLAStatus(coord2.getId() + "@2", false);
job1 = CoordJobQueryExecutor.getInstance().get(CoordJobQueryExecutor.CoordJobQuery.GET_COORD_JOB, coord1.getId());
xConf = new XConfiguration(new StringReader(job1.getConf()));
assertEquals(xConf.get(OozieClient.SLA_DISABLE_ALERT), SLAOperations.ALL_VALUE);
bundleEngine.disableSLAAlert(jobIdsStr, null, null, "coord2");
// with multiple coordID.
String dates = "2014-01-01T00:00Z::2014-01-03T00:00Z";
bundleEngine.enableSLAAlert(jobIdsStr, null, dates, "coord1," + coord2.getId());
checkSLAStatus(coord1.getId() + "@1", false);
checkSLAStatus(coord1.getId() + "@2", false);
checkSLAStatus(coord1.getId() + "@3", false);
checkSLAStatus(coord1.getId() + "@4", true);
checkSLAStatus(coord1.getId() + "@5", true);
checkSLAStatus(coord2.getId() + "@1", false);
checkSLAStatus(coord2.getId() + "@2", false);
checkSLAStatus(coord2.getId() + "@3", false);
checkSLAStatus(coord2.getId() + "@4", true);
try {
bundleEngine.disableSLAAlert(jobIdsStr, null, null, "dummy");
fail("Should throw Exception");
} catch (BaseEngineException e) {
assertEquals(e.getErrorCode(), ErrorCode.E1026);
}
}
use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.
the class TestAbandonedCoordChecker method testKill.
public void testKill() throws Exception {
Date start = DateUtils.addMonths(new Date(), -1);
// 4 hrs
Date end = DateUtils.addHours(new Date(), 4);
Date createdTime = start;
CoordinatorJobBean job1 = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, createdTime, true, false, 6);
addRecordToCoordActionTable(job1.getId(), 6, CoordinatorAction.Status.FAILED);
CoordinatorJobBean job2 = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, createdTime, true, false, 4);
addRecordToCoordActionTable(job2.getId(), 4, CoordinatorAction.Status.FAILED);
new AbandonedCoordCheckerRunnable(5, true).run();
assertEquals(CoordJobQueryExecutor.getInstance().get(CoordJobQuery.GET_COORD_JOB, job1.getId()).getStatus(), CoordinatorJob.Status.KILLED);
assertEquals(CoordJobQueryExecutor.getInstance().get(CoordJobQuery.GET_COORD_JOB, job2.getId()).getStatus(), CoordinatorJob.Status.RUNNING);
}
use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.
the class TestBulkCoordXCommand method testBulkCoordResumeNoOp.
public void testBulkCoordResumeNoOp() throws Exception {
String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
CoordinatorJobBean job1 = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, false, false, 0);
CoordinatorActionBean action1 = addRecordToCoordActionTable(job1.getId(), 1, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
Map<String, List<String>> map = new HashMap<String, List<String>>();
List<String> names = new ArrayList<String>();
names.add("COORD-TEST");
map.put("name", names);
new BulkCoordXCommand(map, 1, 50, OperationType.Resume).call();
List<String> jobIds = new ArrayList<String>();
jobIds.add(job1.getId());
List<String> actionIds = new ArrayList<String>();
actionIds.add(action1.getId());
verifyJobsStatus(jobIds, CoordinatorJob.Status.RUNNING);
verifyActionsStatus(actionIds, CoordinatorAction.Status.RUNNING);
}
use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.
the class TestBulkCoordXCommand method testBulkCoordResumeNegative.
public void testBulkCoordResumeNegative() throws Exception {
String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
CoordinatorJobBean job1 = addRecordToCoordJobTable(CoordinatorJob.Status.SUSPENDED, start, end, false, false, 0);
CoordinatorActionBean action1 = addRecordToCoordActionTable(job1.getId(), 1, CoordinatorAction.Status.SUSPENDED, "coord-action-get.xml", 0);
Map<String, List<String>> map = new HashMap<String, List<String>>();
List<String> names = new ArrayList<String>();
names.add("COORD");
map.put("name", names);
new BulkCoordXCommand(map, 1, 50, OperationType.Resume).call();
List<String> jobIds = new ArrayList<String>();
jobIds.add(job1.getId());
List<String> actionIds = new ArrayList<String>();
actionIds.add(action1.getId());
verifyJobsStatus(jobIds, CoordinatorJob.Status.SUSPENDED);
verifyActionsStatus(actionIds, CoordinatorAction.Status.SUSPENDED);
}
Aggregations