use of org.apache.oozie.CoordinatorActionBean 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.CoordinatorActionBean in project oozie by apache.
the class TestCoordActionInputCheckXCommand method testResolveCoordConfiguration.
public void testResolveCoordConfiguration() {
try {
CoordinatorJobBean job = addRecordToCoordJobTableForWaiting("coord-job-for-action-input-check.xml", CoordinatorJob.Status.RUNNING, false, true);
CoordinatorActionBean action = addRecordToCoordActionTableForWaiting(job.getId(), 1, CoordinatorAction.Status.WAITING, "coord-action-for-action-input-check.xml");
createTestCaseSubDir("2009/01/29/_SUCCESS".split("/"));
createTestCaseSubDir("2009/01/22/_SUCCESS".split("/"));
createTestCaseSubDir("2009/01/15/_SUCCESS".split("/"));
createTestCaseSubDir("2009/01/08/_SUCCESS".split("/"));
sleep(3000);
new CoordActionInputCheckXCommand(action.getId(), job.getId()).call();
sleep(3000);
final JPAService jpaService = Services.get().get(JPAService.class);
CoordActionGetJPAExecutor coordGetCmd = new CoordActionGetJPAExecutor(action.getId());
CoordinatorActionBean caBean = jpaService.execute(coordGetCmd);
Element eAction = XmlUtils.parseXml(caBean.getActionXml());
Element configElem = eAction.getChild("action", eAction.getNamespace()).getChild("workflow", eAction.getNamespace()).getChild("configuration", eAction.getNamespace());
List<?> elementList = configElem.getChildren("property", configElem.getNamespace());
Element e1 = (Element) elementList.get(0);
Element e2 = (Element) elementList.get(1);
assertEquals("file://,testDir/2009/29,file://,testDir/2009/22,file://,testDir/2009/15,file://,testDir/2009/08", e1.getChild("value", e1.getNamespace()).getValue());
assertEquals("file://,testDir/2009/29", e2.getChild("value", e1.getNamespace()).getValue());
} catch (Exception e) {
e.printStackTrace();
fail("Unexpected exception");
}
}
use of org.apache.oozie.CoordinatorActionBean 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>")));
}
use of org.apache.oozie.CoordinatorActionBean in project oozie by apache.
the class TestCoordActionNotificationXCommand method testCoordNotificationTimeout.
public void testCoordNotificationTimeout() throws Exception {
XConfiguration conf = new XConfiguration();
conf.set(OozieClient.COORD_ACTION_NOTIFICATION_URL, container.getServletURL("/hang/*"));
String runConf = conf.toXmlString(false);
CoordinatorActionBean coord = Mockito.mock(CoordinatorActionBean.class);
Mockito.when(coord.getId()).thenReturn("1");
Mockito.when(coord.getStatus()).thenReturn(CoordinatorAction.Status.SUCCEEDED);
Mockito.when(coord.getRunConf()).thenReturn(runConf);
CoordActionNotificationXCommand command = new CoordActionNotificationXCommand(coord);
command.retries = 3;
long start = System.currentTimeMillis();
command.call();
long end = System.currentTimeMillis();
Assert.assertTrue(end - start >= 50);
Assert.assertTrue(end - start <= 10000);
}
use of org.apache.oozie.CoordinatorActionBean in project oozie by apache.
the class CoordJobGetActionsSuspendedJPAExecutor method execute.
@Override
@SuppressWarnings("unchecked")
public List<CoordinatorActionBean> execute(EntityManager em) throws JPAExecutorException {
try {
List<CoordinatorActionBean> actionBeansList = new ArrayList<CoordinatorActionBean>();
Query q = em.createNamedQuery("GET_COORD_ACTIONS_SUSPENDED");
q.setParameter("jobId", coordJobId);
List<Object[]> objectArrList = q.getResultList();
for (Object[] arr : objectArrList) {
CoordinatorActionBean caa = getBeanForCoordinatorActionFromArray(arr);
actionBeansList.add(caa);
}
return actionBeansList;
} catch (Exception e) {
throw new JPAExecutorException(ErrorCode.E0603, e.getMessage(), e);
}
}
Aggregations