use of org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor in project oozie by apache.
the class TestEventGeneration method testForNoDuplicatesCoordinatorActionEvents.
@Test
public void testForNoDuplicatesCoordinatorActionEvents() throws Exception {
// test coordinator action events (failure case)
Date startTime = DateUtils.parseDateOozieTZ("2009-02-01T23:59Z");
Date endTime = DateUtils.parseDateOozieTZ("2009-02-02T23:59Z");
CoordinatorJobBean coord = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, startTime, endTime, false, false, 0);
_modifyCoordForFailureAction(coord, "wf-invalid-fork.xml");
new CoordMaterializeTransitionXCommand(coord.getId(), 3600).call();
final CoordJobGetJPAExecutor readCmd1 = new CoordJobGetJPAExecutor(coord.getId());
waitFor(1 * 100, new Predicate() {
@Override
public boolean evaluate() throws Exception {
CoordinatorJobBean bean = jpaService.execute(readCmd1);
return bean.getStatus() == CoordinatorJob.Status.SUCCEEDED || bean.getStatus() == CoordinatorJob.Status.KILLED;
}
});
assertEquals(2, queue.size());
assertEquals(EventStatus.WAITING, ((JobEvent) queue.poll()).getEventStatus());
assertEquals(EventStatus.FAILURE, ((JobEvent) queue.poll()).getEventStatus());
queue.clear();
}
use of org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor in project oozie by apache.
the class TestEventGeneration method testInvalidXMLCoordinatorFailsForNoDuplicates.
@Test
public void testInvalidXMLCoordinatorFailsForNoDuplicates() throws Exception {
Date startTime = DateUtils.parseDateOozieTZ("2009-02-01T23:59Z");
Date endTime = DateUtils.parseDateOozieTZ("2009-02-02T23:59Z");
// test coordinator action events (failure from ActionStartX)
ehs.getAppTypes().add("workflow_action");
CoordinatorJobBean coord = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, startTime, endTime, false, false, 0);
CoordinatorActionBean action = addRecordToCoordActionTable(coord.getId(), 1, CoordinatorAction.Status.RUNNING, "coord-action-sla1.xml", 0);
WorkflowJobBean wf = addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING, action.getId());
action.setExternalId(wf.getId());
CoordActionQueryExecutor.getInstance().executeUpdate(CoordActionQuery.UPDATE_COORD_ACTION, action);
String waId = _createWorkflowAction(wf.getId(), "wf-action");
new ActionStartXCommand(waId, action.getType()).call();
final CoordJobGetJPAExecutor readCmd2 = new CoordJobGetJPAExecutor(coord.getId());
waitFor(1 * 100, new Predicate() {
@Override
public boolean evaluate() throws Exception {
return jpaService.execute(readCmd2).getStatus() == CoordinatorJob.Status.KILLED;
}
});
assertEquals(3, queue.size());
HashMap<AppType, JobEvent> eventsMap = new HashMap<AppType, JobEvent>();
while (queue.size() > 0) {
JobEvent event = (JobEvent) queue.poll();
eventsMap.put(event.getAppType(), event);
}
assertEquals(3, eventsMap.size());
// Check the WF action
{
JobEvent wfActionEvent = eventsMap.get(AppType.WORKFLOW_ACTION);
assertNotNull("There should be a WF action", wfActionEvent);
assertEquals(EventStatus.FAILURE, wfActionEvent.getEventStatus());
assertEquals(waId, wfActionEvent.getId());
assertEquals(AppType.WORKFLOW_ACTION, wfActionEvent.getAppType());
}
// Check the WF job
{
JobEvent wfJobEvent = eventsMap.get(AppType.WORKFLOW_JOB);
assertNotNull("There should be a WF job", wfJobEvent);
assertEquals(EventStatus.FAILURE, wfJobEvent.getEventStatus());
assertEquals(wf.getId(), wfJobEvent.getId());
assertEquals(AppType.WORKFLOW_JOB, wfJobEvent.getAppType());
}
// Check the Coordinator action
{
JobEvent coordActionEvent = eventsMap.get(AppType.COORDINATOR_ACTION);
assertNotNull("There should be a Coordinator action", coordActionEvent);
assertEquals(EventStatus.FAILURE, coordActionEvent.getEventStatus());
assertEquals(action.getId(), coordActionEvent.getId());
assertEquals(AppType.COORDINATOR_ACTION, coordActionEvent.getAppType());
}
queue.clear();
}
use of org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor in project oozie by apache.
the class CoordPushDependencyCheckXCommand method loadState.
@Override
protected void loadState() throws CommandException {
jpaService = Services.get().get(JPAService.class);
try {
coordAction = jpaService.execute(new CoordActionGetForInputCheckJPAExecutor(actionId));
if (coordAction != null) {
coordJob = jpaService.execute(new CoordJobGetJPAExecutor(coordAction.getJobId()));
LogUtils.setLogInfo(coordAction);
} else {
throw new CommandException(ErrorCode.E0605, actionId);
}
} catch (JPAExecutorException je) {
throw new CommandException(je);
}
}
use of org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor in project oozie by apache.
the class CoordResumeXCommand method loadState.
@Override
protected void loadState() throws CommandException {
jpaService = Services.get().get(JPAService.class);
if (jpaService == null) {
throw new CommandException(ErrorCode.E0610);
}
try {
coordJob = jpaService.execute(new CoordJobGetJPAExecutor(jobId));
} catch (JPAExecutorException e) {
throw new CommandException(e);
}
setJob(coordJob);
prevStatus = coordJob.getStatus();
LogUtils.setLogInfo(coordJob);
}
use of org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor in project oozie by apache.
the class CoordJobXCommand method execute.
/* (non-Javadoc)
* @see org.apache.oozie.command.XCommand#execute()
*/
@Override
protected CoordinatorJobBean execute() throws CommandException {
try {
JPAService jpaService = Services.get().get(JPAService.class);
CoordinatorJobBean coordJob = null;
if (jpaService != null) {
coordJob = jpaService.execute(new CoordJobGetJPAExecutor(id));
if (getActionInfo) {
int numAction = jpaService.execute(new CoordActionsCountForJobIdJPAExecutor(id, filterMap));
List<CoordinatorActionBean> coordActions = null;
if (len == 0) {
coordActions = new ArrayList<CoordinatorActionBean>();
} else {
coordActions = jpaService.execute(new CoordJobGetActionsSubsetJPAExecutor(id, filterMap, offset, len, desc));
}
coordJob.setActions(coordActions);
coordJob.setNumActions(numAction);
}
} else {
LOG.error(ErrorCode.E0610);
}
return coordJob;
} catch (XException ex) {
throw new CommandException(ex);
}
}
Aggregations