Search in sources :

Example 1 with BundleJobQuery

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);
    }
}
Also used : BundleJobQuery(org.apache.oozie.executor.jpa.BundleJobQueryExecutor.BundleJobQuery) XException(org.apache.oozie.XException) CommandException(org.apache.oozie.command.CommandException) BundleActionBean(org.apache.oozie.BundleActionBean) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) XException(org.apache.oozie.XException) CommandException(org.apache.oozie.command.CommandException) PreconditionException(org.apache.oozie.command.PreconditionException) CoordChangeXCommand(org.apache.oozie.command.coord.CoordChangeXCommand)

Example 2 with BundleJobQuery

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));
}
Also used : BundleJobQuery(org.apache.oozie.executor.jpa.BundleJobQueryExecutor.BundleJobQuery) Date(java.util.Date)

Example 3 with BundleJobQuery

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));
}
Also used : BundleJobQuery(org.apache.oozie.executor.jpa.BundleJobQueryExecutor.BundleJobQuery) Date(java.util.Date)

Example 4 with BundleJobQuery

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);
}
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

BundleJobQuery (org.apache.oozie.executor.jpa.BundleJobQueryExecutor.BundleJobQuery)4 Date (java.util.Date)2 BundleActionBean (org.apache.oozie.BundleActionBean)2 ArrayList (java.util.ArrayList)1 EntityManager (javax.persistence.EntityManager)1 Query (javax.persistence.Query)1 BundleJobBean (org.apache.oozie.BundleJobBean)1 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)1 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)1 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)1 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)1 XException (org.apache.oozie.XException)1 JsonBean (org.apache.oozie.client.rest.JsonBean)1 CommandException (org.apache.oozie.command.CommandException)1 PreconditionException (org.apache.oozie.command.PreconditionException)1 CoordChangeXCommand (org.apache.oozie.command.coord.CoordChangeXCommand)1 BundleActionQuery (org.apache.oozie.executor.jpa.BundleActionQueryExecutor.BundleActionQuery)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