Search in sources :

Example 1 with CoordJobGetActionsRunningJPAExecutor

use of org.apache.oozie.executor.jpa.CoordJobGetActionsRunningJPAExecutor in project oozie by apache.

the class CoordSuspendXCommand method suspendChildren.

@Override
public void suspendChildren() throws CommandException {
    try {
        // Get all running actions of a job to suspend them
        List<CoordinatorActionBean> actionList = jpaService.execute(new CoordJobGetActionsRunningJPAExecutor(jobId));
        for (CoordinatorActionBean action : actionList) {
            // queue a SuspendXCommand
            if (action.getExternalId() != null) {
                queue(new SuspendXCommand(action.getExternalId()));
                updateCoordAction(action);
                LOG.debug("Suspend coord action = [{0}], new status = [{1}], pending = [{2}] and queue SuspendXCommand for [{3}]", action.getId(), action.getStatus(), action.getPending(), action.getExternalId());
            } else {
                updateCoordAction(action);
                LOG.debug("Suspend coord action = [{0}], new status = [{1}], pending = [{2}] and external id is null", action.getId(), action.getStatus(), action.getPending());
            }
        }
        LOG.debug("Suspended coordinator actions for the coordinator=[{0}]", jobId);
    } catch (XException ex) {
        exceptionOccured = true;
        throw new CommandException(ex);
    } finally {
        if (exceptionOccured) {
            coordJob.setStatus(CoordinatorJob.Status.FAILED);
            coordJob.resetPending();
            LOG.debug("Exception happened, fail coordinator job id = " + jobId + ", status = " + coordJob.getStatus());
            updateList.add(new UpdateEntry<CoordJobQuery>(CoordJobQuery.UPDATE_COORD_JOB_STATUS_PENDING_TIME, coordJob));
        }
    }
}
Also used : SuspendXCommand(org.apache.oozie.command.wf.SuspendXCommand) CoordJobGetActionsRunningJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetActionsRunningJPAExecutor) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) XException(org.apache.oozie.XException) CommandException(org.apache.oozie.command.CommandException) CoordJobQuery(org.apache.oozie.executor.jpa.CoordJobQueryExecutor.CoordJobQuery)

Aggregations

CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)1 XException (org.apache.oozie.XException)1 CommandException (org.apache.oozie.command.CommandException)1 SuspendXCommand (org.apache.oozie.command.wf.SuspendXCommand)1 CoordJobGetActionsRunningJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetActionsRunningJPAExecutor)1 CoordJobQuery (org.apache.oozie.executor.jpa.CoordJobQueryExecutor.CoordJobQuery)1