Search in sources :

Example 1 with BundleActionQuery

use of org.apache.oozie.executor.jpa.BundleActionQueryExecutor.BundleActionQuery in project oozie by apache.

the class BundleJobResumeXCommand method updateBundleAction.

private void updateBundleAction(BundleActionBean action) {
    if (action.getStatus() == Job.Status.PREPSUSPENDED) {
        action.setStatus(Job.Status.PREP);
    } else if (action.getStatus() == Job.Status.SUSPENDED) {
        action.setStatus(Job.Status.RUNNING);
    } else if (action.getStatus() == Job.Status.SUSPENDEDWITHERROR) {
        action.setStatus(Job.Status.RUNNINGWITHERROR);
    }
    action.incrementAndGetPending();
    action.setLastModifiedTime(new Date());
    updateList.add(new UpdateEntry<BundleActionQuery>(BundleActionQuery.UPDATE_BUNDLE_ACTION_STATUS_PENDING_MODTIME, action));
}
Also used : BundleActionQuery(org.apache.oozie.executor.jpa.BundleActionQueryExecutor.BundleActionQuery) Date(java.util.Date)

Example 2 with BundleActionQuery

use of org.apache.oozie.executor.jpa.BundleActionQueryExecutor.BundleActionQuery in project oozie by apache.

the class BundleRerunXCommand method updateBundleAction.

/**
 * Update bundle action
 *
 * @param action the bundle action
 * @throws CommandException thrown if failed to update bundle action
 */
private void updateBundleAction(BundleActionBean action) {
    action.incrementAndGetPending();
    action.setLastModifiedTime(new Date());
    updateList.add(new UpdateEntry<BundleActionQuery>(BundleActionQuery.UPDATE_BUNDLE_ACTION_PENDING_MODTIME, action));
}
Also used : BundleActionQuery(org.apache.oozie.executor.jpa.BundleActionQueryExecutor.BundleActionQuery) Date(java.util.Date)

Example 3 with BundleActionQuery

use of org.apache.oozie.executor.jpa.BundleActionQueryExecutor.BundleActionQuery in project oozie by apache.

the class BundleJobSuspendXCommand method updateBundleAction.

private void updateBundleAction(BundleActionBean action) {
    if (action.getStatus() == Job.Status.PREP) {
        action.setStatus(Job.Status.PREPSUSPENDED);
    } else if (action.getStatus() == Job.Status.RUNNING) {
        action.setStatus(Job.Status.SUSPENDED);
    } else if (action.getStatus() == Job.Status.RUNNINGWITHERROR) {
        action.setStatus(Job.Status.SUSPENDEDWITHERROR);
    } else if (action.getStatus() == Job.Status.PAUSED) {
        action.setStatus(Job.Status.SUSPENDED);
    } else if (action.getStatus() == Job.Status.PAUSEDWITHERROR) {
        action.setStatus(Job.Status.SUSPENDEDWITHERROR);
    }
    action.incrementAndGetPending();
    action.setLastModifiedTime(new Date());
    updateList.add(new UpdateEntry<BundleActionQuery>(BundleActionQuery.UPDATE_BUNDLE_ACTION_STATUS_PENDING_MODTIME, action));
}
Also used : BundleActionQuery(org.apache.oozie.executor.jpa.BundleActionQueryExecutor.BundleActionQuery) Date(java.util.Date)

Example 4 with BundleActionQuery

use of org.apache.oozie.executor.jpa.BundleActionQueryExecutor.BundleActionQuery in project oozie by apache.

the class BundleKillXCommand method updateBundleAction.

/**
 * Update bundle action
 *
 * @param action
 * @throws CommandException
 */
private void updateBundleAction(BundleActionBean action) {
    action.setLastModifiedTime(new Date());
    if (!action.isTerminalStatus()) {
        action.incrementAndGetPending();
        action.setStatus(Job.Status.KILLED);
    } else {
        // while coordinator is killed.
        if (action.isPending()) {
            if (action.getCoordId() == null) {
                action.setPending(0);
            } else {
                try {
                    CoordinatorJobBean coordJob = CoordJobQueryExecutor.getInstance().get(CoordJobQuery.GET_COORD_JOB, action.getCoordId());
                    if (!coordJob.isPending() && coordJob.isTerminalStatus()) {
                        action.setPending(0);
                        action.setStatus(coordJob.getStatus());
                    }
                } catch (JPAExecutorException e) {
                    LOG.warn("Error in checking coord job status:" + action.getCoordId(), e);
                }
            }
        }
    }
    updateList.add(new UpdateEntry<BundleActionQuery>(BundleActionQuery.UPDATE_BUNDLE_ACTION_STATUS_PENDING_MODTIME, action));
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) BundleActionQuery(org.apache.oozie.executor.jpa.BundleActionQueryExecutor.BundleActionQuery) Date(java.util.Date)

Example 5 with BundleActionQuery

use of org.apache.oozie.executor.jpa.BundleActionQueryExecutor.BundleActionQuery 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

BundleActionQuery (org.apache.oozie.executor.jpa.BundleActionQueryExecutor.BundleActionQuery)5 Date (java.util.Date)4 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)2 ArrayList (java.util.ArrayList)1 EntityManager (javax.persistence.EntityManager)1 Query (javax.persistence.Query)1 BundleActionBean (org.apache.oozie.BundleActionBean)1 BundleJobBean (org.apache.oozie.BundleJobBean)1 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)1 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)1 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)1 JsonBean (org.apache.oozie.client.rest.JsonBean)1 BundleJobQuery (org.apache.oozie.executor.jpa.BundleJobQueryExecutor.BundleJobQuery)1 CoordActionQuery (org.apache.oozie.executor.jpa.CoordActionQueryExecutor.CoordActionQuery)1 CoordJobQuery (org.apache.oozie.executor.jpa.CoordJobQueryExecutor.CoordJobQuery)1 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)1 SLARegQuery (org.apache.oozie.executor.jpa.SLARegistrationQueryExecutor.SLARegQuery)1 SLASummaryQuery (org.apache.oozie.executor.jpa.SLASummaryQueryExecutor.SLASummaryQuery)1 WorkflowActionQuery (org.apache.oozie.executor.jpa.WorkflowActionQueryExecutor.WorkflowActionQuery)1 WorkflowJobQuery (org.apache.oozie.executor.jpa.WorkflowJobQueryExecutor.WorkflowJobQuery)1