use of org.apache.oozie.BundleJobBean 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.BundleJobBean in project oozie by apache.
the class BulkBundleXCommand method execute.
/* (non-Javadoc)
* @see org.apache.oozie.command.XCommand#execute()
*/
@Override
protected BundleJobInfo execute() throws CommandException {
List<BundleJobBean> jobs = this.bundleJobInfo.getBundleJobs();
for (BundleJobBean job : jobs) {
switch(operation) {
case Kill:
if (job.getStatus() != Job.Status.SUCCEEDED && job.getStatus() != Job.Status.FAILED && job.getStatus() != Job.Status.DONEWITHERROR && job.getStatus() != Job.Status.KILLED) {
new BundleKillXCommand(job.getId()).call();
}
break;
case Suspend:
if (job.getStatus() != Job.Status.SUCCEEDED && job.getStatus() != Job.Status.FAILED && job.getStatus() != Job.Status.KILLED && job.getStatus() != Job.Status.DONEWITHERROR) {
new BundleJobSuspendXCommand(job.getId()).call();
}
break;
case Resume:
if (job.getStatus() == Job.Status.SUSPENDED || job.getStatus() == Job.Status.SUSPENDEDWITHERROR || job.getStatus() == Job.Status.PREPSUSPENDED) {
new BundleJobResumeXCommand(job.getId()).call();
}
break;
default:
throw new CommandException(ErrorCode.E1102, operation);
}
}
loadBundleJobs();
return this.bundleJobInfo;
}
use of org.apache.oozie.BundleJobBean 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);
}
use of org.apache.oozie.BundleJobBean in project oozie by apache.
the class BulkJPAExecutor method execute.
@Override
public BulkResponseInfo execute(EntityManager em) throws JPAExecutorException {
List<BulkResponseImpl> responseList = new ArrayList<BulkResponseImpl>();
Map<String, Timestamp> actionTimes = new HashMap<String, Timestamp>();
try {
List<String> coords = bulkFilter.get(BulkResponseImpl.BULK_FILTER_COORD);
List<String> statuses = bulkFilter.get(BulkResponseImpl.BULK_FILTER_STATUS);
List<String> params = new ArrayList<String>();
// Lightweight Query 1 on Bundle level to fetch the bundle job(s)
// corresponding to names or ids
List<BundleJobBean> bundleBeans = bundleQuery(em);
// Join query between coordinator job and coordinator action tables
// to get entries for specific bundleId only
String conditions = actionQuery(coords, params, statuses, em, bundleBeans, actionTimes, responseList);
// Query to get the count of records
long total = countQuery(statuses, params, conditions, em, bundleBeans, actionTimes);
BulkResponseInfo bulk = new BulkResponseInfo(responseList, start, len, total);
return bulk;
} catch (Exception e) {
throw new JPAExecutorException(ErrorCode.E0603, e.getMessage(), e);
}
}
use of org.apache.oozie.BundleJobBean in project oozie by apache.
the class BulkJPAExecutor method bundleQuery.
/**
* build the bundle level query to get bundle beans for the specified ids or appnames
* @param em
* @return List BundleJobBeans
* @throws JPAExecutorException
*/
@SuppressWarnings("unchecked")
private List<BundleJobBean> bundleQuery(EntityManager em) throws JPAExecutorException {
Query q = em.createNamedQuery("BULK_MONITOR_BUNDLE_QUERY");
StringBuilder bundleQuery = new StringBuilder(q.toString());
StringBuilder whereClause = null;
List<String> bundles = bulkFilter.get(BulkResponseImpl.BULK_FILTER_BUNDLE);
if (bundles != null) {
PARAM_TYPE type = getParamType(bundles.get(0), 'B');
if (type == PARAM_TYPE.NAME) {
whereClause = inClause(bundles.size(), "appName", 'b', "bundles");
} else if (type == PARAM_TYPE.ID) {
whereClause = inClause(bundles.size(), "id", 'b', "bundles");
}
// Query: select <columns> from BundleJobBean b where b.id IN (...) _or_ b.appName IN (...)
bundleQuery.append(whereClause.replace(whereClause.indexOf("AND"), whereClause.indexOf("AND") + 3, "WHERE"));
Query tmp = em.createQuery(bundleQuery.toString());
fillParameters(tmp, "bundles", bundles);
List<Object[]> bundleObjs = (List<Object[]>) tmp.getResultList();
if (bundleObjs.isEmpty()) {
throw new JPAExecutorException(ErrorCode.E0603, "No entries found for given bundle(s)");
}
List<BundleJobBean> bundleBeans = new ArrayList<BundleJobBean>();
for (Object[] bundleElem : bundleObjs) {
bundleBeans.add(constructBundleBean(bundleElem));
}
return bundleBeans;
}
return null;
}
Aggregations