use of org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor in project oozie by apache.
the class TestCoordRerunXCommand method addRecordToCoordJobTableWithPausedTime.
protected CoordinatorJobBean addRecordToCoordJobTableWithPausedTime(CoordinatorJob.Status status, boolean pending, boolean doneMatd, Date pausedTime) throws Exception {
CoordinatorJobBean coordJob = createCoordJob(status, pending, doneMatd);
coordJob.setPauseTime(pausedTime);
try {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordJobInsertJPAExecutor coordInsertCmd = new CoordJobInsertJPAExecutor(coordJob);
jpaService.execute(coordInsertCmd);
} catch (JPAExecutorException je) {
je.printStackTrace();
fail("Unable to insert the test coord job record to table");
throw je;
}
return coordJob;
}
use of org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor in project oozie by apache.
the class TestCoordChangeXCommand method addRecordToCoordJobTableForPauseTimeTest.
protected CoordinatorJobBean addRecordToCoordJobTableForPauseTimeTest(CoordinatorJob.Status status, Date start, Date end, Date lastActionTime, boolean pending, boolean doneMatd, int lastActionNum) throws Exception {
CoordinatorJobBean coordJob = createCoordJob(status, start, end, pending, doneMatd, lastActionNum);
coordJob.setFrequency("1");
coordJob.setTimeUnit(Timeunit.HOUR);
coordJob.setLastActionNumber(lastActionNum);
coordJob.setLastActionTime(lastActionTime);
try {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordJobInsertJPAExecutor coordInsertCmd = new CoordJobInsertJPAExecutor(coordJob);
jpaService.execute(coordInsertCmd);
} catch (JPAExecutorException je) {
je.printStackTrace();
fail("Unable to insert the test coord job record to table");
throw je;
}
return coordJob;
}
use of org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor in project oozie by apache.
the class TestCoordCommandUtils method addRecordToCoordJobTable.
protected CoordinatorJobBean addRecordToCoordJobTable(CoordinatorJob.Status status, Date startTime, Date endTime, String freq) throws Exception {
CoordinatorJobBean coordJob = createCoordJob(status, startTime, endTime, false, false, 0);
coordJob.setStartTime(startTime);
coordJob.setEndTime(endTime);
coordJob.setFrequency(freq);
coordJob.setTimeUnit(CoordinatorJob.Timeunit.MINUTE);
try {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
CoordJobInsertJPAExecutor coordInsertCmd = new CoordJobInsertJPAExecutor(coordJob);
jpaService.execute(coordInsertCmd);
} catch (JPAExecutorException ex) {
ex.printStackTrace();
fail("Unable to insert the test coord job record to table");
throw ex;
}
return coordJob;
}
use of org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor 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.CoordJobInsertJPAExecutor in project oozie by apache.
the class TestBundleStartXCommand method testBundleStartWithFailedCoordinator.
public void testBundleStartWithFailedCoordinator() throws Exception {
services.destroy();
services = new Services();
String[] excludeServices = { "org.apache.oozie.service.UUIDService", "org.apache.oozie.service.StatusTransitService" };
Configuration conf = services.getConf();
setClassesToBeExcluded(conf, excludeServices);
conf.set(Services.CONF_SERVICE_CLASSES, conf.get(Services.CONF_SERVICE_CLASSES) + "," + DummyUUIDService.class.getName());
services.init();
CoordinatorJobBean coordJob = new CoordinatorJobBean();
coordJob.setId("dummy-coord-id");
JPAService jpaService = Services.get().get(JPAService.class);
CoordJobInsertJPAExecutor coordInsertCmd = new CoordJobInsertJPAExecutor(coordJob);
jpaService.execute(coordInsertCmd);
BundleJobBean job = addRecordToBundleJobTable(Job.Status.PREP, false);
BundleJobGetJPAExecutor bundleJobGetExecutor = new BundleJobGetJPAExecutor(job.getId());
job = jpaService.execute(bundleJobGetExecutor);
assertEquals(job.getStatus(), Job.Status.PREP);
new BundleStartXCommand(job.getId()).call();
job = jpaService.execute(bundleJobGetExecutor);
assertEquals(job.getStatus(), Job.Status.RUNNING);
sleep(2000);
List<BundleActionBean> actions = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_ACTIONS_STATUS_UNIGNORED_FOR_BUNDLE, job.getId());
assertNull(actions.get(0).getCoordId());
assertEquals(Job.Status.FAILED, actions.get(0).getStatus());
Runnable runnable = new StatusTransitRunnable();
// 1st run of StatusTransitionService changes bundle to running
runnable.run();
sleep(2000);
// 2nd run changes bundle to DoneWithError
runnable.run();
sleep(2000);
job = jpaService.execute(bundleJobGetExecutor);
assertEquals(job.getStatus(), Job.Status.DONEWITHERROR);
}
Aggregations