Search in sources :

Example 6 with CoordJobQuery

use of org.apache.oozie.executor.jpa.CoordJobQueryExecutor.CoordJobQuery 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));
        }
    }
}
Also used : CoordJobGetActionsSuspendedJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetActionsSuspendedJPAExecutor) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) XException(org.apache.oozie.XException) ResumeXCommand(org.apache.oozie.command.wf.ResumeXCommand) CommandException(org.apache.oozie.command.CommandException) CoordJobQuery(org.apache.oozie.executor.jpa.CoordJobQueryExecutor.CoordJobQuery)

Example 7 with CoordJobQuery

use of org.apache.oozie.executor.jpa.CoordJobQueryExecutor.CoordJobQuery 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);
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) SLARegistrationBean(org.apache.oozie.sla.SLARegistrationBean) JsonBean(org.apache.oozie.client.rest.JsonBean) CoordActionQuery(org.apache.oozie.executor.jpa.CoordActionQueryExecutor.CoordActionQuery) SLARegQuery(org.apache.oozie.executor.jpa.SLARegistrationQueryExecutor.SLARegQuery) CoordJobQuery(org.apache.oozie.executor.jpa.CoordJobQueryExecutor.CoordJobQuery) BundleJobQuery(org.apache.oozie.executor.jpa.BundleJobQueryExecutor.BundleJobQuery) SLASummaryQuery(org.apache.oozie.executor.jpa.SLASummaryQueryExecutor.SLASummaryQuery) Query(javax.persistence.Query) WorkflowActionQuery(org.apache.oozie.executor.jpa.WorkflowActionQueryExecutor.WorkflowActionQuery) BundleActionQuery(org.apache.oozie.executor.jpa.BundleActionQueryExecutor.BundleActionQuery) WorkflowJobQuery(org.apache.oozie.executor.jpa.WorkflowJobQueryExecutor.WorkflowJobQuery) SLARegQuery(org.apache.oozie.executor.jpa.SLARegistrationQueryExecutor.SLARegQuery) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) BundleJobQuery(org.apache.oozie.executor.jpa.BundleJobQueryExecutor.BundleJobQuery) ArrayList(java.util.ArrayList) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean) QueryEntry(org.apache.oozie.service.JPAService.QueryEntry) EntityManager(javax.persistence.EntityManager) WorkflowJobQuery(org.apache.oozie.executor.jpa.WorkflowJobQueryExecutor.WorkflowJobQuery) BundleJobBean(org.apache.oozie.BundleJobBean) JPAService(org.apache.oozie.service.JPAService) CoordJobQuery(org.apache.oozie.executor.jpa.CoordJobQueryExecutor.CoordJobQuery) BundleActionBean(org.apache.oozie.BundleActionBean) SLASummaryBean(org.apache.oozie.sla.SLASummaryBean)

Aggregations

CoordJobQuery (org.apache.oozie.executor.jpa.CoordJobQueryExecutor.CoordJobQuery)7 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)4 Date (java.util.Date)3 XException (org.apache.oozie.XException)3 CommandException (org.apache.oozie.command.CommandException)3 ArrayList (java.util.ArrayList)2 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)2 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)2 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)2 JsonBean (org.apache.oozie.client.rest.JsonBean)2 WorkflowJobQuery (org.apache.oozie.executor.jpa.WorkflowJobQueryExecutor.WorkflowJobQuery)2 JPAService (org.apache.oozie.service.JPAService)2 EntityManager (javax.persistence.EntityManager)1 Query (javax.persistence.Query)1 BundleActionBean (org.apache.oozie.BundleActionBean)1 BundleJobBean (org.apache.oozie.BundleJobBean)1 BundleStatusUpdateXCommand (org.apache.oozie.command.bundle.BundleStatusUpdateXCommand)1 ResumeXCommand (org.apache.oozie.command.wf.ResumeXCommand)1 SuspendXCommand (org.apache.oozie.command.wf.SuspendXCommand)1 UpdateEntry (org.apache.oozie.executor.jpa.BatchQueryExecutor.UpdateEntry)1