use of org.apache.oozie.executor.jpa.JPAExecutorException in project oozie by apache.
the class TestPurgeXCommand method testPurgeWFWithSubWF3MoreThanLimit.
/**
* Test : The subworkflow should get purged, and the workflow parent should get purged --> both will get purged
* There are more subworkflow children than the limit
*
* @throws Exception
*/
public void testPurgeWFWithSubWF3MoreThanLimit() throws Exception {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
WorkflowJobBean wfJob = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
WorkflowActionBean wfAction1 = addRecordToWfActionTable(wfJob.getId(), "1", WorkflowAction.Status.OK);
WorkflowActionBean wfAction2 = addRecordToWfActionTable(wfJob.getId(), "2", WorkflowAction.Status.OK);
WorkflowActionBean wfAction3 = addRecordToWfActionTable(wfJob.getId(), "3", WorkflowAction.Status.OK);
WorkflowActionBean wfAction4 = addRecordToWfActionTable(wfJob.getId(), "4", WorkflowAction.Status.OK);
WorkflowActionBean wfAction5 = addRecordToWfActionTable(wfJob.getId(), "5", WorkflowAction.Status.OK);
WorkflowJobBean subwfJob1 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED, wfJob.getId());
WorkflowJobBean subwfJob2 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED, wfJob.getId());
WorkflowJobBean subwfJob3 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED, wfJob.getId());
WorkflowJobBean subwfJob4 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED, wfJob.getId());
WorkflowJobBean subwfJob5 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED, wfJob.getId());
WorkflowActionBean subwfAction1 = addRecordToWfActionTable(subwfJob1.getId(), "1", WorkflowAction.Status.OK);
WorkflowActionBean subwfAction2 = addRecordToWfActionTable(subwfJob2.getId(), "1", WorkflowAction.Status.OK);
WorkflowActionBean subwfAction3 = addRecordToWfActionTable(subwfJob3.getId(), "1", WorkflowAction.Status.OK);
WorkflowActionBean subwfAction4 = addRecordToWfActionTable(subwfJob4.getId(), "1", WorkflowAction.Status.OK);
WorkflowActionBean subwfAction5 = addRecordToWfActionTable(subwfJob5.getId(), "1", WorkflowAction.Status.OK);
WorkflowJobGetJPAExecutor wfJobGetCmd = new WorkflowJobGetJPAExecutor(wfJob.getId());
WorkflowActionGetJPAExecutor wfAction1GetCmd = new WorkflowActionGetJPAExecutor(wfAction1.getId());
WorkflowActionGetJPAExecutor wfAction2GetCmd = new WorkflowActionGetJPAExecutor(wfAction2.getId());
WorkflowActionGetJPAExecutor wfAction3GetCmd = new WorkflowActionGetJPAExecutor(wfAction3.getId());
WorkflowActionGetJPAExecutor wfAction4GetCmd = new WorkflowActionGetJPAExecutor(wfAction4.getId());
WorkflowActionGetJPAExecutor wfAction5GetCmd = new WorkflowActionGetJPAExecutor(wfAction5.getId());
WorkflowJobGetJPAExecutor subwfJob1GetCmd = new WorkflowJobGetJPAExecutor(subwfJob1.getId());
WorkflowJobGetJPAExecutor subwfJob2GetCmd = new WorkflowJobGetJPAExecutor(subwfJob2.getId());
WorkflowJobGetJPAExecutor subwfJob3GetCmd = new WorkflowJobGetJPAExecutor(subwfJob3.getId());
WorkflowJobGetJPAExecutor subwfJob4GetCmd = new WorkflowJobGetJPAExecutor(subwfJob4.getId());
WorkflowJobGetJPAExecutor subwfJob5GetCmd = new WorkflowJobGetJPAExecutor(subwfJob5.getId());
WorkflowActionGetJPAExecutor subwfAction1GetCmd = new WorkflowActionGetJPAExecutor(subwfAction1.getId());
WorkflowActionGetJPAExecutor subwfAction2GetCmd = new WorkflowActionGetJPAExecutor(subwfAction2.getId());
WorkflowActionGetJPAExecutor subwfAction3GetCmd = new WorkflowActionGetJPAExecutor(subwfAction3.getId());
WorkflowActionGetJPAExecutor subwfAction4GetCmd = new WorkflowActionGetJPAExecutor(subwfAction4.getId());
WorkflowActionGetJPAExecutor subwfAction5GetCmd = new WorkflowActionGetJPAExecutor(subwfAction5.getId());
wfJob = jpaService.execute(wfJobGetCmd);
wfAction1 = jpaService.execute(wfAction1GetCmd);
wfAction2 = jpaService.execute(wfAction2GetCmd);
wfAction3 = jpaService.execute(wfAction3GetCmd);
wfAction4 = jpaService.execute(wfAction4GetCmd);
wfAction5 = jpaService.execute(wfAction5GetCmd);
subwfJob1 = jpaService.execute(subwfJob1GetCmd);
subwfJob2 = jpaService.execute(subwfJob2GetCmd);
subwfJob3 = jpaService.execute(subwfJob3GetCmd);
subwfJob4 = jpaService.execute(subwfJob4GetCmd);
subwfJob5 = jpaService.execute(subwfJob5GetCmd);
subwfAction1 = jpaService.execute(subwfAction1GetCmd);
subwfAction2 = jpaService.execute(subwfAction2GetCmd);
subwfAction3 = jpaService.execute(subwfAction3GetCmd);
subwfAction4 = jpaService.execute(subwfAction4GetCmd);
subwfAction5 = jpaService.execute(subwfAction5GetCmd);
assertEquals(WorkflowJob.Status.SUCCEEDED, wfJob.getStatus());
assertEquals(WorkflowAction.Status.OK, wfAction1.getStatus());
assertEquals(WorkflowAction.Status.OK, wfAction2.getStatus());
assertEquals(WorkflowAction.Status.OK, wfAction3.getStatus());
assertEquals(WorkflowAction.Status.OK, wfAction4.getStatus());
assertEquals(WorkflowAction.Status.OK, wfAction5.getStatus());
assertEquals(WorkflowJob.Status.SUCCEEDED, subwfJob1.getStatus());
assertEquals(WorkflowJob.Status.SUCCEEDED, subwfJob2.getStatus());
assertEquals(WorkflowJob.Status.SUCCEEDED, subwfJob3.getStatus());
assertEquals(WorkflowJob.Status.SUCCEEDED, subwfJob4.getStatus());
assertEquals(WorkflowJob.Status.SUCCEEDED, subwfJob5.getStatus());
assertEquals(WorkflowAction.Status.OK, subwfAction1.getStatus());
assertEquals(WorkflowAction.Status.OK, subwfAction2.getStatus());
assertEquals(WorkflowAction.Status.OK, subwfAction3.getStatus());
assertEquals(WorkflowAction.Status.OK, subwfAction4.getStatus());
assertEquals(WorkflowAction.Status.OK, subwfAction5.getStatus());
new PurgeXCommand(7, 1, 1, 3).call();
try {
jpaService.execute(wfJobGetCmd);
fail("Workflow Job should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0604, je.getErrorCode());
}
try {
jpaService.execute(wfAction1GetCmd);
fail("Workflow Action 1 should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
try {
jpaService.execute(wfAction2GetCmd);
fail("Workflow Action 2 should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
try {
jpaService.execute(wfAction3GetCmd);
fail("Workflow Action 3 should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
try {
jpaService.execute(wfAction4GetCmd);
fail("Workflow Action 4 should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
try {
jpaService.execute(wfAction5GetCmd);
fail("Workflow Action 5 should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
try {
jpaService.execute(subwfJob1GetCmd);
fail("SubWorkflow Job 1 should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0604, je.getErrorCode());
}
try {
jpaService.execute(subwfJob2GetCmd);
fail("SubWorkflow Job 2 should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0604, je.getErrorCode());
}
try {
jpaService.execute(subwfJob3GetCmd);
fail("SubWorkflow Job 3 should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0604, je.getErrorCode());
}
try {
jpaService.execute(subwfJob4GetCmd);
fail("SubWorkflow Job 4 should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0604, je.getErrorCode());
}
try {
jpaService.execute(subwfJob5GetCmd);
fail("SubWorkflow Job 5 should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0604, je.getErrorCode());
}
try {
jpaService.execute(subwfAction1GetCmd);
fail("SubWorkflow Action 1 should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
try {
jpaService.execute(subwfAction2GetCmd);
fail("SubWorkflow Action 2 should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
try {
jpaService.execute(subwfAction3GetCmd);
fail("SubWorkflow Action 3 should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
try {
jpaService.execute(subwfAction4GetCmd);
fail("SubWorkflow Action 4 should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
try {
jpaService.execute(subwfAction5GetCmd);
fail("SubWorkflow Action 5 should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
}
use of org.apache.oozie.executor.jpa.JPAExecutorException 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.executor.jpa.JPAExecutorException in project oozie by apache.
the class TestCoordActionInputCheckXCommand method addRecordToCoordJobTable.
private CoordinatorJobBean addRecordToCoordJobTable(String jobId, Date start, Date end, String dataInType) throws CommandException {
CoordinatorJobBean coordJob = new CoordinatorJobBean();
coordJob.setId(jobId);
coordJob.setAppName("testApp");
coordJob.setAppPath("testAppPath");
coordJob.setStatus(CoordinatorJob.Status.RUNNING);
coordJob.setCreatedTime(new Date());
coordJob.setLastModifiedTime(new Date());
coordJob.setUser("testUser");
coordJob.setGroup("testGroup");
coordJob.setTimeZone("UTC");
coordJob.setTimeUnit(Timeunit.DAY);
coordJob.setMatThrottling(2);
try {
coordJob.setStartTime(start);
coordJob.setEndTime(end);
} catch (Exception e) {
e.printStackTrace();
fail("Could not set Date/time");
}
String testDir = getTestCaseDir();
XConfiguration jobConf = new XConfiguration();
jobConf.set(OozieClient.USER_NAME, getTestUser());
String confStr = jobConf.toXmlString(false);
coordJob.setConf(confStr);
String appXml = "<coordinator-app xmlns='uri:oozie:coordinator:0.2' name='NAME' frequency=\"1\" start='2009-02-01T01:00" + TZ + "' end='2009-02-03T23:59" + TZ + "' timezone='UTC' freq_timeunit='DAY' end_of_duration='NONE'>";
appXml += "<controls>";
appXml += "<timeout>10</timeout>";
appXml += "<concurrency>2</concurrency>";
appXml += "<execution>LIFO</execution>";
appXml += "</controls>";
appXml += "<input-events>";
appXml += "<data-in name='A' dataset='a'>";
appXml += "<dataset name='a' frequency='7' initial-instance='2009-01-01T01:00" + TZ + "' timezone='UTC'" + " freq_timeunit='DAY' end_of_duration='NONE'>";
appXml += "<uri-template>" + getTestCaseFileUri("${YEAR}/${MONTH}/${DAY}") + "</uri-template>";
appXml += "</dataset>";
if (dataInType.equals("future")) {
appXml += "<start-instance>${coord:" + dataInType + "(0,5)}</start-instance>";
appXml += "<end-instance>${coord:" + dataInType + "(3,5)}</end-instance>";
} else if (dataInType.equals("latest")) {
appXml += "<start-instance>${coord:" + dataInType + "(-3)}</start-instance>";
appXml += "<end-instance>${coord:" + dataInType + "(0)}</end-instance>";
} else if (dataInType.equals("current")) {
appXml += "<start-instance>${coord:" + dataInType + "(-3)}</start-instance>";
appXml += "<end-instance>${coord:" + dataInType + "(1)}</end-instance>";
}
appXml += "</data-in>";
appXml += "</input-events>";
appXml += "<output-events>";
appXml += "<data-out name='LOCAL_A' dataset='local_a'>";
appXml += "<dataset name='local_a' frequency='7' initial-instance='2009-01-01T01:00" + TZ + "' timezone='UTC'" + " freq_timeunit='DAY' end_of_duration='NONE'>";
appXml += "<uri-template>" + getTestCaseFileUri("${YEAR}/${MONTH}/${DAY}") + "</uri-template>";
appXml += "</dataset>";
appXml += "<start-instance>${coord:current(-3)}</start-instance>";
appXml += "<instance>${coord:current(0)}</instance>";
appXml += "</data-out>";
appXml += "</output-events>";
appXml += "<action>";
appXml += "<workflow>";
appXml += "<app-path>hdfs:///tmp/workflows/</app-path>";
appXml += "<configuration>";
appXml += "<property>";
appXml += "<name>inputA</name>";
appXml += "<value>${coord:dataIn('A')}</value>";
appXml += "</property>";
appXml += "<property>";
appXml += "<name>inputB</name>";
appXml += "<value>${coord:dataOut('LOCAL_A')}</value>";
appXml += "</property>";
appXml += "</configuration>";
appXml += "</workflow>";
appXml += "</action>";
appXml += "</coordinator-app>";
coordJob.setJobXml(appXml);
coordJob.setLastActionNumber(0);
coordJob.setFrequency("1");
coordJob.setExecutionOrder(Execution.FIFO);
coordJob.setConcurrency(1);
JPAService jpaService = Services.get().get(JPAService.class);
if (jpaService != null) {
try {
jpaService.execute(new CoordJobInsertJPAExecutor(coordJob));
} catch (JPAExecutorException e) {
throw new CommandException(e);
}
} else {
fail("Unable to insert the test job record to table");
}
return coordJob;
}
use of org.apache.oozie.executor.jpa.JPAExecutorException in project oozie by apache.
the class TestCoordActionInputCheckXCommand method addRecordToCoordActionTableForWaiting.
protected CoordinatorActionBean addRecordToCoordActionTableForWaiting(String jobId, int actionNum, CoordinatorAction.Status status, String resourceXmlName) throws Exception {
CoordinatorActionBean action = createCoordAction(jobId, actionNum, status, resourceXmlName, 0, TZ, null);
String missDeps = getTestCaseFileUri("2009/01/29/_SUCCESS") + "#" + getTestCaseFileUri("2009/01/22/_SUCCESS") + "#" + getTestCaseFileUri("2009/01/15/_SUCCESS") + "#" + getTestCaseFileUri("2009/01/08/_SUCCESS");
action.setMissingDependencies(missDeps);
try {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordActionInsertJPAExecutor coordActionInsertCmd = new CoordActionInsertJPAExecutor(action);
jpaService.execute(coordActionInsertCmd);
} catch (JPAExecutorException je) {
je.printStackTrace();
fail("Unable to insert the test coord action record to table");
throw je;
}
return action;
}
use of org.apache.oozie.executor.jpa.JPAExecutorException in project oozie by apache.
the class TestCoordActionInputCheckXCommand method testActionInputCheckFuture.
public void testActionInputCheckFuture() throws Exception {
String jobId = "0000000-" + new Date().getTime() + "-TestCoordActionInputCheckXCommand-C";
Date startTime = DateUtils.parseDateOozieTZ("2009-02-15T23:59" + TZ);
Date endTime = DateUtils.parseDateOozieTZ("2009-02-16T23:59" + TZ);
CoordinatorJobBean job = addRecordToCoordJobTable(jobId, startTime, endTime, "future");
new CoordMaterializeTransitionXCommand(job.getId(), 3600).call();
// providing some of the dataset dirs required as per coordinator specification with holes
createTestCaseSubDir("2009/02/12/_SUCCESS".split("/"));
createTestCaseSubDir("2009/02/26/_SUCCESS".split("/"));
createTestCaseSubDir("2009/03/05/_SUCCESS".split("/"));
// limit is 5. So this should be ignored
createTestCaseSubDir("2009/03/26/_SUCCESS".split("/"));
new CoordActionInputCheckXCommand(job.getId() + "@1", job.getId()).call();
CoordinatorActionBean action = null;
JPAService jpaService = Services.get().get(JPAService.class);
try {
action = jpaService.execute(new CoordActionGetJPAExecutor(job.getId() + "@1"));
} catch (JPAExecutorException se) {
fail("Action ID " + job.getId() + "@1" + " was not stored properly in db");
}
assertEquals(CoordCommandUtils.RESOLVED_UNRESOLVED_SEPARATOR + "${coord:futureRange(0,3,'5')}", action.getMissingDependencies());
createTestCaseSubDir("2009/03/12/_SUCCESS".split("/"));
new CoordActionInputCheckXCommand(job.getId() + "@1", job.getId()).call();
try {
action = jpaService.execute(new CoordActionGetJPAExecutor(job.getId() + "@1"));
} catch (JPAExecutorException se) {
fail("Action ID " + job.getId() + "@1" + " was not stored properly in db");
}
assertEquals("", action.getMissingDependencies());
String actionXML = action.getActionXml();
String resolvedList = getTestCaseFileUri("2009/02/12") + CoordELFunctions.INSTANCE_SEPARATOR + getTestCaseFileUri("2009/02/26") + CoordELFunctions.INSTANCE_SEPARATOR + getTestCaseFileUri("2009/03/05") + CoordELFunctions.INSTANCE_SEPARATOR + getTestCaseFileUri("2009/03/12");
assertEquals(resolvedList, actionXML.substring(actionXML.indexOf("<uris>") + 6, actionXML.indexOf("</uris>")));
}
Aggregations