use of org.apache.oozie.executor.jpa.BundleJobQueryExecutor.BundleJobQuery in project oozie by apache.
the class BundleJobChangeXCommand method execute.
/* (non-Javadoc)
* @see org.apache.oozie.command.XCommand#execute()
*/
@Override
protected Void execute() throws CommandException {
StringBuffer changeReport = new StringBuffer();
try {
if (isChangePauseTime || isChangeEndTime) {
if (isChangePauseTime) {
bundleJob.setPauseTime(newPauseTime);
} else if (isChangeEndTime) {
bundleJob.setEndTime(newEndTime);
if (bundleJob.getStatus() == Job.Status.SUCCEEDED) {
bundleJob.setStatus(Job.Status.RUNNING);
}
if (bundleJob.getStatus() == Job.Status.DONEWITHERROR || bundleJob.getStatus() == Job.Status.FAILED) {
bundleJob.setStatus(StatusUtils.getStatusIfBackwardSupportTrue(Job.Status.RUNNINGWITHERROR));
}
}
for (BundleActionBean action : this.bundleActions) {
// queue coord change commands;
if (action.getStatus() != Job.Status.KILLED && action.getCoordId() != null) {
try {
new CoordChangeXCommand(action.getCoordId(), changeValue).call();
} catch (Exception e) {
String errorMsg = action.getCoordId() + " : " + e.getMessage();
LOG.info("Change command failed " + errorMsg);
changeReport.append("[ ").append(errorMsg).append(" ]");
}
} else {
String errorMsg = action.getCoordId() + " : Coord is in killed state";
LOG.info("Change command failed " + errorMsg);
changeReport.append("[ ").append(errorMsg).append(" ]");
}
}
updateList.add(new UpdateEntry<BundleJobQuery>(BundleJobQuery.UPDATE_BUNDLE_JOB_STATUS_PAUSE_ENDTIME, bundleJob));
BatchQueryExecutor.getInstance().executeBatchInsertUpdateDelete(null, updateList, null);
}
if (!changeReport.toString().isEmpty()) {
throw new CommandException(ErrorCode.E1320, changeReport.toString());
}
return null;
} catch (XException ex) {
throw new CommandException(ex);
}
}
use of org.apache.oozie.executor.jpa.BundleJobQueryExecutor.BundleJobQuery in project oozie by apache.
the class BundleJobResumeXCommand method updateJob.
/* (non-Javadoc)
* @see org.apache.oozie.command.TransitionXCommand#updateJob()
*/
@Override
public void updateJob() {
InstrumentUtils.incrJobCounter("bundle_resume", 1, null);
bundleJob.setSuspendedTime(null);
bundleJob.setLastModifiedTime(new Date());
LOG.debug("Resume bundle job id = " + bundleId + ", " + "status = " + bundleJob.getStatus() + ", pending = " + bundleJob.isPending());
updateList.add(new UpdateEntry<BundleJobQuery>(BundleJobQuery.UPDATE_BUNDLE_JOB_STATUS_PENDING_SUSP_MOD_TIME, bundleJob));
}
use of org.apache.oozie.executor.jpa.BundleJobQueryExecutor.BundleJobQuery in project oozie by apache.
the class BundleJobSuspendXCommand method updateJob.
/* (non-Javadoc)
* @see org.apache.oozie.command.TransitionXCommand#updateJob()
*/
@Override
public void updateJob() {
InstrumentUtils.incrJobCounter("bundle_suspend", 1, null);
bundleJob.setSuspendedTime(new Date());
bundleJob.setLastModifiedTime(new Date());
LOG.debug("Suspend bundle job id = " + jobId + ", status = " + bundleJob.getStatus() + ", pending = " + bundleJob.isPending());
updateList.add(new UpdateEntry<BundleJobQuery>(BundleJobQuery.UPDATE_BUNDLE_JOB_STATUS_PENDING_SUSP_MOD_TIME, bundleJob));
}
use of org.apache.oozie.executor.jpa.BundleJobQueryExecutor.BundleJobQuery in project oozie by apache.
the class BatchQueryExecutor method executeBatchInsertUpdateDelete.
@SuppressWarnings("rawtypes")
public void executeBatchInsertUpdateDelete(Collection<JsonBean> insertList, Collection<UpdateEntry> updateList, Collection<JsonBean> deleteList) throws JPAExecutorException {
List<QueryEntry> queryList = new ArrayList<QueryEntry>();
JPAService jpaService = Services.get().get(JPAService.class);
EntityManager em = jpaService.getEntityManager();
if (updateList != null) {
for (UpdateEntry entry : updateList) {
Query query = null;
JsonBean bean = entry.getBean();
if (bean instanceof WorkflowJobBean) {
query = WorkflowJobQueryExecutor.getInstance().getUpdateQuery((WorkflowJobQuery) entry.getQueryName(), (WorkflowJobBean) entry.getBean(), em);
} else if (bean instanceof WorkflowActionBean) {
query = WorkflowActionQueryExecutor.getInstance().getUpdateQuery((WorkflowActionQuery) entry.getQueryName(), (WorkflowActionBean) entry.getBean(), em);
} else if (bean instanceof CoordinatorJobBean) {
query = CoordJobQueryExecutor.getInstance().getUpdateQuery((CoordJobQuery) entry.getQueryName(), (CoordinatorJobBean) entry.getBean(), em);
} else if (bean instanceof CoordinatorActionBean) {
query = CoordActionQueryExecutor.getInstance().getUpdateQuery((CoordActionQuery) entry.getQueryName(), (CoordinatorActionBean) entry.getBean(), em);
} else if (bean instanceof BundleJobBean) {
query = BundleJobQueryExecutor.getInstance().getUpdateQuery((BundleJobQuery) entry.getQueryName(), (BundleJobBean) entry.getBean(), em);
} else if (bean instanceof BundleActionBean) {
query = BundleActionQueryExecutor.getInstance().getUpdateQuery((BundleActionQuery) entry.getQueryName(), (BundleActionBean) entry.getBean(), em);
} else if (bean instanceof SLARegistrationBean) {
query = SLARegistrationQueryExecutor.getInstance().getUpdateQuery((SLARegQuery) entry.getQueryName(), (SLARegistrationBean) entry.getBean(), em);
} else if (bean instanceof SLASummaryBean) {
query = SLASummaryQueryExecutor.getInstance().getUpdateQuery((SLASummaryQuery) entry.getQueryName(), (SLASummaryBean) entry.getBean(), em);
} else {
throw new JPAExecutorException(ErrorCode.E0603, "BatchQueryExecutor failed to construct a query");
}
queryList.add(new QueryEntry(entry.getQueryName(), query));
}
}
jpaService.executeBatchInsertUpdateDelete(insertList, queryList, deleteList, em);
}
Aggregations