use of org.apache.oozie.XException in project oozie by apache.
the class SLAEventsXCommand method execute.
@Override
protected List<SLAEventBean> execute() throws CommandException {
try {
JPAService jpaService = Services.get().get(JPAService.class);
List<SLAEventBean> slaEventList = null;
long[] lastSeqId = new long[1];
if (jpaService != null) {
slaEventList = jpaService.execute(new SLAEventsGetForFilterJPAExecutor(seqId, maxNoEvents, filter, lastSeqId));
} else {
LOG.error(ErrorCode.E0610);
}
setLastSeqId(lastSeqId[0]);
return slaEventList;
} catch (XException ex) {
throw new CommandException(ex);
}
}
use of org.apache.oozie.XException in project oozie by apache.
the class TestBundleJobInfoGetJPAExecutor method testGetJobInfoForText.
public void testGetJobInfoForText() throws Exception {
BundleJobBean bundleJob1 = addRecordToBundleJobTable(BundleJob.Status.RUNNING, false);
BundleJobBean bundleJob2 = addRecordToBundleJobTable(BundleJob.Status.KILLED, false);
bundleJob1.setAppName("oozie-bundle1");
bundleJob2.setAppName("oozie-bundle2");
BundleJobQueryExecutor.getInstance().executeUpdate(BundleJobQueryExecutor.BundleJobQuery.UPDATE_BUNDLE_JOB, bundleJob1);
BundleJobQueryExecutor.getInstance().executeUpdate(BundleJobQueryExecutor.BundleJobQuery.UPDATE_BUNDLE_JOB, bundleJob2);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
Map<String, List<String>> filter = new HashMap<String, List<String>>();
BundleJobInfoGetJPAExecutor bundleInfoGetCmd = new BundleJobInfoGetJPAExecutor(filter, 1, 20);
BundleJobInfo ret = jpaService.execute(bundleInfoGetCmd);
assertNotNull(ret);
assertEquals(2, ret.getBundleJobs().size());
filter.clear();
ArrayList<String> textList = new ArrayList<String>();
textList.add("tes");
filter.put(OozieClient.FILTER_TEXT, textList);
bundleInfoGetCmd = new BundleJobInfoGetJPAExecutor(filter, 1, 20);
ret = jpaService.execute(bundleInfoGetCmd);
assertNotNull(ret);
assertEquals(ret.getBundleJobs().size(), 2);
textList.clear();
textList.add("oozie-bundle1");
filter.put(OozieClient.FILTER_TEXT, textList);
bundleInfoGetCmd = new BundleJobInfoGetJPAExecutor(filter, 1, 20);
ret = jpaService.execute(bundleInfoGetCmd);
assertNotNull(ret);
assertEquals(ret.getBundleJobs().size(), 1);
textList.clear();
textList.add("random");
filter.put(OozieClient.FILTER_TEXT, textList);
bundleInfoGetCmd = new BundleJobInfoGetJPAExecutor(filter, 1, 20);
ret = jpaService.execute(bundleInfoGetCmd);
assertNotNull(ret);
assertEquals(ret.getBundleJobs().size(), 0);
textList.clear();
textList.add("oozie-bundle");
filter.put(OozieClient.FILTER_TEXT, textList);
bundleInfoGetCmd = new BundleJobInfoGetJPAExecutor(filter, 1, 20);
ret = jpaService.execute(bundleInfoGetCmd);
assertNotNull(ret);
assertEquals(ret.getBundleJobs().size(), 2);
textList.add("tes");
filter.put(OozieClient.FILTER_TEXT, textList);
bundleInfoGetCmd = new BundleJobInfoGetJPAExecutor(filter, 1, 20);
try {
jpaService.execute(bundleInfoGetCmd);
fail("BundleJobInfoGetJPAExecutor should have thrown E0302 exception.");
} catch (XException e) {
assertEquals(ErrorCode.E0302, e.getErrorCode());
assertEquals(e.getMessage(), "E0302: Invalid parameter [cannot specify multiple strings to search]");
}
// Update bundle appName, user and validate text filter
bundleJob1.setAppName("updated-app-name1");
bundleJob2.setAppName("updated-app-name2");
BundleJobQueryExecutor.getInstance().executeUpdate(BundleJobQueryExecutor.BundleJobQuery.UPDATE_BUNDLE_JOB, bundleJob1);
BundleJobQueryExecutor.getInstance().executeUpdate(BundleJobQueryExecutor.BundleJobQuery.UPDATE_BUNDLE_JOB, bundleJob2);
textList.clear();
textList.add("oozie-bundle");
filter.put(OozieClient.FILTER_TEXT, textList);
bundleInfoGetCmd = new BundleJobInfoGetJPAExecutor(filter, 1, 20);
ret = jpaService.execute(bundleInfoGetCmd);
assertNotNull(ret);
assertEquals(ret.getBundleJobs().size(), 0);
textList.clear();
textList.add("updated-app");
filter.put(OozieClient.FILTER_TEXT, textList);
bundleInfoGetCmd = new BundleJobInfoGetJPAExecutor(filter, 1, 20);
ret = jpaService.execute(bundleInfoGetCmd);
assertNotNull(ret);
assertEquals(ret.getBundleJobs().size(), 2);
textList.clear();
textList.add("updated-app-name1");
bundleInfoGetCmd = new BundleJobInfoGetJPAExecutor(filter, 1, 20);
ret = jpaService.execute(bundleInfoGetCmd);
assertNotNull(ret);
assertEquals(ret.getBundleJobs().size(), 1);
}
use of org.apache.oozie.XException in project oozie by apache.
the class BundleJobXCommand method execute.
/* (non-Javadoc)
* @see org.apache.oozie.command.XCommand#execute()
*/
@Override
protected BundleJobBean execute() throws CommandException {
try {
JPAService jpaService = Services.get().get(JPAService.class);
BundleJobBean bundleJob = null;
if (jpaService != null) {
bundleJob = jpaService.execute(new BundleJobGetJPAExecutor(id));
List<CoordinatorJobBean> coordinators = jpaService.execute(new BundleJobGetCoordinatorsJPAExecutor(id));
bundleJob.setCoordJobs(coordinators);
} else {
LOG.error(ErrorCode.E0610);
}
return bundleJob;
} catch (XException ex) {
throw new CommandException(ex);
}
}
use of org.apache.oozie.XException in project oozie by apache.
the class BundleKillXCommand method loadState.
@Override
public void loadState() throws CommandException {
try {
this.bundleJob = BundleJobQueryExecutor.getInstance().get(BundleJobQuery.GET_BUNDLE_JOB, jobId);
this.bundleActions = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_ACTIONS_STATUS_UNIGNORED_FOR_BUNDLE, jobId);
LogUtils.setLogInfo(bundleJob);
super.setJob(bundleJob);
} catch (XException ex) {
throw new CommandException(ex);
}
}
use of org.apache.oozie.XException in project oozie by apache.
the class CoordResumeXCommand method resumeChildren.
@Override
public void resumeChildren() throws CommandException {
try {
// Get all suspended actions to resume them
List<CoordinatorActionBean> actionList = jpaService.execute(new CoordJobGetActionsSuspendedJPAExecutor(jobId));
for (CoordinatorActionBean action : actionList) {
if (action.getExternalId() != null) {
// queue a ResumeXCommand
queue(new ResumeXCommand(action.getExternalId()));
updateCoordAction(action);
LOG.debug("Resume coord action = [{0}], new status = [{1}], pending = [{2}] and queue ResumeXCommand for [{3}]", action.getId(), action.getStatus(), action.getPending(), action.getExternalId());
} else {
updateCoordAction(action);
LOG.debug("Resume coord action = [{0}], new status = [{1}], pending = [{2}] and external id is null", action.getId(), action.getStatus(), action.getPending());
}
}
} catch (XException ex) {
exceptionOccured = true;
throw new CommandException(ex);
} finally {
if (exceptionOccured) {
coordJob.setStatus(CoordinatorJob.Status.FAILED);
coordJob.resetPending();
LOG.warn("Resume children failed so fail coordinator, coordinator job id = " + jobId + ", status = " + coordJob.getStatus());
updateList.add(new UpdateEntry<CoordJobQuery>(CoordJobQuery.UPDATE_COORD_JOB_STATUS_PENDING_TIME, coordJob));
}
}
}
Aggregations