Package org.apache.oozie.executor.jpa

Examples of org.apache.oozie.executor.jpa.WorkflowActionUpdateJPAExecutor


        List<WorkflowActionBean> actions = jpaService.execute(actionsGetExecutor);
        WorkflowActionBean action = actions.get(0);
        assertEquals(WorkflowActionBean.Status.RUNNING, action.getStatus());

        action.setLastCheckTime(new Date());
        jpaService.execute(new WorkflowActionUpdateJPAExecutor(action));

        int actionCheckDelay = 20;

        Runnable actionCheckRunnable = new ActionCheckRunnable(actionCheckDelay);
        actionCheckRunnable.run();
View Full Code Here


            throw new PreconditionException(ErrorCode.E0815, wfAction.getPending(), wfAction.getStatusStr());
        }
        if (wfJob.getStatus() != WorkflowJob.Status.RUNNING) {
            wfAction.setLastCheckTime(new Date());
            try {
                jpaService.execute(new WorkflowActionUpdateJPAExecutor(wfAction));
            }
            catch (JPAExecutorException e) {
                throw new CommandException(e);
            }
            throw new PreconditionException(ErrorCode.E0818, wfAction.getId(), wfJob.getId(), wfJob.getStatus());
View Full Code Here

                    continue;
                }
                else {
                    action.resetPendingOnly();
                }
                jpaService.execute(new WorkflowActionUpdateJPAExecutor(action));

            }
        }
        catch (JPAExecutorException je) {
            throw new CommandException(je);
View Full Code Here

            wfAction.resetPending();
            if (!skipAction) {
                wfAction.setTransition(workflowInstance.getTransition(wfAction.getName()));
            }
            try {
                jpaService.execute(new WorkflowActionUpdateJPAExecutor(wfAction));
            }
            catch (JPAExecutorException je) {
                throw new CommandException(je);
            }
        }

        if (completed) {
            try {
                for (String actionToKillId : WorkflowStoreService.getActionsToKill(workflowInstance)) {
                    WorkflowActionBean actionToKill;

                    actionToKill = jpaService.execute(new WorkflowActionGetJPAExecutor(actionToKillId));

                    actionToKill.setPending();
                    actionToKill.setStatus(WorkflowActionBean.Status.KILLED);
                    jpaService.execute(new WorkflowActionUpdateJPAExecutor(actionToKill));
                    queue(new ActionKillXCommand(actionToKill.getId(), actionToKill.getType()));
                }

                for (String actionToFailId : WorkflowStoreService.getActionsToFail(workflowInstance)) {
                    WorkflowActionBean actionToFail = jpaService.execute(new WorkflowActionGetJPAExecutor(
                            actionToFailId));
                    actionToFail.resetPending();
                    actionToFail.setStatus(WorkflowActionBean.Status.FAILED);
                    SLADbXOperations.writeStausEvent(wfAction.getSlaXml(), wfAction.getId(), Status.FAILED,
                            SlaAppType.WORKFLOW_ACTION);
                    jpaService.execute(new WorkflowActionUpdateJPAExecutor(actionToFail));
                }
            }
            catch (JPAExecutorException je) {
                throw new CommandException(je);
            }

            wfJob.setStatus(WorkflowJob.Status.valueOf(workflowInstance.getStatus().toString()));
            wfJob.setEndTime(new Date());
            wfJob.setWorkflowInstance(workflowInstance);
            Status slaStatus = Status.SUCCEEDED;
            switch (wfJob.getStatus()) {
                case SUCCEEDED:
                    slaStatus = Status.SUCCEEDED;
                    break;
                case KILLED:
                    slaStatus = Status.KILLED;
                    break;
                case FAILED:
                    slaStatus = Status.FAILED;
                    break;
                default: // TODO SUSPENDED
                    break;
            }
            SLADbXOperations.writeStausEvent(wfJob.getSlaXml(), jobId, slaStatus, SlaAppType.WORKFLOW_JOB);
            queue(new NotificationXCommand(wfJob));
            if (wfJob.getStatus() == WorkflowJob.Status.SUCCEEDED) {
                InstrumentUtils.incrJobCounter(INSTR_SUCCEEDED_JOBS_COUNTER_NAME, 1, getInstrumentation());
            }

            // output message for Kill node
            if (wfAction != null) { // wfAction could be a no-op job
                NodeDef nodeDef = workflowInstance.getNodeDef(wfAction.getExecutionPath());
                if (nodeDef != null && nodeDef instanceof KillNodeDef) {
                    boolean isRetry = false;
                    boolean isUserRetry = false;
                    ActionExecutorContext context = new ActionXCommand.ActionExecutorContext(wfJob, wfAction, isRetry,
                            isUserRetry);
                    try {
                        String tmpNodeConf = nodeDef.getConf();
                        String actionConf = context.getELEvaluator().evaluate(tmpNodeConf, String.class);
                        LOG.debug("Try to resolve KillNode message for jobid [{0}], actionId [{1}], before resolve [{2}], after resolve [{3}]",
                                        jobId, actionId, tmpNodeConf, actionConf);
                        if (wfAction.getErrorCode() != null) {
                            wfAction.setErrorInfo(wfAction.getErrorCode(), actionConf);
                        }
                        else {
                            wfAction.setErrorInfo(ErrorCode.E0729.toString(), actionConf);
                        }
                        jpaService.execute(new WorkflowActionUpdateJPAExecutor(wfAction));
                    }
                    catch (JPAExecutorException je) {
                        throw new CommandException(je);
                    }
                    catch (Exception ex) {
                        LOG.warn("Exception in SignalXCommand ", ex.getMessage(), ex);
                        throw new CommandException(ErrorCode.E0729, wfAction.getName(), ex);
                    }
                }
            }

        }
        else {
            for (WorkflowActionBean newAction : WorkflowStoreService.getStartedActions(workflowInstance)) {
                String skipVar = workflowInstance.getVar(newAction.getName() + WorkflowInstance.NODE_VAR_SEPARATOR
                        + ReRunCommand.TO_SKIP);
                boolean skipNewAction = false;
                if (skipVar != null) {
                    skipNewAction = skipVar.equals("true");
                }
                try {
                    if (skipNewAction) {
                        WorkflowActionBean oldAction;

                        oldAction = jpaService.execute(new WorkflowActionGetJPAExecutor(newAction.getId()));

                        oldAction.setPending();
                        jpaService.execute(new WorkflowActionUpdateJPAExecutor(oldAction));

                        queue(new SignalXCommand(jobId, oldAction.getId()));
                    }
                    else {
                        newAction.setPending();
View Full Code Here

            throw new PreconditionException(ErrorCode.E0815, wfAction.getPending(), wfAction.getStatusStr());
        }
        if (wfJob.getStatus() != WorkflowJob.Status.RUNNING) {
            wfAction.setLastCheckTime(new Date());
            try {
                jpaService.execute(new WorkflowActionUpdateJPAExecutor(wfAction));
            }
            catch (JPAExecutorException e) {
                throw new CommandException(e);
            }
            throw new PreconditionException(ErrorCode.E0818, wfAction.getId(), wfJob.getId(), wfJob.getStatus());
View Full Code Here

                            .getType());
                    wfAction.setErrorInfo(EXEC_DATA_MISSING,
                            "Execution Complete, but Execution Data Missing from Action");
                    failJob(context);
                    wfAction.setLastCheckTime(new Date());
                    jpaService.execute(new WorkflowActionUpdateJPAExecutor(wfAction));
                    jpaService.execute(new WorkflowJobUpdateJPAExecutor(wfJob));
                    return null;
                }
                wfAction.setPending();
                queue(new ActionEndXCommand(wfAction.getId(), wfAction.getType()));
            }
            wfAction.setLastCheckTime(new Date());
            jpaService.execute(new WorkflowActionUpdateJPAExecutor(wfAction));
            jpaService.execute(new WorkflowJobUpdateJPAExecutor(wfJob));
        }
        catch (ActionExecutorException ex) {
            LOG.warn("Exception while executing check(). Error Code [{0}], Message[{1}]", ex.getErrorCode(), ex
                    .getMessage(), ex);

            wfAction.setErrorInfo(ex.getErrorCode(), ex.getMessage());

            switch (ex.getErrorType()) {
                case FAILED:
                    failAction(wfJob, wfAction);
                    break;
                case ERROR:
                    handleUserRetry(wfAction);
                    break;
            }
            wfAction.setLastCheckTime(new Date());
            try {
                jpaService.execute(new WorkflowActionUpdateJPAExecutor(wfAction));
                jpaService.execute(new WorkflowJobUpdateJPAExecutor(wfJob));
            }
            catch (JPAExecutorException e) {
                throw new CommandException(e);
            }
View Full Code Here

        List<WorkflowActionBean> actions = jpaService.execute(actionsGetExecutor);
        WorkflowActionBean action = actions.get(0);
        assertEquals(WorkflowActionBean.Status.RUNNING, action.getStatus());

        action.setLastCheckTime(new Date());
        jpaService.execute(new WorkflowActionUpdateJPAExecutor(action));

        int actionCheckDelay = 20;

        Runnable actionCheckRunnable = new ActionCheckRunnable(actionCheckDelay);
        actionCheckRunnable.run();
View Full Code Here

                    LOG.warn(XLog.OPS, "Action Completed, ActionExecutor [{0}] must call setExecutionData()", executor
                            .getType());
                    wfAction.setErrorInfo(EXEC_DATA_MISSING,
                            "Execution Complete, but Execution Data Missing from Action");
                    failJob(context);
                    jpaService.execute(new WorkflowActionUpdateJPAExecutor(wfAction));
                    jpaService.execute(new WorkflowJobUpdateJPAExecutor(wfJob));
                    return null;
                }
                wfAction.setPending();
                queue(new ActionEndXCommand(wfAction.getId(), wfAction.getType()));
            }
            else {
                if (!context.isStarted()) {
                    LOG.warn(XLog.OPS, "Action Started, ActionExecutor [{0}] must call setStartData()", executor
                            .getType());
                    wfAction.setErrorInfo(START_DATA_MISSING, "Execution Started, but Start Data Missing from Action");
                    failJob(context);
                    jpaService.execute(new WorkflowActionUpdateJPAExecutor(wfAction));
                    jpaService.execute(new WorkflowJobUpdateJPAExecutor(wfJob));
                    return null;
                }
                queue(new NotificationXCommand(wfJob, wfAction));
            }

            LOG.warn(XLog.STD, "[***" + wfAction.getId() + "***]" + "Action status=" + wfAction.getStatusStr());

            jpaService.execute(new WorkflowActionUpdateJPAExecutor(wfAction));
            jpaService.execute(new WorkflowJobUpdateJPAExecutor(wfJob));
            // Add SLA status event (STARTED) for WF_ACTION
            SLADbXOperations.writeStausEvent(wfAction.getSlaXml(), wfAction.getId(), Status.STARTED,
                    SlaAppType.WORKFLOW_ACTION);
            LOG.warn(XLog.STD, "[***" + wfAction.getId() + "***]" + "Action updated in DB!");

        }
        catch (ActionExecutorException ex) {
            LOG.warn("Error starting action [{0}]. ErrorType [{1}], ErrorCode [{2}], Message [{3}]",
                    wfAction.getName(), ex.getErrorType(), ex.getErrorCode(), ex.getMessage(), ex);
            wfAction.setErrorInfo(ex.getErrorCode(), ex.getMessage());
            switch (ex.getErrorType()) {
                case TRANSIENT:
                    if (!handleTransient(context, executor, WorkflowAction.Status.START_RETRY)) {
                        handleNonTransient(context, executor, WorkflowAction.Status.START_MANUAL);
                        wfAction.setPendingAge(new Date());
                        wfAction.setRetries(0);
                        wfAction.setStartTime(null);
                    }
                    break;
                case NON_TRANSIENT:
                    handleNonTransient(context, executor, WorkflowAction.Status.START_MANUAL);
                    break;
                case ERROR:
                    handleError(context, executor, WorkflowAction.Status.ERROR.toString(), true,
                            WorkflowAction.Status.DONE);
                    break;
                case FAILED:
                    try {
                        failJob(context);
                        // update coordinator action
                        new CoordActionUpdateXCommand(wfJob, 3).call();
                        new WfEndXCommand(wfJob).call(); // To delete the WF temp dir
                        SLADbXOperations.writeStausEvent(wfAction.getSlaXml(), wfAction.getId(), Status.FAILED,
                                SlaAppType.WORKFLOW_ACTION);
                        SLADbXOperations.writeStausEvent(wfJob.getSlaXml(), wfJob.getId(), Status.FAILED,
                                SlaAppType.WORKFLOW_JOB);
                    }
                    catch (XException x) {
                        LOG.warn("ActionStartXCommand - case:FAILED ", x.getMessage());
                    }
                    break;
            }
            try {
                jpaService.execute(new WorkflowActionUpdateJPAExecutor(wfAction));
                jpaService.execute(new WorkflowJobUpdateJPAExecutor(wfJob));
            }
            catch (JPAExecutorException je) {
                throw new CommandException(je);
            }
View Full Code Here

    private void handleError(ActionExecutorContext context, WorkflowJobBean workflow, WorkflowActionBean action)
            throws CommandException {
        failJob(context);
        try {
            jpaService.execute(new WorkflowActionUpdateJPAExecutor(action));
            jpaService.execute(new WorkflowJobUpdateJPAExecutor(workflow));
        }
        catch (JPAExecutorException je) {
            throw new CommandException(je);
        }
View Full Code Here

            if (!context.isEnded()) {
                LOG.warn(XLog.OPS, "Action Ended, ActionExecutor [{0}] must call setEndData()",
                        executor.getType());
                wfAction.setErrorInfo(END_DATA_MISSING, "Execution Ended, but End Data Missing from Action");
                failJob(context);
                jpaService.execute(new WorkflowActionUpdateJPAExecutor(wfAction));
                jpaService.execute(new WorkflowJobUpdateJPAExecutor(wfJob));
                return null;
            }
            wfAction.setRetries(0);
            wfAction.setEndTime(new Date());

            boolean shouldHandleUserRetry = false;
            Status slaStatus = null;
            switch (wfAction.getStatus()) {
                case OK:
                    slaStatus = Status.SUCCEEDED;
                    break;
                case KILLED:
                    slaStatus = Status.KILLED;
                    break;
                case FAILED:
                    slaStatus = Status.FAILED;
                    shouldHandleUserRetry = true;
                    break;
                case ERROR:
                    LOG.info("ERROR is considered as FAILED for SLA");
                    slaStatus = Status.KILLED;
                    shouldHandleUserRetry = true;
                    break;
                default:
                    slaStatus = Status.FAILED;
                    shouldHandleUserRetry = true;
                    break;
            }
            if (!shouldHandleUserRetry || !handleUserRetry(wfAction)) {
                SLADbXOperations.writeStausEvent(wfAction.getSlaXml(), wfAction.getId(), slaStatus, SlaAppType.WORKFLOW_ACTION);
                queue(new NotificationXCommand(wfJob, wfAction));
                LOG.debug(
                        "Queuing commands for action=" + actionId + ", status=" + wfAction.getStatus()
                        + ", Set pending=" + wfAction.getPending());
                queue(new SignalXCommand(jobId, actionId));
            }

            jpaService.execute(new WorkflowActionUpdateJPAExecutor(wfAction));
            jpaService.execute(new WorkflowJobUpdateJPAExecutor(wfJob));
        }
        catch (ActionExecutorException ex) {
            LOG.warn(
                    "Error ending action [{0}]. ErrorType [{1}], ErrorCode [{2}], Message [{3}]",
                    wfAction.getName(), ex.getErrorType(), ex.getErrorCode(), ex.getMessage());
            wfAction.setErrorInfo(ex.getErrorCode(), ex.getMessage());
            wfAction.setEndTime(null);

            switch (ex.getErrorType()) {
                case TRANSIENT:
                    if (!handleTransient(context, executor, WorkflowAction.Status.END_RETRY)) {
                        handleNonTransient(context, executor, WorkflowAction.Status.END_MANUAL);
                        wfAction.setPendingAge(new Date());
                        wfAction.setRetries(0);
                    }
                    wfAction.setEndTime(null);
                    break;
                case NON_TRANSIENT:
                    handleNonTransient(context, executor, WorkflowAction.Status.END_MANUAL);
                    wfAction.setEndTime(null);
                    break;
                case ERROR:
                    handleError(context, executor, COULD_NOT_END, false, WorkflowAction.Status.ERROR);
                    queue(new SignalXCommand(jobId, actionId));
                    break;
                case FAILED:
                    failJob(context);
                    break;
            }

            WorkflowInstance wfInstance = wfJob.getWorkflowInstance();
            DagELFunctions.setActionInfo(wfInstance, wfAction);
            wfJob.setWorkflowInstance(wfInstance);

            try {
                jpaService.execute(new WorkflowActionUpdateJPAExecutor(wfAction));
                jpaService.execute(new WorkflowJobUpdateJPAExecutor(wfJob));
            }
            catch (JPAExecutorException je) {
                throw new CommandException(je);
            }
View Full Code Here

TOP

Related Classes of org.apache.oozie.executor.jpa.WorkflowActionUpdateJPAExecutor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.