use of org.apache.oozie.executor.jpa.JPAExecutorException in project oozie by apache.
the class XDataTestCase method addRecordToCoordJobTableForWaiting.
protected CoordinatorJobBean addRecordToCoordJobTableForWaiting(String testFileName, CoordinatorJobBean coordJob) throws Exception {
String testDir = getTestCaseDir();
String appXml = getCoordJobXmlForWaiting(testFileName, testDir);
coordJob.setJobXml(appXml);
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.JPAExecutorException in project oozie by apache.
the class XDataTestCase method addRecordToBundleActionTable.
/**
* Create bundle action bean and save to db
*
* @param jobId bundle job id
* @param coordName coordinator name
* @param pending true if action is pending
* @param status job status
* @return bundle action bean
* @throws Exception
*/
protected BundleActionBean addRecordToBundleActionTable(String jobId, String coordName, int pending, Job.Status status) throws Exception {
BundleActionBean action = createBundleAction(jobId, null, coordName, pending, status);
try {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
BundleActionInsertJPAExecutor bundleActionJPAExecutor = new BundleActionInsertJPAExecutor(action);
jpaService.execute(bundleActionJPAExecutor);
} catch (JPAExecutorException ex) {
ex.printStackTrace();
fail("Unable to insert the test bundle action record to table");
throw ex;
}
return action;
}
use of org.apache.oozie.executor.jpa.JPAExecutorException in project oozie by apache.
the class XDataTestCase method addRecordToCoordJobTableWithBundle.
/**
* Add coordinator job bean with bundle id info.
*
* @param bundleId bundle id
* @param coordId coord id and coord name
* @param status job status
* @param pending true if pending is true
* @param doneMatd true if doneMaterialization is true
* @param lastActionNumber last action number
* @return coordinator job bean
* @throws Exception
*/
protected CoordinatorJobBean addRecordToCoordJobTableWithBundle(String bundleId, String coordId, CoordinatorJob.Status status, boolean pending, boolean doneMatd, int lastActionNumber) throws Exception {
CoordinatorJobBean coordJob = createCoordJob(status, pending, doneMatd);
coordJob.setBundleId(bundleId);
// coord id and coord name are the same
coordJob.setId(coordId);
coordJob.setAppName(coordId);
coordJob.setLastActionNumber(lastActionNumber);
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.JPAExecutorException in project oozie by apache.
the class CoordMaterializeTransitionXCommand method materialize.
/* (non-Javadoc)
* @see org.apache.oozie.command.MaterializeTransitionXCommand#materialize()
*/
@Override
protected void materialize() throws CommandException {
Instrumentation.Cron cron = new Instrumentation.Cron();
cron.start();
try {
materializeActions(false);
updateJobMaterializeInfo(coordJob);
} catch (CommandException ex) {
LOG.warn("Exception occurred:" + ex.getMessage() + " Making the job failed ", ex);
coordJob.setStatus(Job.Status.FAILED);
coordJob.resetPending();
// remove any materialized actions and slaEvents
insertList.clear();
} catch (Exception e) {
LOG.error("Exception occurred:" + e.getMessage() + " Making the job failed ", e);
coordJob.setStatus(Job.Status.FAILED);
try {
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB_MATERIALIZE, coordJob);
} catch (JPAExecutorException jex) {
throw new CommandException(ErrorCode.E1011, jex);
}
throw new CommandException(ErrorCode.E1012, e.getMessage(), e);
} finally {
cron.stop();
instrumentation.addCron(INSTRUMENTATION_GROUP, getName() + ".materialize", cron);
}
}
use of org.apache.oozie.executor.jpa.JPAExecutorException in project oozie by apache.
the class CoordPushDependencyCheckXCommand method updateCoordAction.
protected void updateCoordAction(CoordinatorActionBean coordAction, boolean isChangeInDependency) throws CommandException {
coordAction.setLastModifiedTime(new Date());
if (jpaService != null) {
try {
if (isChangeInDependency) {
coordAction.setPushMissingDependencies(coordAction.getPushInputDependencies().serialize());
CoordActionQueryExecutor.getInstance().executeUpdate(CoordActionQuery.UPDATE_COORD_ACTION_FOR_PUSH_INPUTCHECK, coordAction);
if (EventHandlerService.isEnabled() && coordAction.getStatus() != CoordinatorAction.Status.READY) {
// since event is not to be generated unless action
// RUNNING via StartX
generateEvent(coordAction, coordJob.getUser(), coordJob.getAppName(), null);
}
} else {
CoordActionQueryExecutor.getInstance().executeUpdate(CoordActionQuery.UPDATE_COORD_ACTION_FOR_MODIFIED_DATE, coordAction);
}
} catch (JPAExecutorException jex) {
throw new CommandException(ErrorCode.E1021, jex.getMessage(), jex);
} catch (IOException ioe) {
throw new CommandException(ErrorCode.E1021, ioe.getMessage(), ioe);
}
}
}
Aggregations